From 7122e478174545bd2bccd8d1aa7d49ae99cd6d8e Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Mon, 1 Oct 2018 03:32:20 +0300 Subject: [PATCH 1/3] Added scrolling over tabs with wheel to switch channels. --- src/widgets/helper/NotebookTab.cpp | 14 ++++++++++++++ src/widgets/helper/NotebookTab.hpp | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/src/widgets/helper/NotebookTab.cpp b/src/widgets/helper/NotebookTab.cpp index 51812e7c7..8f88ea1c5 100644 --- a/src/widgets/helper/NotebookTab.cpp +++ b/src/widgets/helper/NotebookTab.cpp @@ -479,6 +479,20 @@ void NotebookTab::mouseMoveEvent(QMouseEvent *event) Button::mouseMoveEvent(event); } +void NotebookTab::wheelEvent(QWheelEvent *event) +{ + float mouseMultiplier = getSettings()->mouseScrollMultiplier; + wheelValue += event->delta() * mouseMultiplier; + + if (wheelValue > WHEEL_STEP) { + this->notebook_->selectNextTab(); + wheelValue = 0; + } else if (wheelValue < -WHEEL_STEP) { + this->notebook_->selectPreviousTab(); + wheelValue = 0; + } +} + QRect NotebookTab::getXRect() { // if (!this->notebook->getAllowUserTabManagement()) { diff --git a/src/widgets/helper/NotebookTab.hpp b/src/widgets/helper/NotebookTab.hpp index 15baebecc..3c0fe8ab6 100644 --- a/src/widgets/helper/NotebookTab.hpp +++ b/src/widgets/helper/NotebookTab.hpp @@ -12,6 +12,7 @@ namespace chatterino { #define NOTEBOOK_TAB_HEIGHT 28 +#define WHEEL_STEP 240 // class Notebook; class Notebook; @@ -61,6 +62,7 @@ protected: virtual void dragEnterEvent(QDragEnterEvent *event) override; virtual void mouseMoveEvent(QMouseEvent *event) override; + virtual void wheelEvent(QWheelEvent *event) override; private: bool hasXButton(); @@ -83,6 +85,8 @@ private: bool mouseOverX_ = false; bool mouseDownX_ = false; + float wheelValue = 0; + HighlightState highlightState_ = HighlightState::None; bool highlightEnabled_ = true; QAction *highlightNewMessagesAction_; From 1fcfd8b13a58a3f545f48e65c3502088876a017c Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Fri, 5 Oct 2018 23:57:02 +0300 Subject: [PATCH 2/3] Removed few-step scroll. --- src/widgets/helper/NotebookTab.cpp | 9 ++------- src/widgets/helper/NotebookTab.hpp | 3 --- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/widgets/helper/NotebookTab.cpp b/src/widgets/helper/NotebookTab.cpp index 8f88ea1c5..5143ea4e2 100644 --- a/src/widgets/helper/NotebookTab.cpp +++ b/src/widgets/helper/NotebookTab.cpp @@ -481,15 +481,10 @@ void NotebookTab::mouseMoveEvent(QMouseEvent *event) void NotebookTab::wheelEvent(QWheelEvent *event) { - float mouseMultiplier = getSettings()->mouseScrollMultiplier; - wheelValue += event->delta() * mouseMultiplier; - - if (wheelValue > WHEEL_STEP) { + if (event->delta() > 0) { this->notebook_->selectNextTab(); - wheelValue = 0; - } else if (wheelValue < -WHEEL_STEP) { + } else { this->notebook_->selectPreviousTab(); - wheelValue = 0; } } diff --git a/src/widgets/helper/NotebookTab.hpp b/src/widgets/helper/NotebookTab.hpp index 3c0fe8ab6..4ec931acc 100644 --- a/src/widgets/helper/NotebookTab.hpp +++ b/src/widgets/helper/NotebookTab.hpp @@ -12,7 +12,6 @@ namespace chatterino { #define NOTEBOOK_TAB_HEIGHT 28 -#define WHEEL_STEP 240 // class Notebook; class Notebook; @@ -85,8 +84,6 @@ private: bool mouseOverX_ = false; bool mouseDownX_ = false; - float wheelValue = 0; - HighlightState highlightState_ = HighlightState::None; bool highlightEnabled_ = true; QAction *highlightNewMessagesAction_; From 871fde5f72d3111ef3d5d31fac2ebc3c972dad6c Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sat, 6 Oct 2018 14:18:27 +0300 Subject: [PATCH 3/3] Reversed scroll behavior. --- src/widgets/helper/NotebookTab.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/widgets/helper/NotebookTab.cpp b/src/widgets/helper/NotebookTab.cpp index 5143ea4e2..f3f2f7643 100644 --- a/src/widgets/helper/NotebookTab.cpp +++ b/src/widgets/helper/NotebookTab.cpp @@ -482,9 +482,9 @@ void NotebookTab::mouseMoveEvent(QMouseEvent *event) void NotebookTab::wheelEvent(QWheelEvent *event) { if (event->delta() > 0) { - this->notebook_->selectNextTab(); - } else { this->notebook_->selectPreviousTab(); + } else { + this->notebook_->selectNextTab(); } }