diff options
| author | Peter Penz <[email protected]> | 2011-08-25 15:42:39 +0200 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2011-08-25 15:44:23 +0200 |
| commit | 04dec30c805f506ba0135636a19970bf01c66209 (patch) | |
| tree | 9ff3905e69e871f6f60ce820116d5c1b6806b435 /src/kitemviews/kitemlistcontainer.cpp | |
| parent | cae90c168ebf8e81f5bb8569f6a4d15156923196 (diff) | |
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.
Diffstat (limited to 'src/kitemviews/kitemlistcontainer.cpp')
| -rw-r--r-- | src/kitemviews/kitemlistcontainer.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
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; } } |
