From 552cd6dff6f94b0301dd18ddfe8add33b7d75c45 Mon Sep 17 00:00:00 2001 From: Petros S Date: Sat, 9 Oct 2021 19:17:52 +0300 Subject: [PATCH] Add option to disable the preview when hovering over the assembly (#2795) --- src/common/Configuration.cpp | 10 + src/common/Configuration.h | 3 + src/dialogs/preferences/AsmOptionsWidget.cpp | 10 + src/dialogs/preferences/AsmOptionsWidget.h | 1 + src/dialogs/preferences/AsmOptionsWidget.ui | 233 ++++++++++--------- src/widgets/DisassemblyWidget.cpp | 4 +- 6 files changed, 147 insertions(+), 114 deletions(-) diff --git a/src/common/Configuration.cpp b/src/common/Configuration.cpp index 764ecdb5..3c309e83 100644 --- a/src/common/Configuration.cpp +++ b/src/common/Configuration.cpp @@ -774,6 +774,16 @@ bool Configuration::getOutputRedirectionEnabled() const return outputRedirectEnabled; } +void Configuration::setPreviewValue( bool checked ) +{ + s.setValue("asm.preview", checked); +} + +bool Configuration::getPreviewValue() const +{ + return s.value("asm.preview").toBool(); +} + bool Configuration::getGraphBlockEntryOffset() { return s.value("graphBlockEntryOffset", true).value(); diff --git a/src/common/Configuration.h b/src/common/Configuration.h index f20cbe26..73ed1045 100644 --- a/src/common/Configuration.h +++ b/src/common/Configuration.h @@ -201,6 +201,9 @@ public: void setOutputRedirectionEnabled(bool enabled); bool getOutputRedirectionEnabled() const; + void setPreviewValue(bool checked); + bool getPreviewValue() const; + /** * @brief Recently opened binaries, as shown in NewFileDialog. */ diff --git a/src/dialogs/preferences/AsmOptionsWidget.cpp b/src/dialogs/preferences/AsmOptionsWidget.cpp index 0a67daec..7004b4b4 100644 --- a/src/dialogs/preferences/AsmOptionsWidget.cpp +++ b/src/dialogs/preferences/AsmOptionsWidget.cpp @@ -134,6 +134,10 @@ void AsmOptionsWidget::updateAsmOptionsFromVars() ui->asmTabsOffSpinBox->setValue(Config()->getConfigInt("asm.tabs.off")); ui->asmTabsOffSpinBox->blockSignals(false); + ui->previewCheckBox->blockSignals(true); + ui->previewCheckBox->setChecked(Config()->getPreviewValue()); + ui->previewCheckBox->blockSignals(false); + QList::iterator confCheckbox; // Set the value for each checkbox in "checkboxes" as it exists in the configuration @@ -238,6 +242,12 @@ void AsmOptionsWidget::on_varsubCheckBox_toggled(bool checked) triggerAsmOptionsChanged(); } +void AsmOptionsWidget::on_previewCheckBox_toggled( bool checked ) +{ + Config()->setPreviewValue(checked); + triggerAsmOptionsChanged(); +} + void AsmOptionsWidget::on_buttonBox_clicked(QAbstractButton *button) { switch (ui->buttonBox->buttonRole(button)) { diff --git a/src/dialogs/preferences/AsmOptionsWidget.h b/src/dialogs/preferences/AsmOptionsWidget.h index 0a3d069c..a3ba832e 100644 --- a/src/dialogs/preferences/AsmOptionsWidget.h +++ b/src/dialogs/preferences/AsmOptionsWidget.h @@ -48,6 +48,7 @@ private slots: void on_bytesCheckBox_toggled(bool checked); void on_varsubCheckBox_toggled(bool checked); + void on_previewCheckBox_toggled(bool checked); void on_buttonBox_clicked(QAbstractButton *button); diff --git a/src/dialogs/preferences/AsmOptionsWidget.ui b/src/dialogs/preferences/AsmOptionsWidget.ui index ac629113..e96421a4 100644 --- a/src/dialogs/preferences/AsmOptionsWidget.ui +++ b/src/dialogs/preferences/AsmOptionsWidget.ui @@ -48,8 +48,8 @@ 0 0 - 583 - 668 + 582 + 766 @@ -65,10 +65,34 @@ Disassembly - - + + + + true + + + + + + + 100 + + + 5 + + + + + - Display the bytes of each instruction (asm.bytes) + Align bytes to the left (asm.lbytes) + + + + + + + Show preview when hovering: @@ -82,66 +106,10 @@ - - - - 100 - - - 5 - - - - - + + - Show Disassembly as: - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - true - - - Number of bytes to display (asm.nbytes): - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - Indent disassembly based on reflines depth (asm.indent) - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 10 - - - - - - - - true + Flags (asm.reloff.flags) @@ -171,7 +139,7 @@ - + Tabs before assembly (asm.tabs.off): @@ -181,13 +149,40 @@ - - - - - + + + + true + - Show empty line after every basic block (asm.bb.line) + Number of bytes to display (asm.nbytes): + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + Separate bytes with whitespace (asm.bytes.space) + + + + + + + 100 + + + 5 + + + + + + + Display the bytes of each instruction (asm.bytes) @@ -210,44 +205,10 @@ - - + + - Align bytes to the left (asm.lbytes) - - - - - - - Separate bytes with whitespace (asm.bytes.space) - - - - - - - Display flags' real name (asm.flags.real) - - - - - - - Tabs in assembly (asm.tabs): - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - 100 - - - 5 + Show empty line after every basic block (asm.bb.line) @@ -269,10 +230,56 @@ - - + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 10 + + + + + + - Flags (asm.reloff.flags) + Show Disassembly as: + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + Tabs in assembly (asm.tabs): + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + Indent disassembly based on reflines depth (asm.indent) + + + + + + + Display flags' real name (asm.flags.real) @@ -408,8 +415,8 @@ 0 0 - 581 - 302 + 454 + 286 diff --git a/src/widgets/DisassemblyWidget.cpp b/src/widgets/DisassemblyWidget.cpp index 32c40e69..95c47375 100644 --- a/src/widgets/DisassemblyWidget.cpp +++ b/src/widgets/DisassemblyWidget.cpp @@ -654,7 +654,9 @@ bool DisassemblyWidget::eventFilter(QObject *obj, QEvent *event) jumpToOffsetUnderCursor(cursor); return true; - } else if (event->type() == QEvent::ToolTip && obj == mDisasTextEdit->viewport()) { + } else if (Config()->getPreviewValue() + && event->type() == QEvent::ToolTip + && obj == mDisasTextEdit->viewport()) { QHelpEvent *helpEvent = static_cast(event); auto cursorForWord = mDisasTextEdit->cursorForPosition(helpEvent->pos());