From 742690afd0fe95c8ffe448e4b613830c2e11d0f6 Mon Sep 17 00:00:00 2001 From: Abdel-Rahman A Date: Sat, 10 Mar 2018 08:26:58 +0200 Subject: [PATCH] Add asm.size option in preferences (#374) --- src/Cutter.cpp | 2 ++ src/dialogs/preferences/AsmOptionsWidget.cpp | 7 +++++++ src/dialogs/preferences/AsmOptionsWidget.h | 1 + src/dialogs/preferences/AsmOptionsWidget.ui | 7 +++++++ src/utils/Configuration.h | 3 +++ 5 files changed, 20 insertions(+) diff --git a/src/Cutter.cpp b/src/Cutter.cpp index c821ffb3..5b66eca8 100644 --- a/src/Cutter.cpp +++ b/src/Cutter.cpp @@ -536,6 +536,7 @@ void CutterCore::resetDefaultAsmOptions() setConfig("asm.cmt.right", Config()->getAsmCmtRight()); setConfig("asm.varsum", Config()->getAsmVarSum()); setConfig("asm.bytes", Config()->getAsmBytes()); + setConfig("asm.size", Config()->getAsmSize()); setConfig("asm.bytespace", Config()->getAsmBytespace()); setConfig("asm.lbytes", Config()->getAsmLBytes()); setConfig("asm.nbytes", Config()->getAsmNBytes()); @@ -561,6 +562,7 @@ void CutterCore::saveDefaultAsmOptions() Config()->setAsmCmtRight(getConfigb("asm.cmt.right")); Config()->setAsmVarSum(getConfigb("asm.varsum")); Config()->setAsmBytes(getConfigb("asm.bytes")); + Config()->setAsmSize(getConfigb("asm.size")); Config()->setAsmBytespace(getConfigb("asm.bytespace")); Config()->setAsmLBytes(getConfigb("asm.lbytes")); Config()->setAsmNBytes(getConfigi("asm.nbytes")); diff --git a/src/dialogs/preferences/AsmOptionsWidget.cpp b/src/dialogs/preferences/AsmOptionsWidget.cpp index 50ba5392..7cfa992d 100644 --- a/src/dialogs/preferences/AsmOptionsWidget.cpp +++ b/src/dialogs/preferences/AsmOptionsWidget.cpp @@ -46,6 +46,7 @@ void AsmOptionsWidget::updateAsmOptionsFromVars() qhelpers::setCheckedWithoutSignals(ui->emuCheckBox, Core()->getConfigb("asm.emu")); qhelpers::setCheckedWithoutSignals(ui->cmtrightCheckBox, Core()->getConfigb("asm.cmtright")); qhelpers::setCheckedWithoutSignals(ui->varsumCheckBox, Core()->getConfigb("asm.varsum")); + qhelpers::setCheckedWithoutSignals(ui->sizeCheckBox, Core()->getConfigb("asm.size")); bool bytesEnabled = Core()->getConfigb("asm.bytes"); qhelpers::setCheckedWithoutSignals(ui->bytesCheckBox, bytesEnabled); @@ -196,6 +197,12 @@ void AsmOptionsWidget::on_bytesCheckBox_toggled(bool checked) triggerAsmOptionsChanged(); } +void AsmOptionsWidget::on_sizeCheckBox_toggled(bool checked) +{ + Core()->setConfig("asm.size", checked); + triggerAsmOptionsChanged(); +} + void AsmOptionsWidget::on_bytespaceCheckBox_toggled(bool checked) { Core()->setConfig("asm.bytespace", checked); diff --git a/src/dialogs/preferences/AsmOptionsWidget.h b/src/dialogs/preferences/AsmOptionsWidget.h index 4dbf294a..754f4940 100644 --- a/src/dialogs/preferences/AsmOptionsWidget.h +++ b/src/dialogs/preferences/AsmOptionsWidget.h @@ -46,6 +46,7 @@ private slots: void on_cmtrightCheckBox_toggled(bool checked); void on_varsumCheckBox_toggled(bool checked); void on_bytesCheckBox_toggled(bool checked); + void on_sizeCheckBox_toggled(bool checked); void on_bytespaceCheckBox_toggled(bool checked); void on_lbytesCheckBox_toggled(bool checked); void on_syntaxComboBox_currentIndexChanged(int index); diff --git a/src/dialogs/preferences/AsmOptionsWidget.ui b/src/dialogs/preferences/AsmOptionsWidget.ui index f469b1f3..c24f9f2a 100644 --- a/src/dialogs/preferences/AsmOptionsWidget.ui +++ b/src/dialogs/preferences/AsmOptionsWidget.ui @@ -98,6 +98,13 @@ + + + + Show size of opcodes in disassembly (asm.size) + + + diff --git a/src/utils/Configuration.h b/src/utils/Configuration.h index 5886437a..2c264eb4 100644 --- a/src/utils/Configuration.h +++ b/src/utils/Configuration.h @@ -85,6 +85,9 @@ public: bool getAsmBytes() const { return s.value("asm.bytes", false).toBool(); } void setAsmBytes(bool v) { s.setValue("asm.bytes", v); } + bool getAsmSize() const { return s.value("asm.size", false).toBool(); } + void setAsmSize(bool v) { s.setValue("asm.size", v); } + bool getAsmBytespace() const { return s.value("asm.bytespace", false).toBool(); } void setAsmBytespace(bool v) { s.setValue("asm.bytespace", v); }