void QParallelAnimationGroupPrivate::_q_uncontrolledAnimationFinished() { Q_Q(QParallelAnimationGroup); QAbstractAnimation *animation = qobject_cast<QAbstractAnimation *>(q->sender()); Q_ASSERT(animation); int uncontrolledRunningCount = 0; if (animation->duration() == -1 || animation->loopCount() < 0) { QHash<QAbstractAnimation *, int>::iterator it = uncontrolledFinishTime.begin(); while (it != uncontrolledFinishTime.end()) { if (it.key() == animation) { *it = animation->currentTime(); } if (it.value() == -1) ++uncontrolledRunningCount; ++it; } } if (uncontrolledRunningCount > 0) return; int maxDuration = 0; for (int i = 0; i < animations.size(); ++i) maxDuration = qMax(maxDuration, animations.at(i)->totalDuration()); if (currentTime >= maxDuration) q->stop(); }
void QParallelAnimationGroupPrivate::connectUncontrolledAnimations() { for (int i = 0; i < animations.size(); ++i) { QAbstractAnimation *animation = animations.at(i); if (animation->duration() == -1 || animation->loopCount() < 0) { uncontrolledFinishTime[animation] = -1; connectUncontrolledAnimation(animation); } } }
void QParallelAnimationGroupPrivate::connectUncontrolledAnimations() { Q_Q(QParallelAnimationGroup); for (int i = 0; i < animations.size(); ++i) { QAbstractAnimation *animation = animations.at(i); if (animation->duration() == -1 || animation->loopCount() < 0) { uncontrolledFinishTime[animation] = -1; QObject::connect(animation, SIGNAL(finished()), q, SLOT(_q_uncontrolledAnimationFinished())); } } }
int QAnimationTimer::closestPauseAnimationTimeToFinish() { int closestTimeToFinish = INT_MAX; for (int i = 0; i < runningPauseAnimations.size(); ++i) { QAbstractAnimation *animation = runningPauseAnimations.at(i); int timeToFinish; if (animation->direction() == QAbstractAnimation::Forward) timeToFinish = animation->duration() - animation->currentLoopTime(); else timeToFinish = animation->currentLoopTime(); if (timeToFinish < closestTimeToFinish) closestTimeToFinish = timeToFinish; } return closestTimeToFinish; }