From 45dea54e3c2cacbd887ce4e0a006d92afd740e53 Mon Sep 17 00:00:00 2001 From: Tobias Patzl Date: Mon, 25 May 2015 15:23:14 +0200 Subject: [PATCH] Add setting to disable mousewheel tab switching. See #374. --- doc/help/settings.asciidoc | 12 ++++++++++++ qutebrowser/config/configdata.py | 4 ++++ qutebrowser/mainwindow/tabwidget.py | 11 +++++++++++ 3 files changed, 27 insertions(+) diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc index 46539c3b7..d3c571aa3 100644 --- a/doc/help/settings.asciidoc +++ b/doc/help/settings.asciidoc @@ -111,6 +111,7 @@ |<>|Spacing between tab edge and indicator. |<>|Whether to open windows instead of tabs. |<>|The format to use for the tab title. The following placeholders are defined: +|<>|Switch between tabs using the mouse wheel. |============== .Quick reference for section ``storage'' @@ -1031,6 +1032,17 @@ The format to use for the tab title. The following placeholders are defined: Default: +pass:[{index}: {title}]+ +[[tabs-mousewheel-tab-switching]] +=== mousewheel-tab-switching +Switch between tabs using the mouse wheel. + +Valid values: + + * +true+ + * +false+ + +Default: +pass:[true]+ + == storage Settings related to cache and storage. diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index cb3a47be7..02b8c6008 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -522,6 +522,10 @@ def data(readonly=False): "* `{index}`: The index of this tab.\n" "* `{id}`: The internal tab ID of this tab."), + ('mousewheel-tab-switching', + SettingValue(typ.Bool(), 'true'), + "Switch between tabs using the mouse wheel."), + readonly=readonly )), diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index df44ebbba..1ad97370e 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -480,6 +480,17 @@ 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.""" + if config.get('tabs', 'mousewheel-tab-switching'): + super().wheelEvent(event) + 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) + class TabBarStyle(QCommonStyle):