Add more options in the menu and loading

This commit is contained in:
Florian Märkl 2017-10-01 18:03:06 +02:00 committed by Maijin
parent 808da402da
commit 675ca69976
8 changed files with 145 additions and 27 deletions

View File

@ -77,6 +77,8 @@ void AnalThread::run()
forceBinPlugin = pluginDesc.name;
}
main->core->setConfig("bin.demangle", ui->demangleCheckBox->isChecked());
main->core->loadFile(main->getFilename(), loadaddr, mapaddr, rw, va, binidx, load_bininfo, forceBinPlugin);
emit updateProgress("Analysis in progress.");

View File

@ -508,6 +508,9 @@ void CutterCore::resetDefaultAsmOptions()
setConfig("asm.syntax", settings.getAsmSyntax());
setConfig("asm.ucase", settings.getAsmUppercase());
setConfig("asm.bbline", settings.getAsmBBLine());
setConfig("asm.capitalize", settings.getAsmCapitalize());
setConfig("asm.varsub", settings.getAsmVarsub());
setConfig("asm.varsub_only", settings.getAsmVarsubOnly());
}
void CutterCore::saveDefaultAsmOptions()
@ -524,6 +527,9 @@ void CutterCore::saveDefaultAsmOptions()
settings.setAsmSyntax(getConfig("asm.syntax"));
settings.setAsmUppercase(getConfigb("asm.ucase"));
settings.setAsmBBLine(getConfigb("asm.bbline"));
settings.setAsmCapitalize(getConfigb("asm.capitalize"));
settings.setAsmVarsub(getConfigb("asm.varsub"));
settings.setAsmVarsubOnly(getConfigb("asm.varsub_only"));
}
QString CutterCore::getConfig(const QString &k)

View File

@ -53,8 +53,27 @@ void AsmOptionsDialog::updateFromVars()
}
}
qhelpers::setCheckedWithoutSignals(ui->uppercaseCheckBox, core->getConfigb("asm.ucase"));
ui->caseComboBox->blockSignals(true);
if (core->getConfigb("asm.ucase"))
{
ui->caseComboBox->setCurrentIndex(1);
}
else if(core->getConfigb("asm.capitalize"))
{
ui->caseComboBox->setCurrentIndex(2);
}
else
{
ui->caseComboBox->setCurrentIndex(0);
}
ui->caseComboBox->blockSignals(false);
qhelpers::setCheckedWithoutSignals(ui->bblineCheckBox, core->getConfigb("asm.bbline"));
bool varsubEnabled = core->getConfigb("asm.varsub");
qhelpers::setCheckedWithoutSignals(ui->varsubCheckBox, varsubEnabled);
qhelpers::setCheckedWithoutSignals(ui->varsubOnlyCheckBox, core->getConfigb("asm.varsub_only"));
ui->varsubOnlyCheckBox->setEnabled(varsubEnabled);
}
@ -127,9 +146,35 @@ void AsmOptionsDialog::on_syntaxComboBox_currentIndexChanged(int index)
core->triggerAsmOptionsChanged();
}
void AsmOptionsDialog::on_uppercaseCheckBox_toggled(bool checked)
void AsmOptionsDialog::on_caseComboBox_currentIndexChanged(int index)
{
core->setConfig("asm.ucase", checked);
bool ucase;
bool capitalize;
switch (index)
{
// lowercase
case 0:
default:
ucase = false;
capitalize = false;
break;
// uppercase
case 1:
ucase = true;
capitalize = false;
break;
case 2:
ucase = false;
capitalize = true;
break;
}
core->setConfig("asm.ucase", ucase);
core->setConfig("asm.capitalize", capitalize);
core->triggerAsmOptionsChanged();
}
@ -139,17 +184,30 @@ void AsmOptionsDialog::on_bblineCheckBox_toggled(bool checked)
core->triggerAsmOptionsChanged();
}
void AsmOptionsDialog::on_varsubCheckBox_toggled(bool checked)
{
core->setConfig("asm.varsub", checked);
ui->varsubOnlyCheckBox->setEnabled(checked);
core->triggerAsmOptionsChanged();
}
void AsmOptionsDialog::on_varsubOnlyCheckBox_toggled(bool checked)
{
core->setConfig("asm.varsub_only", checked);
core->triggerAsmOptionsChanged();
}
void AsmOptionsDialog::on_buttonBox_clicked(QAbstractButton *button)
{
switch (ui->buttonBox->buttonRole(button))
{
case QDialogButtonBox::ButtonRole::ApplyRole:
saveAsDefault();
break;
case QDialogButtonBox::ButtonRole::ResetRole:
resetToDefault();
break;
default:
break;
case QDialogButtonBox::ButtonRole::ApplyRole:
saveAsDefault();
break;
case QDialogButtonBox::ButtonRole::ResetRole:
resetToDefault();
break;
default:
break;
}
}

