]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/private/kitemlistsmoothscroller.cpp
Fix Windows Build
[dolphin.git] / src / kitemviews / private / kitemlistsmoothscroller.cpp
index 6bfdba4c9ae5fbd911716e96c136685e7a5ee22e..cdb7f255b978763ead545ee9901871d6cc191270 100644 (file)
 #include "kitemlistsmoothscroller.h"
 
 #include <QApplication>
-#include <QEvent>
 #include <QPropertyAnimation>
 #include <QScrollBar>
-#include <QWheelEvent>
 #include <QStyle>
+#include <QWheelEvent>
 
 KItemListSmoothScroller::KItemListSmoothScroller(QScrollBar* scrollBar,
                                                  QObject* parent) :
@@ -32,11 +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) ? 100 : 1;
-    m_animation->setDuration(duration);
+#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);
 
@@ -184,7 +189,7 @@ bool KItemListSmoothScroller::eventFilter(QObject* obj, QEvent* event)
 void KItemListSmoothScroller::slotAnimationStateChanged(QAbstractAnimation::State newState,
                                                         QAbstractAnimation::State oldState)
 {
-    Q_UNUSED(oldState);
+    Q_UNUSED(oldState)
     if (newState == QAbstractAnimation::Stopped && m_smoothScrolling && !m_scrollBarPressed) {
         m_smoothScrolling = false;
     }