From 1f21eb0200adf1a480913add64cd56f4ecdec6e0 Mon Sep 17 00:00:00 2001 From: Ivan Ugryumov Date: Thu, 12 Dec 2024 15:13:01 +0300 Subject: [PATCH] Improved tab bar scrolling (#678) * Improved tab bar scrolling * Fix: tab bar scroll for mouse --- src/DockAreaTabBar.cpp | 14 ++------------ src/DockAreaTabBar.h | 3 +-- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/DockAreaTabBar.cpp b/src/DockAreaTabBar.cpp index cf1cb09d..724aedca 100644 --- a/src/DockAreaTabBar.cpp +++ b/src/DockAreaTabBar.cpp @@ -160,19 +160,9 @@ CDockAreaTabBar::~CDockAreaTabBar() //============================================================================ void CDockAreaTabBar::wheelEvent(QWheelEvent* Event) { - Event->accept(); - const int direction = Event->angleDelta().y(); - if (direction < 0) - { - horizontalScrollBar()->setValue(horizontalScrollBar()->value() + 20); - } - else - { - horizontalScrollBar()->setValue(horizontalScrollBar()->value() - 20); - } + QCoreApplication::sendEvent(horizontalScrollBar(), Event); } - //============================================================================ void CDockAreaTabBar::setCurrentIndex(int index) { @@ -356,7 +346,7 @@ void CDockAreaTabBar::onCloseOtherTabsRequested() CDockWidget::DockWidgetDeleteOnClose) ? 1 : 0; closeTab(i); - // If the the dock widget blocks closing, i.e. if the flag + // If the dock widget blocks closing, i.e. if the flag // CustomCloseHandling is set, and the dock widget is still open, // then we do not need to correct the index if (Tab->dockWidget()->isClosed()) diff --git a/src/DockAreaTabBar.h b/src/DockAreaTabBar.h index 2d570094..60557fe6 100644 --- a/src/DockAreaTabBar.h +++ b/src/DockAreaTabBar.h @@ -65,8 +65,7 @@ private Q_SLOTS: void onTabWidgetMoved(const QPoint& GlobalPos); protected: - virtual void wheelEvent(QWheelEvent* Event) override; - + virtual void wheelEvent(QWheelEvent* Event) override; public: using Super = QScrollArea;