The smooth-scrolling may only get turned off after finishing the
animation, if the scrollbar is not currently modified by the user.
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)
{
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)
{
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()) ||
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;
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;
}
}
private:
KItemListController* m_controller;
private:
KItemListController* m_controller;
+ bool m_scrollBarPressed;
bool m_smoothScrolling;
QPropertyAnimation* m_smoothScrollingAnimation;
};
bool m_smoothScrolling;
QPropertyAnimation* m_smoothScrollingAnimation;
};