X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/4cf04b91dd8804f2536fc31ae2f1b486bfc8cf9c..8d61c9c7b6f5a97803bf154529b413ee69bc2a1c:/src/kitemviews/private/kitemlistsmoothscroller.cpp diff --git a/src/kitemviews/private/kitemlistsmoothscroller.cpp b/src/kitemviews/private/kitemlistsmoothscroller.cpp index 994d86174..6bfdba4c9 100644 --- a/src/kitemviews/private/kitemlistsmoothscroller.cpp +++ b/src/kitemviews/private/kitemlistsmoothscroller.cpp @@ -19,13 +19,12 @@ #include "kitemlistsmoothscroller.h" -#include +#include #include #include #include #include - -#include +#include KItemListSmoothScroller::KItemListSmoothScroller(QScrollBar* scrollBar, QObject* parent) : @@ -36,7 +35,7 @@ KItemListSmoothScroller::KItemListSmoothScroller(QScrollBar* scrollBar, m_animation(0) { m_animation = new QPropertyAnimation(this); - const int duration = (KGlobalSettings::graphicEffectsLevel() == KGlobalSettings::NoEffects) ? 1 : 100; + const int duration = m_scrollBar->style()->styleHint(QStyle::SH_Widget_Animate, nullptr, m_scrollBar) ? 100 : 1; m_animation->setDuration(duration); connect(m_animation, &QPropertyAnimation::stateChanged, this, &KItemListSmoothScroller::slotAnimationStateChanged); @@ -173,8 +172,7 @@ bool KItemListSmoothScroller::eventFilter(QObject* obj, QEvent* event) break; case QEvent::Wheel: - handleWheelEvent(static_cast(event)); - break; + return false; // we're the ones sending them default: break; @@ -194,19 +192,14 @@ void KItemListSmoothScroller::slotAnimationStateChanged(QAbstractAnimation::Stat void KItemListSmoothScroller::handleWheelEvent(QWheelEvent* event) { - const int numDegrees = event->delta() / 8; - const int numSteps = numDegrees / 15; - const bool previous = m_smoothScrolling; m_smoothScrolling = true; - const int value = m_scrollBar->value(); - const int pageStep = m_scrollBar->pageStep(); - m_scrollBar->setValue(value - numSteps * pageStep); - m_smoothScrolling = previous; + QWheelEvent copy = *event; + QApplication::sendEvent(m_scrollBar, ©); + event->setAccepted(copy.isAccepted()); - event->accept(); + m_smoothScrolling = previous; } -#include "kitemlistsmoothscroller.moc"