add an explicit way to stop

svn path=/trunk/KDE/kdelibs/; revision=1094245
This commit is contained in:
Marco Martin 2010-02-22 11:21:30 +00:00
parent 2b9a4f4e63
commit ce3762373f
4 changed files with 22 additions and 5 deletions

View File

@ -198,6 +198,14 @@ public:
*/ */
void unregisterScrollingManager(QGraphicsWidget *widget); 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: Q_SIGNALS:
void animationFinished(QGraphicsItem *item, Plasma::Animator::Animation anim); void animationFinished(QGraphicsItem *item, Plasma::Animator::Animation anim);
void movementFinished(QGraphicsItem *item); void movementFinished(QGraphicsItem *item);

View File

@ -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 } // namespace Plasma

View File

@ -369,6 +369,12 @@ void KineticScrolling::setWidget(QGraphicsWidget *parent)
/* TODO: add a new property in plasma::ScrollWidget 'hasOvershoot' */ /* TODO: add a new property in plasma::ScrollWidget 'hasOvershoot' */
} }
void KineticScrolling::stop()
{
d->scrollAnimation->stop();
}
bool KineticScrolling::eventFilter(QObject *watched, QEvent *event) bool KineticScrolling::eventFilter(QObject *watched, QEvent *event)
{ {
Q_UNUSED(watched); Q_UNUSED(watched);
@ -378,11 +384,6 @@ bool KineticScrolling::eventFilter(QObject *watched, QEvent *event)
return false; return false;
} }
if (event->type() == QEvent::GraphicsSceneMove) {
d->scrollAnimation->stop();
return false;
}
bool notBlocked = true; bool notBlocked = true;
if (d->multitouchGesture == KineticScrollingPrivate::GestureNone && if (d->multitouchGesture == KineticScrollingPrivate::GestureNone &&
d->parent && d->parent->scene()) { d->parent && d->parent->scene()) {

View File

@ -40,6 +40,7 @@ public:
KineticScrolling(QGraphicsWidget *parent); KineticScrolling(QGraphicsWidget *parent);
~KineticScrolling(); ~KineticScrolling();
void setWidget(QGraphicsWidget *parent); void setWidget(QGraphicsWidget *parent);
void stop();
Q_SIGNALS: Q_SIGNALS:
void stateChanged(QAbstractAnimation::State newState, void stateChanged(QAbstractAnimation::State newState,