diff --git a/animator.h b/animator.h index d61f20120..c82db346d 100644 --- a/animator.h +++ b/animator.h @@ -198,6 +198,14 @@ public: */ void unregisterScrollingManager(QGraphicsWidget *widget); + /** + * Stop any scrolling that could be happening on widget + * + * @param the widget that must stop animating + * @since 4.5 + */ + void stopScrollingWidget(QGraphicsWidget *widget); + Q_SIGNALS: void animationFinished(QGraphicsItem *item, Plasma::Animator::Animation anim); void movementFinished(QGraphicsItem *item); diff --git a/deprecated/animator.cpp b/deprecated/animator.cpp index 27ddf63bc..bdf98dd3f 100644 --- a/deprecated/animator.cpp +++ b/deprecated/animator.cpp @@ -782,5 +782,12 @@ void Animator::unregisterScrollingManager(QGraphicsWidget *widget) } } +void Animator::stopScrollingWidget(QGraphicsWidget *widget) +{ + if (d->scrollingManagers.contains(widget)) { + d->scrollingManagers.value(widget)->stop(); + } +} + } // namespace Plasma diff --git a/private/kineticscroll.cpp b/private/kineticscroll.cpp index 39b4d50fd..6e323f9e2 100644 --- a/private/kineticscroll.cpp +++ b/private/kineticscroll.cpp @@ -369,6 +369,12 @@ void KineticScrolling::setWidget(QGraphicsWidget *parent) /* TODO: add a new property in plasma::ScrollWidget 'hasOvershoot' */ } +void KineticScrolling::stop() +{ + d->scrollAnimation->stop(); +} + + bool KineticScrolling::eventFilter(QObject *watched, QEvent *event) { Q_UNUSED(watched); @@ -378,11 +384,6 @@ bool KineticScrolling::eventFilter(QObject *watched, QEvent *event) return false; } - if (event->type() == QEvent::GraphicsSceneMove) { - d->scrollAnimation->stop(); - return false; - } - bool notBlocked = true; if (d->multitouchGesture == KineticScrollingPrivate::GestureNone && d->parent && d->parent->scene()) { diff --git a/private/kineticscroll_p.h b/private/kineticscroll_p.h index 5f2571367..cb413a494 100644 --- a/private/kineticscroll_p.h +++ b/private/kineticscroll_p.h @@ -40,6 +40,7 @@ public: KineticScrolling(QGraphicsWidget *parent); ~KineticScrolling(); void setWidget(QGraphicsWidget *parent); + void stop(); Q_SIGNALS: void stateChanged(QAbstractAnimation::State newState,