new optional (so retrocompatible) parameter in the slot called by the custom animation:
the slot can be something like void animationUpdate(qreal progress, int animId) it's useful to keep track of multiple animations with a single slot svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=808853
This commit is contained in:
parent
da89a76bb3
commit
aadef48088
20
animator.cpp
20
animator.cpp
@ -382,7 +382,11 @@ int Animator::customAnimation(int frames, int duration, Animator::CurveShape cur
|
|||||||
connect(receiver, SIGNAL(destroyed(QObject*)),
|
connect(receiver, SIGNAL(destroyed(QObject*)),
|
||||||
this, SLOT(customAnimReceiverDestroyed(QObject*)));
|
this, SLOT(customAnimReceiverDestroyed(QObject*)));
|
||||||
|
|
||||||
QMetaObject::invokeMethod(receiver, slot, Q_ARG(qreal, 0));
|
// try with only progress as argument
|
||||||
|
if (!QMetaObject::invokeMethod(receiver, slot, Q_ARG(qreal, 0))) {
|
||||||
|
//try to pass also the animation id
|
||||||
|
QMetaObject::invokeMethod(receiver, slot, Q_ARG(qreal, 0), Q_ARG(int, state->id));
|
||||||
|
}
|
||||||
|
|
||||||
if (!d->timerId) {
|
if (!d->timerId) {
|
||||||
d->timerId = startTimer(MIN_TICK_RATE);
|
d->timerId = startTimer(MIN_TICK_RATE);
|
||||||
@ -636,11 +640,19 @@ void Animator::timerEvent(QTimerEvent *event)
|
|||||||
state->currentInterval = state->interval;
|
state->currentInterval = state->interval;
|
||||||
animationsRemain = true;
|
animationsRemain = true;
|
||||||
// signal the object
|
// signal the object
|
||||||
QMetaObject::invokeMethod(state->receiver, state->slot,
|
// try with only progress as argument
|
||||||
|
if (!QMetaObject::invokeMethod(state->receiver, state->slot,
|
||||||
Q_ARG(qreal,
|
Q_ARG(qreal,
|
||||||
d->calculateProgress(state->frames, state->currentFrame)));
|
d->calculateProgress(state->frames, state->currentFrame)))) {
|
||||||
|
//if fails try to add the animation id
|
||||||
|
QMetaObject::invokeMethod(state->receiver, state->slot,
|
||||||
|
Q_ARG(qreal,
|
||||||
|
d->calculateProgress(state->frames, state->currentFrame)), Q_ARG(int, state->id));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
QMetaObject::invokeMethod(state->receiver, state->slot, Q_ARG(qreal, 1));
|
if (!QMetaObject::invokeMethod(state->receiver, state->slot, Q_ARG(qreal, 1))) {
|
||||||
|
QMetaObject::invokeMethod(state->receiver, state->slot, Q_ARG(qreal, 1), Q_ARG(int, state->id));
|
||||||
|
}
|
||||||
d->customAnims.erase(d->customAnims.find(state->id));
|
d->customAnims.erase(d->customAnims.find(state->id));
|
||||||
emit customAnimationFinished(state->id);
|
emit customAnimationFinished(state->id);
|
||||||
delete [] state->slot;
|
delete [] state->slot;
|
||||||
|
@ -119,6 +119,9 @@ public:
|
|||||||
* @arg method the method name of slot to be invoked on each update.
|
* @arg method the method name of slot to be invoked on each update.
|
||||||
* It must take a qreal. So if the slot is animate(qreal),
|
* It must take a qreal. So if the slot is animate(qreal),
|
||||||
* pass in "animate" as the method parameter.
|
* pass in "animate" as the method parameter.
|
||||||
|
* It has an optional integer paramenter that takes an
|
||||||
|
* integer that reapresents the animation id, useful if
|
||||||
|
* you want to manage multiple animations with a sigle slot
|
||||||
*
|
*
|
||||||
* @return an id that can be used to identify this animation.
|
* @return an id that can be used to identify this animation.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user