From 1b9b0010a7bd98d1dcadb011b2a577d7b2eee78c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Cl=C3=A9ro?= Date: Sun, 10 Nov 2024 12:44:52 +0100 Subject: [PATCH] Fix QTabBar scroll --- lib/src/style/EventFilters.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/src/style/EventFilters.cpp b/lib/src/style/EventFilters.cpp index fe8e63d..fe5856a 100644 --- a/lib/src/style/EventFilters.cpp +++ b/lib/src/style/EventFilters.cpp @@ -239,12 +239,20 @@ bool TabBarEventFilter::eventFilter(QObject* watchedObject, QEvent* evt) { _tabBar->setIconSize(_tabBar->iconSize()); } else if (type == QEvent::Wheel) { const auto* wheelEvent = static_cast(evt); + + // Block non-horizontal scorll. + const bool wheelVertical = qAbs(wheelEvent->angleDelta().y()) > qAbs(wheelEvent->angleDelta().x()); + if (wheelVertical) { + evt->ignore(); + return true; + } + auto delta = wheelEvent->pixelDelta().x(); // If delta is null, it might be because we are on MacOS, using a trackpad. // So let's use angleDelta instead. if (delta == 0) { - delta = wheelEvent->angleDelta().y(); + delta = wheelEvent->angleDelta().x(); } // Invert the value if necessary.