summaryrefslogtreecommitdiff
path: root/src/corelib/animation
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2009-10-28 09:45:04 +0100
committerBradley T. Hughes <bradley.hughes@nokia.com>2009-10-28 09:45:04 +0100
commit1ec19ed5a69b8b0e11c81037c270072736f48e40 (patch)
tree869800a523b46e527d04c9973f36e294dd101978 /src/corelib/animation
parent0444453661df0f56fd034778028c7abdc0b621cc (diff)
parent1583d643285641bf71e6a107331d788acca9850c (diff)
downloadqt4-tools-1ec19ed5a69b8b0e11c81037c270072736f48e40.tar.gz
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/qt into 4.6-WM_NULL-driven
Diffstat (limited to 'src/corelib/animation')
-rw-r--r--src/corelib/animation/qabstractanimation.cpp39
-rw-r--r--src/corelib/animation/qpauseanimation.cpp3
2 files changed, 21 insertions, 21 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp
index df8b548216..d38ec46fcb 100644
--- a/src/corelib/animation/qabstractanimation.cpp
+++ b/src/corelib/animation/qabstractanimation.cpp
@@ -260,7 +260,8 @@ void QUnifiedTimer::registerAnimation(QAbstractAnimation *animation, bool isTopL
Q_ASSERT(!QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer);
QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer = true;
animationsToStart << animation;
- startStopAnimationTimer.start(STARTSTOP_TIMER_DELAY, this);
+ if (!startStopAnimationTimer.isActive())
+ startStopAnimationTimer.start(STARTSTOP_TIMER_DELAY, this);
}
}
@@ -278,7 +279,7 @@ void QUnifiedTimer::unregisterAnimation(QAbstractAnimation *animation)
if (idx <= currentAnimationIdx)
--currentAnimationIdx;
- if (animations.isEmpty())
+ if (animations.isEmpty() && !startStopAnimationTimer.isActive())
startStopAnimationTimer.start(STARTSTOP_TIMER_DELAY, this);
} else {
animationsToStart.removeOne(animation);
@@ -306,6 +307,7 @@ void QUnifiedTimer::unregisterRunningAnimation(QAbstractAnimation *animation)
runningPauseAnimations.removeOne(animation);
else
runningLeafAnimations--;
+ Q_ASSERT(runningLeafAnimations >= 0);
}
int QUnifiedTimer::closestPauseAnimationTimeToFinish()
@@ -316,9 +318,9 @@ int QUnifiedTimer::closestPauseAnimationTimeToFinish()
int timeToFinish;
if (animation->direction() == QAbstractAnimation::Forward)
- timeToFinish = animation->totalDuration() - QAbstractAnimationPrivate::get(animation)->totalCurrentTime;
+ timeToFinish = animation->duration() - animation->currentTime();
else
- timeToFinish = QAbstractAnimationPrivate::get(animation)->totalCurrentTime;
+ timeToFinish = animation->currentTime();
if (timeToFinish < closestTimeToFinish)
closestTimeToFinish = timeToFinish;
@@ -370,25 +372,20 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState)
QUnifiedTimer::instance()->ensureTimerUpdate(q);
if (!guard)
return;
+ //here we're sure that we were in running state before and that the
+ //animation is currently registered
QUnifiedTimer::instance()->unregisterAnimation(q);
break;
case QAbstractAnimation::Running:
{
bool isTopLevel = !group || group->state() == QAbstractAnimation::Stopped;
+ QUnifiedTimer::instance()->registerAnimation(q, isTopLevel);
// this ensures that the value is updated now that the animation is running
if (oldState == QAbstractAnimation::Stopped) {
if (isTopLevel)
// currentTime needs to be updated if pauseTimer is active
QUnifiedTimer::instance()->ensureTimerUpdate(q);
- if (!guard)
- return;
- }
-
- // test needed in case we stop in the setCurrentTime inside ensureTimerUpdate (zero duration)
- if (state == QAbstractAnimation::Running) {
- // register timer if our parent is not running
- QUnifiedTimer::instance()->registerAnimation(q, isTopLevel);
}
}
break;
@@ -401,7 +398,8 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState)
if (deleteWhenStopped)
q->deleteLater();
- QUnifiedTimer::instance()->unregisterAnimation(q);
+ if (oldState == QAbstractAnimation::Running)
+ QUnifiedTimer::instance()->unregisterAnimation(q);
if (dura == -1 || loopCount < 0
|| (oldDirection == QAbstractAnimation::Forward && (oldCurrentTime * (oldCurrentLoop + 1)) == (dura * loopCount))
@@ -448,7 +446,8 @@ QAbstractAnimation::~QAbstractAnimation()
QAbstractAnimation::State oldState = d->state;
d->state = Stopped;
emit stateChanged(oldState, d->state);
- QUnifiedTimer::instance()->unregisterAnimation(this);
+ if (oldState == QAbstractAnimation::Running)
+ QUnifiedTimer::instance()->unregisterAnimation(this);
}
}
@@ -636,13 +635,13 @@ int QAbstractAnimation::currentLoop() const
*/
int QAbstractAnimation::totalDuration() const
{
- Q_D(const QAbstractAnimation);
- if (d->loopCount < 0)
- return -1;
int dura = duration();
- if (dura == -1)
+ if (dura <= 0)
+ return dura;
+ int loopcount = loopCount();
+ if (loopcount < 0)
return -1;
- return dura * d->loopCount;
+ return dura * loopcount;
}
/*!
@@ -673,7 +672,7 @@ void QAbstractAnimation::setCurrentTime(int msecs)
// Calculate new time and loop.
int dura = duration();
- int totalDura = (d->loopCount < 0 || dura == -1) ? -1 : dura * d->loopCount;
+ int totalDura = dura <= 0 ? dura : ((d->loopCount < 0) ? -1 : dura * d->loopCount);
if (totalDura != -1)
msecs = qMin(totalDura, msecs);
d->totalCurrentTime = msecs;
diff --git a/src/corelib/animation/qpauseanimation.cpp b/src/corelib/animation/qpauseanimation.cpp
index d90f0013d0..21e5b0849a 100644
--- a/src/corelib/animation/qpauseanimation.cpp
+++ b/src/corelib/animation/qpauseanimation.cpp
@@ -73,7 +73,7 @@ QT_BEGIN_NAMESPACE
class QPauseAnimationPrivate : public QAbstractAnimationPrivate
{
public:
- QPauseAnimationPrivate() : QAbstractAnimationPrivate(), duration(0)
+ QPauseAnimationPrivate() : QAbstractAnimationPrivate(), duration(250)
{
isPause = true;
}
@@ -114,6 +114,7 @@ QPauseAnimation::~QPauseAnimation()
\brief the duration of the pause.
The duration of the pause. The duration should not be negative.
+ The default duration is 250 milliseconds.
*/
int QPauseAnimation::duration() const
{