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:
parent
bbbe136346
commit
62264501e2
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user