X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/6c3d9acbc22ea9463ba40ef84c9e8c8419dfacf3..119f7a3f:/src/kitemviews/private/kitemlistsmoothscroller.cpp diff --git a/src/kitemviews/private/kitemlistsmoothscroller.cpp b/src/kitemviews/private/kitemlistsmoothscroller.cpp index 6987e1ce1..697d3f526 100644 --- a/src/kitemviews/private/kitemlistsmoothscroller.cpp +++ b/src/kitemviews/private/kitemlistsmoothscroller.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include KItemListSmoothScroller::KItemListSmoothScroller(QScrollBar* scrollBar, QObject* parent) : @@ -38,8 +38,8 @@ KItemListSmoothScroller::KItemListSmoothScroller(QScrollBar* scrollBar, m_animation = new QPropertyAnimation(this); const int duration = (KGlobalSettings::graphicEffectsLevel() == KGlobalSettings::NoEffects) ? 1 : 100; m_animation->setDuration(duration); - connect(m_animation, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)), - this, SLOT(slotAnimationStateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); + connect(m_animation, &QPropertyAnimation::stateChanged, + this, &KItemListSmoothScroller::slotAnimationStateChanged); m_scrollBar->installEventFilter(this); } @@ -130,8 +130,13 @@ void KItemListSmoothScroller::scrollContentsBy(qreal distance) void KItemListSmoothScroller::scrollTo(qreal position) { - m_smoothScrolling = true; - m_scrollBar->setValue(position); + int newValue = position; + newValue = qBound(0, newValue, m_scrollBar->maximum()); + + if (newValue != m_scrollBar->value()) { + m_smoothScrolling = true; + m_scrollBar->setValue(newValue); + } } bool KItemListSmoothScroller::requestScrollBarUpdate(int newMaximum) @@ -204,4 +209,3 @@ void KItemListSmoothScroller::handleWheelEvent(QWheelEvent* event) event->accept(); } -#include "kitemlistsmoothscroller.moc"