diff options
| -rw-r--r-- | src/kitemviews/kitemlistcontainer.cpp | 7 | ||||
| -rw-r--r-- | src/kitemviews/private/kitemlistsmoothscroller.cpp | 26 |
2 files changed, 32 insertions, 1 deletions
diff --git a/src/kitemviews/kitemlistcontainer.cpp b/src/kitemviews/kitemlistcontainer.cpp index 3ec56e5f1..b221ca5ff 100644 --- a/src/kitemviews/kitemlistcontainer.cpp +++ b/src/kitemviews/kitemlistcontainer.cpp @@ -187,7 +187,12 @@ void KItemListContainer::wheelEvent(QWheelEvent *event) return; } - const bool scrollHorizontally = (qAbs(event->angleDelta().y()) < qAbs(event->angleDelta().x())) || (!verticalScrollBar()->isVisible()); +#ifdef Q_OS_MACOS + const QPoint scrollDelta = event->hasPixelDelta() ? event->pixelDelta() : event->angleDelta(); +#else + const QPoint scrollDelta = event->angleDelta(); +#endif + const bool scrollHorizontally = (qAbs(scrollDelta.y()) < qAbs(scrollDelta.x())) || (!verticalScrollBar()->isVisible()); KItemListSmoothScroller *smoothScroller = scrollHorizontally ? m_horizontalSmoothScroller : m_verticalSmoothScroller; smoothScroller->handleWheelEvent(event); diff --git a/src/kitemviews/private/kitemlistsmoothscroller.cpp b/src/kitemviews/private/kitemlistsmoothscroller.cpp index 915b6b3d5..7cedf9d94 100644 --- a/src/kitemviews/private/kitemlistsmoothscroller.cpp +++ b/src/kitemviews/private/kitemlistsmoothscroller.cpp @@ -209,6 +209,32 @@ void KItemListSmoothScroller::handleWheelEvent(QWheelEvent *event) { const bool previous = m_smoothScrolling; +#ifdef Q_OS_MACOS + if (event->hasPixelDelta()) { + const QPoint pixelDelta = event->pixelDelta(); + const int scrollDelta = qAbs(pixelDelta.x()) > qAbs(pixelDelta.y()) ? pixelDelta.x() : pixelDelta.y(); + const int oldValue = m_scrollBar->value(); + const int newValue = qBound(m_scrollBar->minimum(), oldValue - scrollDelta, m_scrollBar->maximum()); + if (newValue == oldValue) { + event->ignore(); + return; + } + + m_smoothScrolling = false; + if (m_animation->state() == QAbstractAnimation::Running) { + m_animation->stop(); + } + if (QObject *target = targetObject()) { + target->setProperty(propertyName(), newValue); + } + m_scrollBar->setValue(newValue); + event->accept(); + + m_smoothScrolling = previous; + return; + } +#endif + m_smoothScrolling = true; QWheelEvent *copy = event->clone(); |
