From 831bd97941300f0953191f482d496d25fd480d74 Mon Sep 17 00:00:00 2001 From: Adenilson Cavalcanti Da Silva Date: Mon, 7 Dec 2009 16:37:23 +0000 Subject: [PATCH] Making pulse animation work again with new design. It is still using an internal animation group (got to try to fix this later). svn path=/trunk/KDE/kdelibs/; revision=1059906 --- animations/pulser.cpp | 63 ++++++++++++++++++++++++++++--------------- animations/pulser_p.h | 3 ++- 2 files changed, 43 insertions(+), 23 deletions(-) diff --git a/animations/pulser.cpp b/animations/pulser.cpp index d0b5805a1..5ae10b4c2 100644 --- a/animations/pulser.cpp +++ b/animations/pulser.cpp @@ -58,10 +58,18 @@ public : void PulseAnimation::setWidgetToAnimate(QGraphicsWidget *widget) { + if (widget == widgetToAnimate()) { + return; + } + Animation::setWidgetToAnimate(widget); - if (d->animation.data()) { - delete d->animation.data(); - d->animation.clear(); + if (widget) { + if (d->under) { + delete d->under; + d->under = 0; + } + + createAnimation(); } } @@ -135,30 +143,41 @@ void PulseAnimation::createAnimation(qreal duration, qreal scale) /* The group takes ownership of all animations */ group->addAnimation(d->scaleAnimation); d->animation = group; - } else { - QAbstractAnimation::State temp = anim->state(); - if (temp == QAbstractAnimation::Running) { - anim->stop(); - /* TODO: will need to watch stateChanged signal - * and *then* reset the geometry - */ - } else { - if (d->under->size() != widgetToAnimate()->size()) { - setCopy(); - } - - d->opacityAnimation->setEndValue(0); - d->scaleAnimation->setEndValue(scale); - } } } -QAbstractAnimation* PulseAnimation::render(QObject* parent) +void PulseAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) { - Q_UNUSED(parent); - createAnimation(duration()); - return d->animation.data(); + if (oldState == Stopped && newState == Running) { + QParallelAnimationGroup *anim = d->animation.data(); + QAbstractAnimation::State temp = anim->state(); + if (temp == QAbstractAnimation::Running) { + anim->stop(); + /* TODO: will need to watch stateChanged signal + * and *then* reset the geometry + */ + } else { + if (d->under->size() != widgetToAnimate()->size()) { + setCopy(); + } + d->opacityAnimation->setEndValue(0); + /* TODO: save the scale factor somewhere */ + d->scaleAnimation->setEndValue(1.5); + } + + d->animation.data()->start(); + + } else if (newState == Stopped) { + //d->animation.data()->stop(); + } + +} + +void PulseAnimation::updateCurrentTime(int currentTime) +{ + + qDebug() << "\t: " << currentTime; } } //namespace Plasma diff --git a/animations/pulser_p.h b/animations/pulser_p.h index b9a9ab161..c8f923391 100644 --- a/animations/pulser_p.h +++ b/animations/pulser_p.h @@ -42,7 +42,8 @@ public Q_SLOTS: void resetPulser(); protected: - virtual QAbstractAnimation* render(QObject* parent = 0); + void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState); + void updateCurrentTime(int currentTime); void setCopy(); private: