From db682f6ef955724b0d7f56e1aaabca27e81c098a Mon Sep 17 00:00:00 2001 From: Adam Zambrzycki Date: Tue, 17 Jul 2018 09:25:17 +0200 Subject: [PATCH] Added options to remove excessive spacing (#577) * Add option to configure asm.tabs.off * Add option to configure asm.cmt.col --- src/Cutter.cpp | 2 - src/dialogs/preferences/AsmOptionsWidget.cpp | 25 +++++++++++- src/dialogs/preferences/AsmOptionsWidget.h | 2 + src/dialogs/preferences/AsmOptionsWidget.ui | 42 ++++++++++++++++++++ src/utils/Configuration.cpp | 4 +- 5 files changed, 71 insertions(+), 4 deletions(-) diff --git a/src/Cutter.cpp b/src/Cutter.cpp index ea5e0102..130f9ada 100644 --- a/src/Cutter.cpp +++ b/src/Cutter.cpp @@ -824,11 +824,9 @@ void CutterCore::setSettings() setConfig("scr.interactive", false); setConfig("hex.pairs", false); - setConfig("asm.cmt.col", 70); setConfig("asm.xrefs", false); setConfig("asm.tabs.once", true); - setConfig("asm.tabs.off", 5); setConfig("asm.flags.middle", 2); setConfig("anal.hasnext", false); diff --git a/src/dialogs/preferences/AsmOptionsWidget.cpp b/src/dialogs/preferences/AsmOptionsWidget.cpp index 596d5ba2..65dad18c 100644 --- a/src/dialogs/preferences/AsmOptionsWidget.cpp +++ b/src/dialogs/preferences/AsmOptionsWidget.cpp @@ -40,10 +40,16 @@ void AsmOptionsWidget::updateAsmOptionsFromVars() qhelpers::setCheckedWithoutSignals(ui->fcnlinesCheckBox, Config()->getConfigBool("asm.lines.fcn")); qhelpers::setCheckedWithoutSignals(ui->flgoffCheckBox, Config()->getConfigBool("asm.flags.offset")); qhelpers::setCheckedWithoutSignals(ui->emuCheckBox, Config()->getConfigBool("asm.emu")); - qhelpers::setCheckedWithoutSignals(ui->cmtrightCheckBox, Config()->getConfigBool("asm.cmt.right")); qhelpers::setCheckedWithoutSignals(ui->varsumCheckBox, Config()->getConfigBool("asm.var.summary")); qhelpers::setCheckedWithoutSignals(ui->sizeCheckBox, Config()->getConfigBool("asm.size")); + bool cmtRightEnabled = Config()->getConfigBool("asm.cmt.right"); + qhelpers::setCheckedWithoutSignals(ui->cmtrightCheckBox, cmtRightEnabled); + ui->cmtcolSpinBox->blockSignals(true); + ui->cmtcolSpinBox->setValue(Config()->getConfigInt("asm.cmt.col")); + ui->cmtcolSpinBox->blockSignals(false); + ui->cmtcolSpinBox->setEnabled(cmtRightEnabled); + bool bytesEnabled = Config()->getConfigBool("asm.bytes"); qhelpers::setCheckedWithoutSignals(ui->bytesCheckBox, bytesEnabled); qhelpers::setCheckedWithoutSignals(ui->bytespaceCheckBox, Config()->getConfigBool("asm.bytespace")); @@ -81,6 +87,10 @@ void AsmOptionsWidget::updateAsmOptionsFromVars() ui->asmTabsSpinBox->setValue(Config()->getConfigInt("asm.tabs")); ui->asmTabsSpinBox->blockSignals(false); + ui->asmTabsOffSpinBox->blockSignals(true); + ui->asmTabsOffSpinBox->setValue(Config()->getConfigInt("asm.tabs.off")); + ui->asmTabsOffSpinBox->blockSignals(false); + qhelpers::setCheckedWithoutSignals(ui->bblineCheckBox, Config()->getConfigBool("asm.bbline")); bool varsubEnabled = Config()->getConfigBool("asm.varsub"); @@ -167,6 +177,13 @@ void AsmOptionsWidget::on_emuCheckBox_toggled(bool checked) void AsmOptionsWidget::on_cmtrightCheckBox_toggled(bool checked) { Config()->setConfig("asm.cmt.right", checked); + ui->cmtcolSpinBox->setEnabled(checked); + triggerAsmOptionsChanged(); +} + +void AsmOptionsWidget::on_cmtcolSpinBox_valueChanged(int value) +{ + Config()->setConfig("asm.cmt.col", value); triggerAsmOptionsChanged(); } @@ -254,6 +271,12 @@ void AsmOptionsWidget::on_asmTabsSpinBox_valueChanged(int value) triggerAsmOptionsChanged(); } +void AsmOptionsWidget::on_asmTabsOffSpinBox_valueChanged(int value) +{ + Config()->setConfig("asm.tabs.off", value); + triggerAsmOptionsChanged(); +} + void AsmOptionsWidget::on_bblineCheckBox_toggled(bool checked) { Config()->setConfig("asm.bbline", checked); diff --git a/src/dialogs/preferences/AsmOptionsWidget.h b/src/dialogs/preferences/AsmOptionsWidget.h index b4be97ba..2a2d6937 100644 --- a/src/dialogs/preferences/AsmOptionsWidget.h +++ b/src/dialogs/preferences/AsmOptionsWidget.h @@ -43,6 +43,7 @@ private slots: void on_flgoffCheckBox_toggled(bool checked); void on_emuCheckBox_toggled(bool checked); void on_cmtrightCheckBox_toggled(bool checked); + void on_cmtcolSpinBox_valueChanged(int value); void on_varsumCheckBox_toggled(bool checked); void on_bytesCheckBox_toggled(bool checked); void on_sizeCheckBox_toggled(bool checked); @@ -51,6 +52,7 @@ private slots: void on_syntaxComboBox_currentIndexChanged(int index); void on_caseComboBox_currentIndexChanged(int index); void on_asmTabsSpinBox_valueChanged(int value); + void on_asmTabsOffSpinBox_valueChanged(int value); void on_nbytesSpinBox_valueChanged(int value); void on_bblineCheckBox_toggled(bool checked); void on_varsubCheckBox_toggled(bool checked); diff --git a/src/dialogs/preferences/AsmOptionsWidget.ui b/src/dialogs/preferences/AsmOptionsWidget.ui index 216139fe..0bcdfc7a 100644 --- a/src/dialogs/preferences/AsmOptionsWidget.ui +++ b/src/dialogs/preferences/AsmOptionsWidget.ui @@ -127,6 +127,27 @@ + + + + + + Tabs before assembly (asm.tabs.off): + + + + + + + 100 + + + 5 + + + + + @@ -141,6 +162,27 @@ + + + + + + Column to align comments (asm.cmt.col): + + + + + + + 100 + + + 5 + + + + + diff --git a/src/utils/Configuration.cpp b/src/utils/Configuration.cpp index b7759d7e..91bcc128 100644 --- a/src/utils/Configuration.cpp +++ b/src/utils/Configuration.cpp @@ -22,6 +22,7 @@ static const QHash asmOptions = { { "asm.flags.offset", false }, { "asm.emu", false }, { "asm.cmt.right", true }, + { "asm.cmt.col", 70 }, { "asm.var.summary", false }, { "asm.bytes", false }, { "asm.size", false }, @@ -34,7 +35,8 @@ static const QHash asmOptions = { { "asm.capitalize", false }, { "asm.var.sub", true }, { "asm.var.subonly", true }, - { "asm.tabs", 5 } + { "asm.tabs", 5 }, + { "asm.tabs.off", 5 } };