diff --git a/src/plugins/VerticalTabs/verticaltabswidget.cpp b/src/plugins/VerticalTabs/verticaltabswidget.cpp index be57da3d7..0938d45e1 100644 --- a/src/plugins/VerticalTabs/verticaltabswidget.cpp +++ b/src/plugins/VerticalTabs/verticaltabswidget.cpp @@ -27,8 +27,10 @@ #include "tabbedwebview.h" #include "browserwindow.h" -#include #include +#include +#include +#include VerticalTabsWidget::VerticalTabsWidget(BrowserWindow *window) : QWidget() @@ -146,3 +148,29 @@ WebTab *VerticalTabsWidget::previousTab() const } return previous.data(TabModel::WebTabRole).value(); } + +void VerticalTabsWidget::wheelEvent(QWheelEvent *event) +{ + if (m_normalView->verticalScrollBar()->isVisible()) { + return; + } + + m_wheelHelper.processEvent(event); + while (WheelHelper::Direction direction = m_wheelHelper.takeDirection()) { + switch (direction) { + case WheelHelper::WheelUp: + case WheelHelper::WheelLeft: + switchToPreviousTab(); + break; + + case WheelHelper::WheelDown: + case WheelHelper::WheelRight: + switchToNextTab(); + break; + + default: + break; + } + } + event->accept(); +} diff --git a/src/plugins/VerticalTabs/verticaltabswidget.h b/src/plugins/VerticalTabs/verticaltabswidget.h index bfa215d0a..dad653e28 100644 --- a/src/plugins/VerticalTabs/verticaltabswidget.h +++ b/src/plugins/VerticalTabs/verticaltabswidget.h @@ -19,6 +19,8 @@ #include +#include "wheelhelper.h" + #include "verticaltabsplugin.h" class WebTab; @@ -40,6 +42,8 @@ public: void switchToPreviousTab(); private: + void wheelEvent(QWheelEvent *event) override; + WebTab *nextTab() const; WebTab *previousTab() const; @@ -47,4 +51,5 @@ private: TabListView *m_pinnedView; TabTreeView *m_normalView; TabTreeModel *m_treeModel = nullptr; + WheelHelper m_wheelHelper; };