From 7cb39aed0bd1a7b1ddffce0f068514b0edcdd5bd Mon Sep 17 00:00:00 2001 From: nowrep Date: Sun, 12 Jan 2014 16:39:23 +0100 Subject: [PATCH] [TabBar] Added option to always switch tabs using mouse wheel It will switch tabs even when tabs are overflowing. --- src/lib/other/qzsettings.cpp | 1 + src/lib/other/qzsettings.h | 1 + src/lib/preferences/preferences.cpp | 2 ++ src/lib/preferences/preferences.ui | 7 +++++++ src/lib/tools/combotabbar.cpp | 7 +++++++ 5 files changed, 18 insertions(+) diff --git a/src/lib/other/qzsettings.cpp b/src/lib/other/qzsettings.cpp index 62b95a711..6a696fcaa 100644 --- a/src/lib/other/qzsettings.cpp +++ b/src/lib/other/qzsettings.cpp @@ -57,6 +57,7 @@ void QzSettings::loadSettings() settings.beginGroup("Browser-Tabs-Settings"); newTabPosition = settings.value("OpenNewTabsSelected", false).toBool() ? Qz::NT_SelectedTab : Qz::NT_NotSelectedTab; tabsOnTop = settings.value("TabsOnTop", false).toBool(); + alwaysSwitchTabsWithWheel = settings.value("AlwaysSwitchTabsWithWheel", false).toBool(); settings.endGroup(); } diff --git a/src/lib/other/qzsettings.h b/src/lib/other/qzsettings.h index ae27aec49..9105c5dc8 100644 --- a/src/lib/other/qzsettings.h +++ b/src/lib/other/qzsettings.h @@ -60,6 +60,7 @@ public: // Browser-Tabs-Settings Qz::NewTabPositionFlag newTabPosition; bool tabsOnTop; + bool alwaysSwitchTabsWithWheel; }; #define qzSettings Settings::staticSettings() diff --git a/src/lib/preferences/preferences.cpp b/src/lib/preferences/preferences.cpp index 10b6dc470..27b9d464c 100644 --- a/src/lib/preferences/preferences.cpp +++ b/src/lib/preferences/preferences.cpp @@ -228,6 +228,7 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent) ui->activateLastTab->setChecked(settings.value("ActivateLastTabWhenClosingActual", false).toBool()); ui->openNewTabAfterActive->setChecked(settings.value("newTabAfterActive", true).toBool()); ui->openNewEmptyTabAfterActive->setChecked(settings.value("newEmptyTabAfterActive", false).toBool()); + ui->alwaysSwitchTabsWithWheel->setChecked(settings.value("AlwaysSwitchTabsWithWheel", false).toBool()); ui->switchToNewTabs->setChecked(settings.value("OpenNewTabsSelected", false).toBool()); ui->dontQuitOnTab->setChecked(settings.value("dontQuitWithOneTab", false).toBool()); ui->askWhenClosingMultipleTabs->setChecked(settings.value("AskOnClosing", false).toBool()); @@ -901,6 +902,7 @@ void Preferences::saveSettings() settings.setValue("ActivateLastTabWhenClosingActual", ui->activateLastTab->isChecked()); settings.setValue("newTabAfterActive", ui->openNewTabAfterActive->isChecked()); settings.setValue("newEmptyTabAfterActive", ui->openNewEmptyTabAfterActive->isChecked()); + settings.setValue("AlwaysSwitchTabsWithWheel", ui->alwaysSwitchTabsWithWheel->isChecked()); settings.setValue("OpenNewTabsSelected", ui->switchToNewTabs->isChecked()); settings.setValue("dontQuitWithOneTab", ui->dontQuitOnTab->isChecked()); settings.setValue("AskOnClosing", ui->askWhenClosingMultipleTabs->isChecked()); diff --git a/src/lib/preferences/preferences.ui b/src/lib/preferences/preferences.ui index 44324fcea..65bc4ee1b 100644 --- a/src/lib/preferences/preferences.ui +++ b/src/lib/preferences/preferences.ui @@ -728,6 +728,13 @@ + + + + Always switch between tabs with mouse wheel + + + diff --git a/src/lib/tools/combotabbar.cpp b/src/lib/tools/combotabbar.cpp index 522f4d895..baeb619d4 100644 --- a/src/lib/tools/combotabbar.cpp +++ b/src/lib/tools/combotabbar.cpp @@ -19,6 +19,7 @@ #include "toolbutton.h" #include "mainapplication.h" #include "proxystyle.h" +#include "qzsettings.h" #include #include @@ -535,6 +536,12 @@ int ComboTabBar::pinTabBarWidth() const void ComboTabBar::wheelEvent(QWheelEvent* event) { event->accept(); + + if (qzSettings->alwaysSwitchTabsWithWheel) { + setCurrentNextEnabledIndex(event->delta() > 0 ? -1 : 1); + return; + } + if (m_mainTabBarWidget->underMouse()) { if (m_mainTabBarWidget->scrollBar()->isOverFlowed()) { m_mainTabBarWidget->scrollByWheel(event);