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; 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() bool Configuration::getGraphBlockEntryOffset()
{ {
return s.value("graphBlockEntryOffset", true).value<bool>(); return s.value("graphBlockEntryOffset", true).value<bool>();

View File

@ -201,6 +201,9 @@ public:
void setOutputRedirectionEnabled(bool enabled); void setOutputRedirectionEnabled(bool enabled);
bool getOutputRedirectionEnabled() const; bool getOutputRedirectionEnabled() const;
void setPreviewValue(bool checked);
bool getPreviewValue() const;
/** /**
* @brief Recently opened binaries, as shown in NewFileDialog. * @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->setValue(Config()->getConfigInt("asm.tabs.off"));
ui->asmTabsOffSpinBox->blockSignals(false); ui->asmTabsOffSpinBox->blockSignals(false);
ui->previewCheckBox->blockSignals(true);
ui->previewCheckBox->setChecked(Config()->getPreviewValue());
ui->previewCheckBox->blockSignals(false);
QList<ConfigCheckbox>::iterator confCheckbox; QList<ConfigCheckbox>::iterator confCheckbox;
// Set the value for each checkbox in "checkboxes" as it exists in the configuration // 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(); triggerAsmOptionsChanged();
} }
void AsmOptionsWidget::on_previewCheckBox_toggled( bool checked )
{
Config()->setPreviewValue(checked);
triggerAsmOptionsChanged();
}
void AsmOptionsWidget::on_buttonBox_clicked(QAbstractButton *button) void AsmOptionsWidget::on_buttonBox_clicked(QAbstractButton *button)
{ {
switch (ui->buttonBox->buttonRole(button)) { switch (ui->buttonBox->buttonRole(button)) {

View File

@ -48,6 +48,7 @@ private slots:
void on_bytesCheckBox_toggled(bool checked); void on_bytesCheckBox_toggled(bool checked);
void on_varsubCheckBox_toggled(bool checked); void on_varsubCheckBox_toggled(bool checked);
void on_previewCheckBox_toggled(bool checked);
void on_buttonBox_clicked(QAbstractButton *button); void on_buttonBox_clicked(QAbstractButton *button);

View File

@ -48,8 +48,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>583</width> <width>582</width>
<height>668</height> <height>766</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
@ -65,10 +65,34 @@
<string>Disassembly</string> <string>Disassembly</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="11" column="1"> <item row="12" column="2">
<widget class="QCheckBox" name="bytesCheckBox"> <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"> <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> </property>
</widget> </widget>
</item> </item>
@ -82,66 +106,10 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="16" column="2"> <item row="8" column="2">
<widget class="QSpinBox" name="asmTabsOffSpinBox"> <widget class="QCheckBox" name="relOffFlagsCheckBox">
<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">
<property name="text"> <property name="text">
<string>Show Disassembly as:</string> <string>Flags (asm.reloff.flags)</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>
</property> </property>
</widget> </widget>
</item> </item>
@ -171,7 +139,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="16" column="1"> <item row="17" column="1">
<widget class="QLabel" name="asmTabsOffLabel"> <widget class="QLabel" name="asmTabsOffLabel">
<property name="text"> <property name="text">
<string>Tabs before assembly (asm.tabs.off):</string> <string>Tabs before assembly (asm.tabs.off):</string>
@ -181,13 +149,40 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="2"> <item row="12" column="1">
<widget class="QComboBox" name="syntaxComboBox"/> <widget class="QLabel" name="nbytesLabel">
</item> <property name="enabled">
<item row="14" column="1" colspan="2"> <bool>true</bool>
<widget class="QCheckBox" name="bblineCheckBox"> </property>
<property name="text"> <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> </property>
</widget> </widget>
</item> </item>
@ -210,44 +205,10 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="18" column="1" colspan="2"> <item row="14" column="1" colspan="2">
<widget class="QCheckBox" name="lbytesCheckBox"> <widget class="QCheckBox" name="bblineCheckBox">
<property name="text"> <property name="text">
<string>Align bytes to the left (asm.lbytes)</string> <string>Show empty line after every basic block (asm.bb.line)</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>
</property> </property>
</widget> </widget>
</item> </item>
@ -269,10 +230,56 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="8" column="2"> <item row="4" column="2">
<widget class="QCheckBox" name="relOffFlagsCheckBox"> <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"> <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> </property>
</widget> </widget>
</item> </item>
@ -408,8 +415,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>581</width> <width>454</width>
<height>302</height> <height>286</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_6"> <layout class="QVBoxLayout" name="verticalLayout_6">

View File

@ -654,7 +654,9 @@ bool DisassemblyWidget::eventFilter(QObject *obj, QEvent *event)
jumpToOffsetUnderCursor(cursor); jumpToOffsetUnderCursor(cursor);
return true; 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); QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event);
auto cursorForWord = mDisasTextEdit->cursorForPosition(helpEvent->pos()); auto cursorForWord = mDisasTextEdit->cursorForPosition(helpEvent->pos());