summaryrefslogtreecommitdiffstats
path: root/src/corelib/animation/qsequentialanimationgroup.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/animation/qsequentialanimationgroup.cpp')
-rw-r--r--src/corelib/animation/qsequentialanimationgroup.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/corelib/animation/qsequentialanimationgroup.cpp b/src/corelib/animation/qsequentialanimationgroup.cpp
index 53fc4f3..9ad433f 100644
--- a/src/corelib/animation/qsequentialanimationgroup.cpp
+++ b/src/corelib/animation/qsequentialanimationgroup.cpp
@@ -112,17 +112,13 @@ int QSequentialAnimationGroupPrivate::animationActualTotalDuration(int index) co
return ret;
}
-QSequentialAnimationGroupPrivate::AnimationIndex QSequentialAnimationGroupPrivate::indexForTime(int msecs) const
+QSequentialAnimationGroupPrivate::AnimationIndex QSequentialAnimationGroupPrivate::indexForCurrentTime() const
{
- Q_Q(const QSequentialAnimationGroup);
Q_ASSERT(!animations.isEmpty());
AnimationIndex ret;
int duration = 0;
- // in case duration is -1, currentLoop will always be 0
- ret.timeOffset = currentLoop * q->duration();
-
for (int i = 0; i < animations.size(); ++i) {
duration = animationActualTotalDuration(i);
@@ -131,8 +127,8 @@ QSequentialAnimationGroupPrivate::AnimationIndex QSequentialAnimationGroupPrivat
// 2. it ends after msecs
// 3. it is the last animation (this can happen in case there is at least 1 uncontrolled animation)
// 4. it ends exactly in msecs and the direction is backwards
- if (duration == -1 || msecs < (ret.timeOffset + duration)
- || (msecs == (ret.timeOffset + duration) && direction == QAbstractAnimation::Backward)) {
+ if (duration == -1 || currentTime < (ret.timeOffset + duration)
+ || (currentTime == (ret.timeOffset + duration) && direction == QAbstractAnimation::Backward)) {
ret.index = i;
return ret;
}
@@ -338,13 +334,13 @@ int QSequentialAnimationGroup::duration() const
/*!
\reimp
*/
-void QSequentialAnimationGroup::updateCurrentTime(int msecs)
+void QSequentialAnimationGroup::updateCurrentTime()
{
Q_D(QSequentialAnimationGroup);
if (!d->currentAnimation)
return;
- const QSequentialAnimationGroupPrivate::AnimationIndex newAnimationIndex = d->indexForTime(msecs);
+ const QSequentialAnimationGroupPrivate::AnimationIndex newAnimationIndex = d->indexForCurrentTime();
// remove unneeded animations from actualDuration list
while (newAnimationIndex.index < d->actualDuration.size())
@@ -363,7 +359,7 @@ void QSequentialAnimationGroup::updateCurrentTime(int msecs)
d->setCurrentAnimation(newAnimationIndex.index);
- const int newCurrentTime = msecs - newAnimationIndex.timeOffset;
+ const int newCurrentTime = d->currentTime - newAnimationIndex.timeOffset;
if (d->currentAnimation) {
d->currentAnimation->setCurrentTime(newCurrentTime);