Add option to disable the preview when hovering over the assembly (#2795)

This commit is contained in:
Petros S 2021-10-09 19:17:52 +03:00 committed by GitHub
parent 311cd0307e
commit 552cd6dff6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 147 additions and 114 deletions

View File

@ -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<bool>();

View File

@ -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.
*/

View File

@ -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<ConfigCheckbox>::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)) {

View File

@ -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);

View File

@ -48,8 +48,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>583</width>
<height>668</height>
<width>582</width>
<height>766</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
@ -65,10 +65,34 @@
<string>Disassembly</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="11" column="1">
<widget class="QCheckBox" name="bytesCheckBox">
<item row="12" column="2">
<widget class="QSpinBox" name="nbytesSpinBox">
<property name="enabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="17" column="2">
<widget class="QSpinBox" name="asmTabsOffSpinBox">
<property name="maximum">
<number>100</number>
</property>
<property name="singleStep">
<number>5</number>
</property>
</widget>
</item>
<item row="19" column="1" colspan="2">
<widget class="QCheckBox" name="lbytesCheckBox">
<property name="text">
<string>Display the bytes of each instruction (asm.bytes)</string>
<string>Align bytes to the left (asm.lbytes)</string>
</property>
</widget>
</item>
<item row="15" column="1">
<widget class="QCheckBox" name="previewCheckBox">
<property name="text">
<string>Show preview when hovering:</string>
</property>
</widget>
</item>
@ -82,66 +106,10 @@
</property>
</widget>
</item>
<item row="16" column="2">
<widget class="QSpinBox" name="asmTabsOffSpinBox">
<property name="maximum">
<number>100</number>
</property>
<property name="singleStep">
<number>5</number>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="label">
<item row="8" column="2">
<widget class="QCheckBox" name="relOffFlagsCheckBox">
<property name="text">
<string>Show Disassembly as:</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="QLabel" name="nbytesLabel">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Number of bytes to display (asm.nbytes):</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="17" column="1" colspan="2">
<widget class="QCheckBox" name="indentCheckBox">
<property name="text">
<string>Indent disassembly based on reflines depth (asm.indent)</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item row="12" column="2">
<widget class="QSpinBox" name="nbytesSpinBox">
<property name="enabled">
<bool>true</bool>
<string>Flags (asm.reloff.flags)</string>
</property>
</widget>
</item>
@ -171,7 +139,7 @@
</property>
</widget>
</item>
<item row="16" column="1">
<item row="17" column="1">
<widget class="QLabel" name="asmTabsOffLabel">
<property name="text">
<string>Tabs before assembly (asm.tabs.off):</string>
@ -181,13 +149,40 @@
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QComboBox" name="syntaxComboBox"/>
</item>
<item row="14" column="1" colspan="2">
<widget class="QCheckBox" name="bblineCheckBox">
<item row="12" column="1">
<widget class="QLabel" name="nbytesLabel">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Show empty line after every basic block (asm.bb.line)</string>
<string>Number of bytes to display (asm.nbytes):</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="20" column="1" colspan="2">
<widget class="QCheckBox" name="bytespaceCheckBox">
<property name="text">
<string>Separate bytes with whitespace (asm.bytes.space)</string>
</property>
</widget>
</item>
<item row="16" column="2">
<widget class="QSpinBox" name="asmTabsSpinBox">
<property name="maximum">
<number>100</number>
</property>
<property name="singleStep">
<number>5</number>
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="QCheckBox" name="bytesCheckBox">
<property name="text">
<string>Display the bytes of each instruction (asm.bytes)</string>
</property>
</widget>
</item>
@ -210,44 +205,10 @@
</item>
</widget>
</item>
<item row="18" column="1" colspan="2">
<widget class="QCheckBox" name="lbytesCheckBox">
<item row="14" column="1" colspan="2">
<widget class="QCheckBox" name="bblineCheckBox">
<property name="text">
<string>Align bytes to the left (asm.lbytes)</string>
</property>
</widget>
</item>
<item row="19" column="1" colspan="2">
<widget class="QCheckBox" name="bytespaceCheckBox">
<property name="text">
<string>Separate bytes with whitespace (asm.bytes.space)</string>
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QCheckBox" name="realnameCheckBox">
<property name="text">
<string>Display flags' real name (asm.flags.real)</string>
</property>
</widget>
</item>
<item row="15" column="1">
<widget class="QLabel" name="asmTabsLabel">
<property name="text">
<string>Tabs in assembly (asm.tabs):</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="15" column="2">
<widget class="QSpinBox" name="asmTabsSpinBox">
<property name="maximum">
<number>100</number>
</property>
<property name="singleStep">
<number>5</number>
<string>Show empty line after every basic block (asm.bb.line)</string>
</property>
</widget>
</item>
@ -269,10 +230,56 @@
</item>
</layout>
</item>
<item row="8" column="2">
<widget class="QCheckBox" name="relOffFlagsCheckBox">
<item row="4" column="2">
<widget class="QComboBox" name="syntaxComboBox"/>
</item>
<item row="0" column="1" colspan="2">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="1">
<widget class="QLabel" name="label">
<property name="text">
<string>Flags (asm.reloff.flags)</string>
<string>Show Disassembly as:</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="16" column="1">
<widget class="QLabel" name="asmTabsLabel">
<property name="text">
<string>Tabs in assembly (asm.tabs):</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="18" column="1" colspan="2">
<widget class="QCheckBox" name="indentCheckBox">
<property name="text">
<string>Indent disassembly based on reflines depth (asm.indent)</string>
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QCheckBox" name="realnameCheckBox">
<property name="text">
<string>Display flags' real name (asm.flags.real)</string>
</property>
</widget>
</item>
@ -408,8 +415,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>581</width>
<height>302</height>
<width>454</width>
<height>286</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">

View File

@ -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<QHelpEvent *>(event);
auto cursorForWord = mDisasTextEdit->cursorForPosition(helpEvent->pos());