Add setting to disable mousewheel tab switching.

See #374.
This commit is contained in:
Tobias Patzl 2015-05-25 15:23:14 +02:00
parent a345b02729
commit 45dea54e3c
3 changed files with 27 additions and 0 deletions

View File

@ -111,6 +111,7 @@
|<<tabs-indicator-space,indicator-space>>|Spacing between tab edge and indicator.
|<<tabs-tabs-are-windows,tabs-are-windows>>|Whether to open windows instead of tabs.
|<<tabs-title-format,title-format>>|The format to use for the tab title. The following placeholders are defined:
|<<tabs-mousewheel-tab-switching,mousewheel-tab-switching>>|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.

View File

@ -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
)),

View File

@ -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):