48 QSequentialAnimationGroup is a QAnimationGroup that runs its |
48 QSequentialAnimationGroup is a QAnimationGroup that runs its |
49 animations in sequence, i.e., it starts one animation after |
49 animations in sequence, i.e., it starts one animation after |
50 another has finished playing. The animations are played in the |
50 another has finished playing. The animations are played in the |
51 order they are added to the group (using |
51 order they are added to the group (using |
52 \l{QAnimationGroup::}{addAnimation()} or |
52 \l{QAnimationGroup::}{addAnimation()} or |
53 \l{QAnimationGroup::}{insertAnimationAt()}). The animation group |
53 \l{QAnimationGroup::}{insertAnimation()}). The animation group |
54 finishes when its last animation has finished. |
54 finishes when its last animation has finished. |
55 |
55 |
56 At each moment there is at most one animation that is active in |
56 At each moment there is at most one animation that is active in |
57 the group; it is returned by currentAnimation(). An empty group |
57 the group; it is returned by currentAnimation(). An empty group |
58 has no current animation. |
58 has no current animation. |
59 |
59 |
60 A sequential animation group can be treated as any other |
60 A sequential animation group can be treated as any other |
61 animation, i.e., it can be started, stopped, and added to other |
61 animation, i.e., it can be started, stopped, and added to other |
62 groups. You can also call addPause() or insertPauseAt() to add a |
62 groups. You can also call addPause() or insertPause() to add a |
63 pause to a sequential animation group. |
63 pause to a sequential animation group. |
64 |
64 |
65 \code |
65 \code |
66 QSequentialAnimationGroup group; |
66 QSequentialAnimationGroup *group = new QSequentialAnimationGroup; |
67 |
67 |
68 group.addAnimation(anim1); |
68 group->addAnimation(anim1); |
69 group.addAnimation(anim2); |
69 group->addAnimation(anim2); |
70 |
70 |
71 group.start(); |
71 group->start(); |
72 \endcode |
72 \endcode |
73 |
73 |
74 In this example, \c anim1 and \c anim2 are two already set up |
74 In this example, \c anim1 and \c anim2 are two already set up |
75 \l{QPropertyAnimation}s. |
75 \l{QPropertyAnimation}s. |
76 |
76 |
267 Adds a pause of \a msecs to this animation group. |
267 Adds a pause of \a msecs to this animation group. |
268 The pause is considered as a special type of animation, thus |
268 The pause is considered as a special type of animation, thus |
269 \l{QAnimationGroup::animationCount()}{animationCount} will be |
269 \l{QAnimationGroup::animationCount()}{animationCount} will be |
270 increased by one. |
270 increased by one. |
271 |
271 |
272 \sa insertPauseAt(), QAnimationGroup::addAnimation() |
272 \sa insertPause(), QAnimationGroup::addAnimation() |
273 */ |
273 */ |
274 QPauseAnimation *QSequentialAnimationGroup::addPause(int msecs) |
274 QPauseAnimation *QSequentialAnimationGroup::addPause(int msecs) |
275 { |
275 { |
276 QPauseAnimation *pause = new QPauseAnimation(msecs); |
276 QPauseAnimation *pause = new QPauseAnimation(msecs); |
277 addAnimation(pause); |
277 addAnimation(pause); |
280 |
280 |
281 /*! |
281 /*! |
282 Inserts a pause of \a msecs milliseconds at \a index in this animation |
282 Inserts a pause of \a msecs milliseconds at \a index in this animation |
283 group. |
283 group. |
284 |
284 |
285 \sa addPause(), QAnimationGroup::insertAnimationAt() |
285 \sa addPause(), QAnimationGroup::insertAnimation() |
286 */ |
286 */ |
287 QPauseAnimation *QSequentialAnimationGroup::insertPauseAt(int index, int msecs) |
287 QPauseAnimation *QSequentialAnimationGroup::insertPause(int index, int msecs) |
288 { |
288 { |
289 Q_D(const QSequentialAnimationGroup); |
289 Q_D(const QSequentialAnimationGroup); |
290 |
290 |
291 if (index < 0 || index > d->animations.size()) { |
291 if (index < 0 || index > d->animations.size()) { |
292 qWarning("QSequentialAnimationGroup::insertPauseAt: index is out of bounds"); |
292 qWarning("QSequentialAnimationGroup::insertPause: index is out of bounds"); |
293 return 0; |
293 return 0; |
294 } |
294 } |
295 |
295 |
296 QPauseAnimation *pause = new QPauseAnimation(msecs); |
296 QPauseAnimation *pause = new QPauseAnimation(msecs); |
297 insertAnimationAt(index, pause); |
297 insertAnimation(index, pause); |
298 return pause; |
298 return pause; |
299 } |
299 } |
300 |
300 |
301 |
301 |
302 /*! |
302 /*! |
380 } |
380 } |
381 |
381 |
382 /*! |
382 /*! |
383 \reimp |
383 \reimp |
384 */ |
384 */ |
385 void QSequentialAnimationGroup::updateState(QAbstractAnimation::State oldState, |
385 void QSequentialAnimationGroup::updateState(QAbstractAnimation::State newState, |
386 QAbstractAnimation::State newState) |
386 QAbstractAnimation::State oldState) |
387 { |
387 { |
388 Q_D(QSequentialAnimationGroup); |
388 Q_D(QSequentialAnimationGroup); |
389 QAnimationGroup::updateState(oldState, newState); |
389 QAnimationGroup::updateState(newState, oldState); |
390 |
390 |
391 if (!d->currentAnimation) |
391 if (!d->currentAnimation) |
392 return; |
392 return; |
393 |
393 |
394 switch (newState) { |
394 switch (newState) { |
530 |
530 |
531 //we update currentAnimationIndex in case it has changed (the animation pointer is still valid) |
531 //we update currentAnimationIndex in case it has changed (the animation pointer is still valid) |
532 currentAnimationIndex = animations.indexOf(currentAnimation); |
532 currentAnimationIndex = animations.indexOf(currentAnimation); |
533 |
533 |
534 if (index < currentAnimationIndex || currentLoop != 0) { |
534 if (index < currentAnimationIndex || currentLoop != 0) { |
535 qWarning("QSequentialGroup::insertAnimationAt only supports to add animations after the current one."); |
535 qWarning("QSequentialGroup::insertAnimation only supports to add animations after the current one."); |
536 return; //we're not affected because it is added after the current one |
536 return; //we're not affected because it is added after the current one |
537 } |
537 } |
538 } |
538 } |
539 |
539 |
540 /*! |
540 /*! |