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);
}
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)
event->accept();
}
-#include "kitemlistsmoothscroller.moc"