]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fix smooth-scrolling issue
authorPeter Penz <peter.penz19@gmail.com>
Thu, 25 Aug 2011 13:42:39 +0000 (15:42 +0200)
committerPeter Penz <peter.penz19@gmail.com>
Thu, 25 Aug 2011 13:44:23 +0000 (15:44 +0200)
The smooth-scrolling may only get turned off after finishing the
animation, if the scrollbar is not currently modified by the user.

src/kitemviews/kitemlistcontainer.cpp
src/kitemviews/kitemlistcontainer.h

index a0e8c15158888a02319341f5195d78b18c79b66e..2eb94c901ac5ba11d11651b30a230902b95d5dc5 100644 (file)
@@ -59,6 +59,7 @@ public:
 KItemListContainer::KItemListContainer(KItemListController* controller, QWidget* parent) :
     QAbstractScrollArea(parent),
     m_controller(controller),
 KItemListContainer::KItemListContainer(KItemListController* controller, QWidget* parent) :
     QAbstractScrollArea(parent),
     m_controller(controller),
+    m_scrollBarPressed(false),
     m_smoothScrolling(false),
     m_smoothScrollingAnimation(0)
 {
     m_smoothScrolling(false),
     m_smoothScrollingAnimation(0)
 {
@@ -70,6 +71,7 @@ KItemListContainer::KItemListContainer(KItemListController* controller, QWidget*
 KItemListContainer::KItemListContainer(QWidget* parent) :
     QAbstractScrollArea(parent),
     m_controller(0),
 KItemListContainer::KItemListContainer(QWidget* parent) :
     QAbstractScrollArea(parent),
     m_controller(0),
+    m_scrollBarPressed(false),
     m_smoothScrolling(false),
     m_smoothScrollingAnimation(0)
 {
     m_smoothScrolling(false),
     m_smoothScrollingAnimation(0)
 {
@@ -149,8 +151,8 @@ bool KItemListContainer::eventFilter(QObject* obj, QEvent* event)
     Q_ASSERT(obj == horizontalScrollBar() || obj == verticalScrollBar());
 
     // Check whether the scrollbar has been adjusted by a mouse-event
     Q_ASSERT(obj == horizontalScrollBar() || obj == verticalScrollBar());
 
     // Check whether the scrollbar has been adjusted by a mouse-event
-    // triggered by the user and remember this in m_smoothScrolling.
-    // The smooth scrolling will only get active if m_smoothScrolling
+    // triggered by the user and remember this in m_scrollBarPressed.
+    // The smooth scrolling will only get active if m_scrollBarPressed
     // is true (see scrollContentsBy()).
     const bool scrollVertical = (m_controller->view()->scrollOrientation() == Qt::Vertical);
     const bool checkEvent = ( scrollVertical && obj == verticalScrollBar()) ||
     // is true (see scrollContentsBy()).
     const bool scrollVertical = (m_controller->view()->scrollOrientation() == Qt::Vertical);
     const bool checkEvent = ( scrollVertical && obj == verticalScrollBar()) ||
@@ -158,10 +160,12 @@ bool KItemListContainer::eventFilter(QObject* obj, QEvent* event)
     if (checkEvent) {
         switch (event->type()) {
         case QEvent::MouseButtonPress:
     if (checkEvent) {
         switch (event->type()) {
         case QEvent::MouseButtonPress:
+            m_scrollBarPressed = true;
             m_smoothScrolling = true;
             break;
 
         case QEvent::MouseButtonRelease:
             m_smoothScrolling = true;
             break;
 
         case QEvent::MouseButtonRelease:
+            m_scrollBarPressed = false;
             m_smoothScrolling = false;
             break;
 
             m_smoothScrolling = false;
             break;
 
@@ -230,7 +234,7 @@ void KItemListContainer::slotAnimationStateChanged(QAbstractAnimation::State new
                                                    QAbstractAnimation::State oldState)
 {
     Q_UNUSED(oldState);
                                                    QAbstractAnimation::State oldState)
 {
     Q_UNUSED(oldState);
-    if (newState == QAbstractAnimation::Stopped) {
+    if (newState == QAbstractAnimation::Stopped && m_smoothScrolling && !m_scrollBarPressed) {
         m_smoothScrolling = false;
     }
 }
         m_smoothScrolling = false;
     }
 }
index 5f846a9bfa5230e98e3b25fe332a7099b9fc8102..333f01de75bb63965cf9b9c744c3279187fb5caa 100644 (file)
@@ -71,6 +71,7 @@ private:
 private:
     KItemListController* m_controller;
 
 private:
     KItemListController* m_controller;
 
+    bool m_scrollBarPressed;
     bool m_smoothScrolling;
     QPropertyAnimation* m_smoothScrollingAnimation;
 };
     bool m_smoothScrolling;
     QPropertyAnimation* m_smoothScrollingAnimation;
 };