1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

VerticalTabs: Fix tab switching with mouse wheel

Respect the "Always switch between tabs with mouse wheel" option.

BUG: 394066
FIXED-IN: 24.12.0

Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
This commit is contained in:
Juraj Oravec 2024-08-10 12:22:05 +02:00
parent b1be34cd23
commit ccce0818cc
2 changed files with 15 additions and 1 deletions

View File

@ -23,10 +23,12 @@
#include "webtab.h" #include "webtab.h"
#include "tabcontextmenu.h" #include "tabcontextmenu.h"
#include "browserwindow.h" #include "browserwindow.h"
#include "qzsettings.h"
#include <QTimer> #include <QTimer>
#include <QToolTip> #include <QToolTip>
#include <QHoverEvent> #include <QHoverEvent>
#include <QScrollBar>
TabTreeView::TabTreeView(BrowserWindow *window, QWidget *parent) TabTreeView::TabTreeView(BrowserWindow *window, QWidget *parent)
: QTreeView(parent) : QTreeView(parent)
@ -161,6 +163,10 @@ void TabTreeView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bot
if (roles.size() == 1 && roles.at(0) == TabModel::CurrentTabRole && topLeft.data(TabModel::CurrentTabRole).toBool()) { if (roles.size() == 1 && roles.at(0) == TabModel::CurrentTabRole && topLeft.data(TabModel::CurrentTabRole).toBool()) {
setCurrentIndex(topLeft); setCurrentIndex(topLeft);
if (qzSettings->alwaysSwitchTabsWithWheel && verticalScrollBar()->isVisible()) {
scrollTo(indexAbove(topLeft));
}
} }
} }
@ -335,6 +341,13 @@ bool TabTreeView::viewportEvent(QEvent *event)
break; break;
} }
case QEvent::Wheel: {
if (qzSettings->alwaysSwitchTabsWithWheel) {
event->ignore();
return false;
}
}
default: default:
break; break;
} }

View File

@ -26,6 +26,7 @@
#include "toolbutton.h" #include "toolbutton.h"
#include "tabtreemodel.h" #include "tabtreemodel.h"
#include "browserwindow.h" #include "browserwindow.h"
#include "qzsettings.h"
#include <QListView> #include <QListView>
#include <QScrollBar> #include <QScrollBar>
@ -159,7 +160,7 @@ WebTab *VerticalTabsWidget::previousTab() const
void VerticalTabsWidget::wheelEvent(QWheelEvent *event) void VerticalTabsWidget::wheelEvent(QWheelEvent *event)
{ {
if (m_normalView->verticalScrollBar()->isVisible()) { if (!qzSettings->alwaysSwitchTabsWithWheel && m_normalView->verticalScrollBar()->isVisible()) {
return; return;
} }