1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

VerticalTabs: Switch tabs with mouse wheel

But only when there is no scrollbar in normal tabs view.
This commit is contained in:
David Rosca 2018-02-04 11:24:21 +01:00
parent bbbe136346
commit 62264501e2
No known key found for this signature in database
GPG Key ID: EBC3FC294452C6D8
2 changed files with 34 additions and 1 deletions

View File

@ -27,8 +27,10 @@
#include "tabbedwebview.h"
#include "browserwindow.h"
#include <QVBoxLayout>
#include <QListView>
#include <QScrollBar>
#include <QVBoxLayout>
#include <QWheelEvent>
VerticalTabsWidget::VerticalTabsWidget(BrowserWindow *window)
: QWidget()
@ -146,3 +148,29 @@ WebTab *VerticalTabsWidget::previousTab() const
}
return previous.data(TabModel::WebTabRole).value<WebTab*>();
}
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();
}

View File

@ -19,6 +19,8 @@
#include <QWidget>
#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;
};