Load radare script from Options Dialoh (#464)

* Initial implementation of radare script loading from OptionsDialog
* Fixed and removed redundant function
This commit is contained in:
Itay Cohen 2018-04-30 09:39:48 +03:00 committed by xarkes
parent 63788c1715
commit 5e4dff9639
4 changed files with 80 additions and 2 deletions

View File

@ -106,6 +106,10 @@ void AnalThread::run()
core->loadPDB(ui->pdbLineEdit->text());
}
if (ui->scriptCheckBox->isChecked()) {
core->loadScript(ui->scriptLineEdit->text());
}
if (optionsDialog->getSelectedEndianness() != OptionsDialog::Endianness::Auto) {
core->setEndianness(optionsDialog->getSelectedEndianness() == OptionsDialog::Endianness::Big);
}

View File

@ -54,6 +54,10 @@ OptionsDialog::OptionsDialog(MainWindow *main):
connect(ui->pdbCheckBox, SIGNAL(stateChanged(int)), this, SLOT(updatePDBLayout()));
updateScriptLayout();
connect(ui->scriptCheckBox, SIGNAL(stateChanged(int)), this, SLOT(updateScriptLayout()));
// Add this so the dialog resizes when widgets are shown/hidden
//this->layout()->setSizeConstraint(QLayout::SetFixedSize);
@ -343,6 +347,30 @@ void OptionsDialog::on_pdbSelectButton_clicked()
}
}
void OptionsDialog::updateScriptLayout()
{
ui->scriptWidget->setEnabled(ui->scriptCheckBox->isChecked());
}
void OptionsDialog::on_scriptSelectButton_clicked()
{
QFileDialog dialog(this);
dialog.setWindowTitle(tr("Select radare2 script file"));
dialog.setNameFilters({ tr("Script file (*.r2)"), tr("All files (*)") });
if (!dialog.exec()) {
return;
}
QString fileName = dialog.selectedFiles().first();
if (!fileName.isEmpty()) {
ui->scriptLineEdit->setText(fileName);
}
}
void OptionsDialog::reject()
{
done(0);

View File

@ -33,11 +33,13 @@ private slots:
void on_analCheckBox_clicked(bool checked);
void on_archComboBox_currentIndexChanged(int index);
void on_pdbSelectButton_clicked();
void on_scriptSelectButton_clicked();
void updateProgressTimer();
void updatePDBLayout();
void updateScriptLayout();
void anal_finished();
protected:

View File

@ -885,7 +885,51 @@
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="scriptCheckBox">
<property name="text">
<string>Load script file</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QWidget" name="scriptWidget" native="true">
<property name="enabled">
<bool>true</bool>
</property>
<layout class="QHBoxLayout" name="scriptLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="scriptLineEdit">
<property name="placeholderText">
<string>Path to radare2 script file</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="scriptSelectButton">
<property name="text">
<string>Select</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="analbbLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@ -904,7 +948,7 @@
</property>
</widget>
</item>
<item row="3" column="1">
<item row="4" column="1">
<widget class="QLineEdit" name="entry_analbb">
<property name="text">
<string>1024</string>