From 49b27ba241aab54c43143f52615fd3da3ab5d309 Mon Sep 17 00:00:00 2001 From: Philip Nelson Date: Thu, 7 Feb 2019 17:55:24 -0500 Subject: [PATCH] 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 --- src/common/Configuration.cpp | 31 ++++++++++---------- src/dialogs/preferences/AsmOptionsWidget.cpp | 15 ++++++++-- src/dialogs/preferences/AsmOptionsWidget.h | 1 + src/dialogs/preferences/AsmOptionsWidget.ui | 7 +++++ 4 files changed, 35 insertions(+), 19 deletions(-) diff --git a/src/common/Configuration.cpp b/src/common/Configuration.cpp index 315ba9df..cc4e2a19 100644 --- a/src/common/Configuration.cpp +++ b/src/common/Configuration.cpp @@ -24,6 +24,7 @@ static const QHash 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, diff --git a/src/dialogs/preferences/AsmOptionsWidget.cpp b/src/dialogs/preferences/AsmOptionsWidget.cpp index 7c3db403..55be318a 100644 --- a/src/dialogs/preferences/AsmOptionsWidget.cpp +++ b/src/dialogs/preferences/AsmOptionsWidget.cpp @@ -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(); } diff --git a/src/dialogs/preferences/AsmOptionsWidget.h b/src/dialogs/preferences/AsmOptionsWidget.h index 807bd1b1..26d396cd 100644 --- a/src/dialogs/preferences/AsmOptionsWidget.h +++ b/src/dialogs/preferences/AsmOptionsWidget.h @@ -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); diff --git a/src/dialogs/preferences/AsmOptionsWidget.ui b/src/dialogs/preferences/AsmOptionsWidget.ui index 5795edff..9a02b35b 100644 --- a/src/dialogs/preferences/AsmOptionsWidget.ui +++ b/src/dialogs/preferences/AsmOptionsWidget.ui @@ -52,6 +52,13 @@ + + + + Indent disassembly based on reflines depth (asm.indent) + + +