/*! \reimp */ void QParallelAnimationGroup::updateCurrentTime(int currentTime) { Q_D(QParallelAnimationGroup); if (d->animations.isEmpty()) return; if (d->currentLoop > d->lastLoop) { // simulate completion of the loop int dura = duration(); if (dura > 0) { for (int i = 0; i < d->animations.size(); ++i) { QAbstractAnimation *animation = d->animations.at(i); if (animation->state() != QAbstractAnimation::Stopped) d->animations.at(i)->setCurrentTime(dura); // will stop } } } else if (d->currentLoop < d->lastLoop) { // simulate completion of the loop seeking backwards for (int i = 0; i < d->animations.size(); ++i) { QAbstractAnimation *animation = d->animations.at(i); //we need to make sure the animation is in the right state //and then rewind it d->applyGroupState(animation); animation->setCurrentTime(0); animation->stop(); } } #ifdef QANIMATION_DEBUG qDebug("QParallellAnimationGroup %5d: setCurrentTime(%d), loop:%d, last:%d, timeFwd:%d, lastcurrent:%d, %d", __LINE__, d->currentTime, d->currentLoop, d->lastLoop, timeFwd, d->lastCurrentTime, state()); #endif // finally move into the actual time of the current loop for (int i = 0; i < d->animations.size(); ++i) { QAbstractAnimation *animation = d->animations.at(i); const int dura = animation->totalDuration(); //if the loopcount is bigger we should always start all animations if (d->currentLoop > d->lastLoop //if we're at the end of the animation, we need to start it if it wasn't already started in this loop //this happens in Backward direction where not all animations are started at the same time || d->shouldAnimationStart(animation, d->lastCurrentTime > dura /*startIfAtEnd*/)) { d->applyGroupState(animation); } if (animation->state() == state()) { animation->setCurrentTime(currentTime); if (dura > 0 && currentTime > dura) animation->stop(); } } d->lastLoop = d->currentLoop; d->lastCurrentTime = currentTime; }
/*! \reimp */ void QParallelAnimationGroup::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) { Q_D(QParallelAnimationGroup); QAnimationGroup::updateState(newState, oldState); switch (newState) { case Stopped: for (int i = 0; i < d->animations.size(); ++i) d->animations.at(i)->stop(); d->disconnectUncontrolledAnimations(); break; case Paused: for (int i = 0; i < d->animations.size(); ++i) if (d->animations.at(i)->state() == Running) d->animations.at(i)->pause(); break; case Running: d->connectUncontrolledAnimations(); for (int i = 0; i < d->animations.size(); ++i) { QAbstractAnimation *animation = d->animations.at(i); if (oldState == Stopped) animation->stop(); animation->setDirection(d->direction); if (d->shouldAnimationStart(animation, oldState == Stopped)) animation->start(); } break; } }