X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/58c5eae1953bbdcf6d4150b21cb7ffdad07a5257..9760f9607d:/src/kitemviews/private/kitemlistsmoothscroller.cpp diff --git a/src/kitemviews/private/kitemlistsmoothscroller.cpp b/src/kitemviews/private/kitemlistsmoothscroller.cpp index cb1dd61ff..4f6fd3015 100644 --- a/src/kitemviews/private/kitemlistsmoothscroller.cpp +++ b/src/kitemviews/private/kitemlistsmoothscroller.cpp @@ -20,11 +20,10 @@ #include "kitemlistsmoothscroller.h" #include -#include #include #include -#include #include +#include KItemListSmoothScroller::KItemListSmoothScroller(QScrollBar* scrollBar, QObject* parent) : @@ -32,12 +31,17 @@ KItemListSmoothScroller::KItemListSmoothScroller(QScrollBar* scrollBar, m_scrollBarPressed(false), m_smoothScrolling(true), m_scrollBar(scrollBar), - m_animation(0) + m_animation(nullptr) { m_animation = new QPropertyAnimation(this); - const int duration = m_scrollBar->style()->styleHint(QStyle::SH_Widget_Animate, nullptr, m_scrollBar) ? 300 : 1; - m_animation->setDuration(duration); - m_animation->setEasingCurve(QEasingCurve::InOutQuart); +#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) + const int animationDuration = m_scrollBar->style()->styleHint(QStyle::SH_Widget_Animation_Duration, nullptr, m_scrollBar); + const bool animationEnabled = (animationDuration > 0); + #else + const int animationDuration = 100; + const bool animationEnabled = m_scrollBar->style()->styleHint(QStyle::SH_Widget_Animate, nullptr, m_scrollBar); +#endif + m_animation->setDuration(animationEnabled ? animationDuration : 1); connect(m_animation, &QPropertyAnimation::stateChanged, this, &KItemListSmoothScroller::slotAnimationStateChanged);