Added a checkbox in the preferences dialog for asm.indent (#1175)

* Added a checkbox in the preferences dialog for asm.indent

* Fixed styling

* Made description more accurate
This commit is contained in:
Philip Nelson 2019-02-07 17:55:24 -05:00 committed by Itay Cohen
parent 1a132ecf83
commit 49b27ba241
4 changed files with 35 additions and 19 deletions

View File

@ -24,6 +24,7 @@ static const QHash<QString, QVariant> asmOptions = {
{ "asm.pseudo", false },
{ "asm.offset", true },
{ "asm.xrefs", false },
{ "asm.indent", false },
{ "asm.describe", false },
{ "asm.stackptr", false },
{ "asm.slow", true },
@ -58,10 +59,10 @@ Configuration::Configuration() : QObject()
mPtr = this;
if (!s.isWritable()) {
QMessageBox::critical(nullptr,
tr("Critical!"),
tr("!!! Settings are not writable! Make sure you have a write access to \"%1\"")
.arg(s.fileName())
);
tr("Critical!"),
tr("!!! Settings are not writable! Make sure you have a write access to \"%1\"")
.arg(s.fileName())
);
}
loadInitial();
}
@ -162,7 +163,7 @@ void Configuration::setLocale(const QLocale &l)
bool Configuration::setLocaleByName(const QString &language)
{
const auto &allLocales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript,
QLocale::AnyCountry);
QLocale::AnyCountry);
for (auto &it : allLocales) {
if (QString::compare(it.nativeLanguageName(), language, Qt::CaseInsensitive) == 0) {
@ -216,8 +217,7 @@ void Configuration::loadNativeTheme()
{
loadBaseThemeNative();
if (windowColorIsDark())
{
if (windowColorIsDark()) {
setColor("gui.border", QColor(0, 0, 0));
setColor("gui.background", QColor(30, 30, 30));
setColor("gui.alt_background", QColor(42, 42, 42));
@ -225,9 +225,7 @@ void Configuration::loadNativeTheme()
setColor("highlight", QColor(255, 255, 255, 15));
setColor("highlightWord", QColor(20, 20, 20, 255));
setColor("highlightPC", QColor(87, 26, 7));
}
else
{
} else {
setColor("gui.border", QColor(0, 0, 0));
setColor("gui.background", QColor(255, 255, 255));
setColor("gui.alt_background", QColor(245, 250, 255));
@ -322,7 +320,7 @@ QString Configuration::getLastThemeOf(const CutterQtTheme &currQtTheme) const
void Configuration::setTheme(int theme)
{
if (theme >= kCutterQtThemesList.size() ||
theme < 0) {
theme < 0) {
theme = 0;
}
s.setValue("ColorPalette", theme);
@ -352,8 +350,8 @@ const CutterQtTheme *Configuration::getCurrentTheme()
QString Configuration::getLogoFile()
{
return windowColorIsDark()
? QString(":/img/cutter_white_plain.svg")
: QString(":/img/cutter_plain.svg");
? QString(":/img/cutter_white_plain.svg")
: QString(":/img/cutter_plain.svg");
}
/*!
@ -489,7 +487,7 @@ QStringList Configuration::getAvailableTranslations()
continue;
}
const QStringList &currTrFileNames = dir.entryList(QStringList("cutter_*.qm"), QDir::Files,
QDir::Name);
QDir::Name);
for (const auto &trFile : currTrFileNames) {
fileNamesSet << trFile;
}
@ -534,8 +532,9 @@ bool Configuration::isFirstExecution()
QStringList Configuration::getTranslationsDirectories() const
{
static const QString cutterTranslationPath = QCoreApplication::applicationDirPath() + QDir::separator()
+ QLatin1String("translations");
static const QString cutterTranslationPath = QCoreApplication::applicationDirPath() +
QDir::separator()
+ QLatin1String("translations");
return {
cutterTranslationPath,

View File

@ -36,8 +36,10 @@ void AsmOptionsWidget::updateAsmOptionsFromVars()
qhelpers::setCheckedWithoutSignals(ui->pseudoCheckBox, Config()->getConfigBool("asm.pseudo"));
qhelpers::setCheckedWithoutSignals(ui->offsetCheckBox, Config()->getConfigBool("asm.offset"));
qhelpers::setCheckedWithoutSignals(ui->xrefCheckBox, Config()->getConfigBool("asm.xrefs"));
qhelpers::setCheckedWithoutSignals(ui->indentCheckBox, Config()->getConfigBool("asm.indent"));
qhelpers::setCheckedWithoutSignals(ui->describeCheckBox, Config()->getConfigBool("asm.describe"));
qhelpers::setCheckedWithoutSignals(ui->stackpointerCheckBox, Config()->getConfigBool("asm.stackptr"));
qhelpers::setCheckedWithoutSignals(ui->stackpointerCheckBox,
Config()->getConfigBool("asm.stackptr"));
qhelpers::setCheckedWithoutSignals(ui->slowCheckBox, Config()->getConfigBool("asm.slow"));
qhelpers::setCheckedWithoutSignals(ui->linesCheckBox, Config()->getConfigBool("asm.lines"));
qhelpers::setCheckedWithoutSignals(ui->fcnlinesCheckBox, Config()->getConfigBool("asm.lines.fcn"));
@ -98,7 +100,8 @@ void AsmOptionsWidget::updateAsmOptionsFromVars()
bool varsubEnabled = Config()->getConfigBool("asm.var.sub");
qhelpers::setCheckedWithoutSignals(ui->varsubCheckBox, varsubEnabled);
qhelpers::setCheckedWithoutSignals(ui->varsubOnlyCheckBox, Config()->getConfigBool("asm.var.subonly"));
qhelpers::setCheckedWithoutSignals(ui->varsubOnlyCheckBox,
Config()->getConfigBool("asm.var.subonly"));
ui->varsubOnlyCheckBox->setEnabled(varsubEnabled);
}
@ -141,6 +144,12 @@ void AsmOptionsWidget::on_xrefCheckBox_toggled(bool checked)
triggerAsmOptionsChanged();
}
void AsmOptionsWidget::on_indentCheckBox_toggled(bool checked)
{
Config()->setConfig("asm.indent", checked);
triggerAsmOptionsChanged();
}
void AsmOptionsWidget::on_describeCheckBox_toggled(bool checked)
{
Config()->setConfig("asm.describe", checked);
@ -239,7 +248,7 @@ void AsmOptionsWidget::on_nbytesSpinBox_valueChanged(int value)
void AsmOptionsWidget::on_syntaxComboBox_currentIndexChanged(int index)
{
Config()->setConfig("asm.syntax",
ui->syntaxComboBox->itemData(index).toString().toUtf8().constData());
ui->syntaxComboBox->itemData(index).toString().toUtf8().constData());
triggerAsmOptionsChanged();
}

View File

@ -36,6 +36,7 @@ private slots:
void on_pseudoCheckBox_toggled(bool checked);
void on_offsetCheckBox_toggled(bool checked);
void on_xrefCheckBox_toggled(bool checked);
void on_indentCheckBox_toggled(bool checked);
void on_describeCheckBox_toggled(bool checked);
void on_stackpointerCheckBox_toggled(bool checked);
void on_slowCheckBox_toggled(bool checked);

View File

@ -52,6 +52,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="indentCheckBox">
<property name="text">
<string>Indent disassembly based on reflines depth (asm.indent)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="describeCheckBox">
<property name="text">