tabs: allow 'tabs.wrap' to work with scroll wheel

QTabBar doesn't wrap when switching between tabs with the scroll wheel so the
'tabs.wrap' option is only respected in the tab* commands. However, 'wheelEvent' is
already being overriden for macos so we might as well override it for all platforms and
implement wrapping there.
Fixes #8521
This commit is contained in:
alex-huff 2025-05-18 11:35:11 -05:00
parent bb7bbb6ead
commit fb77fc2657
1 changed files with 12 additions and 15 deletions

View File

@ -755,21 +755,18 @@ class TabBar(QTabBar):
e: The QWheelEvent
"""
if config.val.tabs.mousewheel_switching:
if utils.is_mac:
# WORKAROUND for this not being customizable until Qt 6:
# https://codereview.qt-project.org/c/qt/qtbase/+/327746
index = self.currentIndex()
if index == -1:
return
dx = e.angleDelta().x()
dy = e.angleDelta().y()
delta = dx if abs(dx) > abs(dy) else dy
offset = -1 if delta > 0 else 1
index += offset
if 0 <= index < self.count():
self.setCurrentIndex(index)
else:
super().wheelEvent(e)
index = self.currentIndex()
if index == -1:
return
dx = e.angleDelta().x()
dy = e.angleDelta().y()
delta = dx if abs(dx) > abs(dy) else dy
offset = -1 if delta > 0 else 1
index += offset
if config.val.tabs.wrap:
index %= self.count()
if 0 <= index < self.count():
self.setCurrentIndex(index)
else:
tabbed_browser = objreg.get('tabbed-browser', scope='window',
window=self._win_id)