diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 7d8ef2fc..7b0c10be 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -286,18 +286,19 @@ void MainWindow::openNewFile(const QString &fn, int analLevel, QList ad /* Prompt to load filename.r2 script */ QString script = QString("%1.r2").arg(this->filename); + QString loadScript; if (r_file_exists(script.toStdString().data())) { QMessageBox mb; mb.setWindowTitle(tr("Script loading")); mb.setText(tr("Do you want to load the '%1' script?").arg(script)); mb.setStandardButtons(QMessageBox::Yes | QMessageBox::No); if (mb.exec() == QMessageBox::Yes) { - core->loadScript(script); + loadScript = script; } } /* Show analysis options dialog */ - displayAnalysisOptionsDialog(analLevel, advancedOptions); + displayAnalysisOptionsDialog(analLevel, advancedOptions, loadScript); } void MainWindow::openNewFileFailed() @@ -327,10 +328,11 @@ void MainWindow::closeNewFileDialog() newFileDialog = nullptr; } -void MainWindow::displayAnalysisOptionsDialog(int analLevel, QList advancedOptions) +void MainWindow::displayAnalysisOptionsDialog(int analLevel, QList advancedOptions, const QString &script) { OptionsDialog *o = new OptionsDialog(this); o->setAttribute(Qt::WA_DeleteOnClose); + o->setInitialScript(script); o->show(); if (analLevel >= 0) { @@ -823,7 +825,7 @@ void MainWindow::on_actionRefresh_Panels_triggered() void MainWindow::on_actionAnalyze_triggered() { - displayAnalysisOptionsDialog(-1, QList()); + displayAnalysisOptionsDialog(-1, QList(), nullptr); } void MainWindow::on_actionImportPDB_triggered() diff --git a/src/MainWindow.h b/src/MainWindow.h index b6baf649..0bbc4704 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -71,7 +71,7 @@ public: QList advancedOptions = QList()); void displayNewFileDialog(); void closeNewFileDialog(); - void displayAnalysisOptionsDialog(int analLevel, QList advancedOptions); + void displayAnalysisOptionsDialog(int analLevel, QList advancedOptions, const QString &script); void openProject(const QString &project_name); void initUI(); diff --git a/src/dialogs/OptionsDialog.cpp b/src/dialogs/OptionsDialog.cpp index 7db4db9e..aaf622fa 100644 --- a/src/dialogs/OptionsDialog.cpp +++ b/src/dialogs/OptionsDialog.cpp @@ -82,6 +82,15 @@ void OptionsDialog::updateCPUComboBox() ui->cpuComboBox->lineEdit()->setText(currentText); } +void OptionsDialog::setInitialScript(const QString &script) +{ + ui->scriptCheckBox->setChecked(!script.isEmpty()); + ui->scriptLineEdit->setText(script); + if (!script.isEmpty()) { + ui->analSlider->setValue(0); + } +} + QString OptionsDialog::getSelectedArch() { QVariant archValue = ui->archComboBox->currentData(); diff --git a/src/dialogs/OptionsDialog.h b/src/dialogs/OptionsDialog.h index 22bc94be..95610953 100644 --- a/src/dialogs/OptionsDialog.h +++ b/src/dialogs/OptionsDialog.h @@ -40,6 +40,8 @@ protected: void closeEvent(QCloseEvent *event) override; private: + std::unique_ptr ui; + MainWindow *main; CutterCore *core; int defaultAnalLevel; @@ -49,7 +51,7 @@ private: void updateCPUComboBox(); public: - std::unique_ptr ui; + void setInitialScript(const QString &script); QString getSelectedArch(); QString getSelectedCPU();