Skip to content

Commit

Permalink
Fix QTabBar scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
oclero committed Nov 10, 2024
1 parent 1b3692f commit 1b9b001
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/src/style/EventFilters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<QWheelEvent*>(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.
Expand Down

0 comments on commit 1b9b001

Please sign in to comment.