From 61519e63839b81ee1532c8021709534f6f49e9f3 Mon Sep 17 00:00:00 2001 From: Tobias Patzl Date: Mon, 25 May 2015 20:21:37 +0200 Subject: [PATCH] move part of the logic to `TabbedBrowser` --- qutebrowser/mainwindow/tabbedbrowser.py | 9 +++++++++ qutebrowser/mainwindow/tabwidget.py | 14 ++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/qutebrowser/mainwindow/tabbedbrowser.py b/qutebrowser/mainwindow/tabbedbrowser.py index c465c8ca4..7b3477018 100644 --- a/qutebrowser/mainwindow/tabbedbrowser.py +++ b/qutebrowser/mainwindow/tabbedbrowser.py @@ -577,3 +577,12 @@ class TabbedBrowser(tabwidget.TabWidget): """ super().resizeEvent(e) self.resized.emit(self.geometry()) + + def wheelEvent(self, e): + """Override wheelEvent of QWidget to forward it to the focused tab. + + Args: + e: The QWheelEvent + """ + if self._now_focused is not None: + self._now_focused.wheelEvent(e) diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index 1ad97370e..bbbfdf045 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -480,16 +480,18 @@ class TabBar(QTabBar): new_idx = super().insertTab(idx, icon, '') self.set_page_title(new_idx, text) - def wheelEvent(self, event): - """Override wheelEvent to make the action configurable.""" + def wheelEvent(self, e): + """Override wheelEvent to make the action configurable. + + Args: + e: The QWheelEvent + """ if config.get('tabs', 'mousewheel-tab-switching'): - super().wheelEvent(event) + super().wheelEvent(e) else: tabbed_browser = objreg.get('tabbed-browser', scope='window', window=self._win_id) - focused_tab = tabbed_browser.currentWidget() - if focused_tab is not None: - focused_tab.wheelEvent(event) + tabbed_browser.wheelEvent(e) class TabBarStyle(QCommonStyle):