From: Peter Penz Date: Thu, 25 Aug 2011 13:42:39 +0000 (+0200) Subject: Fix smooth-scrolling issue X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/04dec30c805f506ba0135636a19970bf01c66209?ds=inline Fix smooth-scrolling issue The smooth-scrolling may only get turned off after finishing the animation, if the scrollbar is not currently modified by the user. --- diff --git a/src/kitemviews/kitemlistcontainer.cpp b/src/kitemviews/kitemlistcontainer.cpp index a0e8c1515..2eb94c901 100644 --- a/src/kitemviews/kitemlistcontainer.cpp +++ b/src/kitemviews/kitemlistcontainer.cpp @@ -59,6 +59,7 @@ public: KItemListContainer::KItemListContainer(KItemListController* controller, QWidget* parent) : QAbstractScrollArea(parent), m_controller(controller), + m_scrollBarPressed(false), m_smoothScrolling(false), m_smoothScrollingAnimation(0) { @@ -70,6 +71,7 @@ KItemListContainer::KItemListContainer(KItemListController* controller, QWidget* KItemListContainer::KItemListContainer(QWidget* parent) : QAbstractScrollArea(parent), m_controller(0), + m_scrollBarPressed(false), 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 - // 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()) || @@ -158,10 +160,12 @@ bool KItemListContainer::eventFilter(QObject* obj, QEvent* event) if (checkEvent) { switch (event->type()) { case QEvent::MouseButtonPress: + m_scrollBarPressed = true; m_smoothScrolling = true; break; case QEvent::MouseButtonRelease: + m_scrollBarPressed = false; m_smoothScrolling = false; break; @@ -230,7 +234,7 @@ void KItemListContainer::slotAnimationStateChanged(QAbstractAnimation::State new QAbstractAnimation::State oldState) { Q_UNUSED(oldState); - if (newState == QAbstractAnimation::Stopped) { + if (newState == QAbstractAnimation::Stopped && m_smoothScrolling && !m_scrollBarPressed) { m_smoothScrolling = false; } } diff --git a/src/kitemviews/kitemlistcontainer.h b/src/kitemviews/kitemlistcontainer.h index 5f846a9bf..333f01de7 100644 --- a/src/kitemviews/kitemlistcontainer.h +++ b/src/kitemviews/kitemlistcontainer.h @@ -71,6 +71,7 @@ private: private: KItemListController* m_controller; + bool m_scrollBarPressed; bool m_smoothScrolling; QPropertyAnimation* m_smoothScrollingAnimation; };