Reusing duration property from base class and storing target animation

scale factor.


svn path=/trunk/KDE/kdelibs/; revision=1059938
This commit is contained in:
Adenilson Cavalcanti Da Silva 2009-12-07 18:16:33 +00:00
parent 07fcab757c
commit 7a4193fa2a
2 changed files with 10 additions and 10 deletions

View File

@ -38,7 +38,8 @@ public :
PulseAnimationPrivate() PulseAnimationPrivate()
: under(0), : under(0),
zvalue(0), zvalue(0),
mscale(0), scale(0),
endScale(1.5),
opacityAnimation(0), opacityAnimation(0),
scaleAnimation(0) scaleAnimation(0)
{} {}
@ -47,7 +48,8 @@ public :
{ } { }
QGraphicsWidget *under; QGraphicsWidget *under;
qreal zvalue, mscale, mopacity; qreal zvalue, scale, mopacity;
qreal endScale;
QPropertyAnimation *opacityAnimation; QPropertyAnimation *opacityAnimation;
QPropertyAnimation *scaleAnimation; QPropertyAnimation *scaleAnimation;
QWeakPointer<QParallelAnimationGroup> animation; QWeakPointer<QParallelAnimationGroup> animation;
@ -66,15 +68,13 @@ void PulseAnimation::setWidgetToAnimate(QGraphicsWidget *widget)
delete d->under; delete d->under;
d->under = 0; d->under = 0;
} }
createAnimation(Animation::duration(), d->endScale);
createAnimation();
} }
} }
PulseAnimation::PulseAnimation(QObject *parent) PulseAnimation::PulseAnimation(QObject *parent)
: Animation(parent), d(new PulseAnimationPrivate) : Animation(parent), d(new PulseAnimationPrivate)
{ {
} }
PulseAnimation::~PulseAnimation() PulseAnimation::~PulseAnimation()
@ -99,11 +99,11 @@ void PulseAnimation::setCopy()
d->mopacity = 0; d->mopacity = 0;
d->zvalue = target->zValue(); d->zvalue = target->zValue();
--d->zvalue; --d->zvalue;
d->mscale = target->scale(); d->scale = target->scale();
d->under = shadow; d->under = shadow;
d->under->setOpacity(d->mopacity); d->under->setOpacity(d->mopacity);
d->under->setScale(d->mscale); d->under->setScale(d->scale);
d->under->setZValue(d->zvalue); d->under->setZValue(d->zvalue);
} }
@ -111,7 +111,7 @@ void PulseAnimation::setCopy()
void PulseAnimation::resetPulser() void PulseAnimation::resetPulser()
{ {
d->under->setOpacity(d->mopacity); d->under->setOpacity(d->mopacity);
d->under->setScale(d->mscale); d->under->setScale(d->scale);
d->under->setZValue(d->zvalue); d->under->setZValue(d->zvalue);
} }
@ -135,7 +135,7 @@ void PulseAnimation::createAnimation(qreal duration, qreal scale)
d->scaleAnimation = new QPropertyAnimation(d->under, "scale"); d->scaleAnimation = new QPropertyAnimation(d->under, "scale");
d->scaleAnimation->setDuration(duration); d->scaleAnimation->setDuration(duration);
d->scaleAnimation->setStartValue(d->mscale); d->scaleAnimation->setStartValue(d->scale);
d->scaleAnimation->setEndValue(scale); d->scaleAnimation->setEndValue(scale);
/* The group takes ownership of all animations */ /* The group takes ownership of all animations */

View File

@ -47,7 +47,7 @@ protected:
private: private:
void createAnimation(qreal _duration = 500, qreal _scale = 1.5); void createAnimation(qreal _duration, qreal _scale);
PulseAnimationPrivate *d; PulseAnimationPrivate *d;
}; };