View File

@ -40,8 +40,10 @@ private slots:
void on_bytespaceCheckBox_toggled(bool checked);
void on_lbytesCheckBox_toggled(bool checked);
void on_syntaxComboBox_currentIndexChanged(int index);
void on_uppercaseCheckBox_toggled(bool checked);
void on_caseComboBox_currentIndexChanged(int index);
void on_bblineCheckBox_toggled(bool checked);
void on_varsubCheckBox_toggled(bool checked);
void on_varsubOnlyCheckBox_toggled(bool checked);
void on_buttonBox_clicked(QAbstractButton *button);
};

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>415</width>
<height>368</height>
<width>445</width>
<height>631</height>
</rect>
</property>
<property name="windowTitle">
@ -81,26 +81,38 @@
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QComboBox" name="syntaxComboBox"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="syntaxLabel">
<property name="text">
<string>Syntax (asm.syntax):</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="syntaxComboBox"/>
<item row="1" column="1">
<widget class="QComboBox" name="caseComboBox">
<item>
<property name="text">
<string>Lowercase</string>
</property>
</item>
<item>
<property name="text">
<string>Uppercase (asm.ucase)</string>
</property>
</item>
<item>
<property name="text">
<string>CamelCase (asm.capitalize)</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="uppercaseCheckBox">
<property name="text">
<string>Uppercase syntax (asm.ucase)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="bblineCheckBox">
<property name="text">
@ -108,6 +120,27 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="varsubCheckBox">
<property name="text">
<string>Substitute variables (asm.varsub)</string>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="leftMargin">
<number>16</number>
</property>
<item>
<widget class="QCheckBox" name="varsubOnlyCheckBox">
<property name="text">
<string>Substitute entire variable expressions with names (asm.varsub_only)</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">

View File

@ -436,6 +436,16 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="demangleCheckBox">
<property name="text">
<string>Import demangled symbols</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>

View File

@ -42,6 +42,15 @@ public:
bool getAsmBBLine() const { return settings.value("asm.bbline", false).toBool(); }
void setAsmBBLine(bool v) { settings.setValue("asm.bbline", v); }
bool getAsmCapitalize() const { return settings.value("asm.capitalize", false).toBool(); }
void setAsmCapitalize(bool v) { settings.setValue("asm.capitalize", v); }
bool getAsmVarsub() const { return settings.value("asm.varsub", true).toBool(); }
void setAsmVarsub(bool v) { settings.setValue("asm.varsub", v); }
bool getAsmVarsubOnly() const { return settings.value("asm.varsub_only", true).toBool(); }
void setAsmVarsubOnly(bool v) { settings.setValue("asm.varsub_only", v); }
};
#endif // SETTINGS_H

View File

@ -68,8 +68,6 @@ static const int invalidHistoryPos = -1;
static bool isForbidden(const QString &input)
{
return false;
static const QRegExp delimiters("[;&]");