From 736d3e1f1dac61b532ff3a76bbf2438b5f1f532e Mon Sep 17 00:00:00 2001 From: adikso Date: Sun, 14 Jul 2019 02:52:43 +0200 Subject: [PATCH] Add scrolling to DisassemblyWidget left panel --- src/widgets/DisassemblyWidget.cpp | 11 +++++++++-- src/widgets/DisassemblyWidget.h | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/widgets/DisassemblyWidget.cpp b/src/widgets/DisassemblyWidget.cpp index 58982f15..72ae073a 100644 --- a/src/widgets/DisassemblyWidget.cpp +++ b/src/widgets/DisassemblyWidget.cpp @@ -79,7 +79,7 @@ DisassemblyWidget::DisassemblyWidget(MainWindow *main, QAction *action) mDisasScrollArea->setFocusPolicy(Qt::ClickFocus); setFocusPolicy(Qt::ClickFocus); - + // Behave like all widgets: highlight on focus and hover connect(qApp, &QApplication::focusChanged, this, [this](QWidget* , QWidget* now) { QColor borderColor = this == now @@ -217,7 +217,7 @@ DisassemblyWidget::DisassemblyWidget(MainWindow *main, QAction *action) ADD_ACTION(QKeySequence::MoveToPreviousPage, Qt::WidgetWithChildrenShortcut, [this]() { moveCursorRelative(true, true); }) - + // Plus sign in num-bar considered "Qt::Key_Equal" ADD_ACTION(QKeySequence(Qt::CTRL + Qt::Key_Equal), Qt::WidgetWithChildrenShortcut, &DisassemblyWidget::zoomIn) // Plus sign in numpad @@ -813,6 +813,13 @@ DisassemblyLeftPanel::DisassemblyLeftPanel(DisassemblyWidget *disas) this->disas = disas; } +void DisassemblyLeftPanel::wheelEvent(QWheelEvent *event) { + int count = -(event->angleDelta() / 15).y(); + count -= (count > 0 ? 5 : -5); + + this->disas->scrollInstructions(count); +} + void DisassemblyLeftPanel::paintEvent(QPaintEvent *event) { Q_UNUSED(event) diff --git a/src/widgets/DisassemblyWidget.h b/src/widgets/DisassemblyWidget.h index b25d565c..3165203a 100644 --- a/src/widgets/DisassemblyWidget.h +++ b/src/widgets/DisassemblyWidget.h @@ -32,6 +32,7 @@ public slots: void showDisasContextMenu(const QPoint &pt); void fontsUpdatedSlot(); void colorsUpdatedSlot(); + void scrollInstructions(int count); void seekPrev(); void setPreviewMode(bool previewMode); QFontMetrics getFontMetrics(); @@ -41,7 +42,6 @@ protected slots: void on_seekChanged(RVA offset); void refreshDisasm(RVA offset = RVA_INVALID); - void scrollInstructions(int count); bool updateMaxLines(); void cursorPositionChanged(); @@ -143,6 +143,7 @@ class DisassemblyLeftPanel: public QFrame public: DisassemblyLeftPanel(DisassemblyWidget *disas); void paintEvent(QPaintEvent *event) override; + void wheelEvent(QWheelEvent *event) override; private: DisassemblyWidget *disas;