summaryrefslogtreecommitdiffstats
path: root/src/corelib/animation
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/animation')
-rw-r--r--src/corelib/animation/qabstractanimation.cpp84
-rw-r--r--src/corelib/animation/qabstractanimation.h2
-rw-r--r--src/corelib/animation/qabstractanimation_p.h10
-rw-r--r--src/corelib/animation/qanimationgroup.h2
-rw-r--r--src/corelib/animation/qanimationgroup_p.h4
-rw-r--r--src/corelib/animation/qparallelanimationgroup.cpp3
-rw-r--r--src/corelib/animation/qparallelanimationgroup.h2
-rw-r--r--src/corelib/animation/qparallelanimationgroup_p.h4
-rw-r--r--src/corelib/animation/qpauseanimation.h2
-rw-r--r--src/corelib/animation/qpropertyanimation.cpp18
-rw-r--r--src/corelib/animation/qpropertyanimation.h2
-rw-r--r--src/corelib/animation/qpropertyanimation_p.h6
-rw-r--r--src/corelib/animation/qsequentialanimationgroup.cpp4
-rw-r--r--src/corelib/animation/qsequentialanimationgroup.h2
-rw-r--r--src/corelib/animation/qsequentialanimationgroup_p.h3
-rw-r--r--src/corelib/animation/qvariantanimation.cpp2
-rw-r--r--src/corelib/animation/qvariantanimation.h4
-rw-r--r--src/corelib/animation/qvariantanimation_p.h4
18 files changed, 78 insertions, 80 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp
index 3720984..1d274c9 100644
--- a/src/corelib/animation/qabstractanimation.cpp
+++ b/src/corelib/animation/qabstractanimation.cpp
@@ -177,17 +177,6 @@ QUnifiedTimer *QUnifiedTimer::instance()
return inst;
}
-void QUnifiedTimer::updateRecentlyStartedAnimations()
-{
- if (animationsToStart.isEmpty())
- return;
-
- animations += animationsToStart;
- updateTimer(); //we make sure we start the timer there
-
- animationsToStart.clear();
-}
-
void QUnifiedTimer::timerEvent(QTimerEvent *event)
{
//this is simply the time we last received a tick
@@ -195,15 +184,16 @@ void QUnifiedTimer::timerEvent(QTimerEvent *event)
if (time.isValid())
lastTick = consistentTiming ? oldLastTick + timingInterval : time.elapsed();
- //we transfer the waiting animations into the "really running" state
- updateRecentlyStartedAnimations();
if (event->timerId() == startStopAnimationTimer.timerId()) {
startStopAnimationTimer.stop();
+ //we transfer the waiting animations into the "really running" state
+ animations += animationsToStart;
+ animationsToStart.clear();
if (animations.isEmpty()) {
animationTimer.stop();
time = QTime();
- } else {
+ } else if (!animationTimer.isActive()) {
animationTimer.start(timingInterval, this);
lastTick = 0;
time.start();
@@ -219,27 +209,19 @@ void QUnifiedTimer::timerEvent(QTimerEvent *event)
}
}
-void QUnifiedTimer::updateTimer()
-{
- //we delay the call to start and stop for the animation timer so that if you
- //stop and start animations in batch you don't stop/start the timer too often.
- if (!startStopAnimationTimer.isActive())
- startStopAnimationTimer.start(0, this); // we delay the actual start of the animation
-}
-
void QUnifiedTimer::registerAnimation(QAbstractAnimation *animation)
{
if (animations.contains(animation) ||animationsToStart.contains(animation))
return;
animationsToStart << animation;
- updateTimer();
+ startStopAnimationTimer.start(0, this); // we delay the check if we should start/stop the global timer
}
void QUnifiedTimer::unregisterAnimation(QAbstractAnimation *animation)
{
animations.removeAll(animation);
animationsToStart.removeAll(animation);
- updateTimer();
+ startStopAnimationTimer.start(0, this); // we delay the check if we should start/stop the global timer
}
@@ -254,8 +236,17 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState)
int oldCurrentLoop = currentLoop;
QAbstractAnimation::Direction oldDirection = direction;
- state = newState;
+ // check if we should Rewind
+ if ((newState == QAbstractAnimation::Paused || newState == QAbstractAnimation::Running)
+ && oldState == QAbstractAnimation::Stopped) {
+ //here we reset the time if needed
+ //we don't call setCurrentTime because this might change the way the animation
+ //behaves: changing the state or changing the current value
+ totalCurrentTime = currentTime =(direction == QAbstractAnimation::Forward) ?
+ 0 : (loopCount == -1 ? q->duration() : q->totalDuration());
+ }
+ state = newState;
QPointer<QAbstractAnimation> guard(q);
guard->updateState(oldState, newState);
@@ -268,36 +259,22 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState)
if (guard)
emit guard->stateChanged(oldState, newState);
- // Enter running state.
switch (state)
{
case QAbstractAnimation::Paused:
case QAbstractAnimation::Running:
- {
- // Rewind
- if (oldState == QAbstractAnimation::Stopped) {
- if (guard) {
- if (direction == QAbstractAnimation::Forward)
- q->setCurrentTime(0);
- else
- q->setCurrentTime(loopCount == -1 ? q->duration() : q->totalDuration());
- }
-
- // Check if the setCurrentTime() function called stop().
- // This can happen for a 0-duration animation
- if (state == QAbstractAnimation::Stopped)
- return;
- }
-
- // Register timer if our parent is not running.
- if (state == QAbstractAnimation::Running && guard) {
- if (!group || group->state() == QAbstractAnimation::Stopped) {
- QUnifiedTimer::instance()->registerAnimation(q);
- }
- } else {
- //new state is paused
- QUnifiedTimer::instance()->unregisterAnimation(q);
+ //this ensures that the value is updated now that the animation is running
+ if(oldState == QAbstractAnimation::Stopped && guard)
+ guard->setCurrentTime(currentTime);
+
+ // Register timer if our parent is not running.
+ if (state == QAbstractAnimation::Running && guard) {
+ if (!group || group->state() == QAbstractAnimation::Stopped) {
+ QUnifiedTimer::instance()->registerAnimation(q);
}
+ } else {
+ //new state is paused
+ QUnifiedTimer::instance()->unregisterAnimation(q);
}
break;
case QAbstractAnimation::Stopped:
@@ -625,8 +602,8 @@ void QAbstractAnimation::start(DeletionPolicy policy)
Q_D(QAbstractAnimation);
if (d->state == Running)
return;
- d->setState(Running);
d->deleteWhenStopped = policy;
+ d->setState(Running);
}
/*!
@@ -648,9 +625,8 @@ void QAbstractAnimation::stop()
/*!
Pauses the animation. When the animation is paused, state() returns Paused.
- The currenttime will remain unchanged until resume() or start() is called.
- If you want to continue from the current time, call resume().
-
+ The value of currentTime will remain unchanged until resume() or start()
+ is called. If you want to continue from the current time, call resume().
\sa start(), state(), resume()
*/
diff --git a/src/corelib/animation/qabstractanimation.h b/src/corelib/animation/qabstractanimation.h
index 8da0935..e4b1fcc 100644
--- a/src/corelib/animation/qabstractanimation.h
+++ b/src/corelib/animation/qabstractanimation.h
@@ -125,7 +125,7 @@ protected:
private:
Q_DISABLE_COPY(QAbstractAnimation)
- Q_DECLARE_SCOPED_PRIVATE(QAbstractAnimation)
+ Q_DECLARE_PRIVATE(QAbstractAnimation)
};
#endif //QT_NO_ANIMATION
diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h
index 00def55..b281aa2 100644
--- a/src/corelib/animation/qabstractanimation_p.h
+++ b/src/corelib/animation/qabstractanimation_p.h
@@ -58,6 +58,8 @@
#include <QtCore/qtimer.h>
#include <private/qobject_p.h>
+#ifndef QT_NO_ANIMATION
+
QT_BEGIN_NAMESPACE
class QAnimationGroup;
@@ -133,11 +135,8 @@ public:
protected:
void timerEvent(QTimerEvent *);
- void updateTimer();
private:
- void updateRecentlyStartedAnimations();
-
QBasicTimer animationTimer, startStopAnimationTimer;
QTime time;
int lastTick;
@@ -147,4 +146,7 @@ private:
};
QT_END_NAMESPACE
-#endif
+
+#endif //QT_NO_ANIMATION
+
+#endif //QABSTRACTANIMATION_P_H
diff --git a/src/corelib/animation/qanimationgroup.h b/src/corelib/animation/qanimationgroup.h
index 5b07524..93c6fb1 100644
--- a/src/corelib/animation/qanimationgroup.h
+++ b/src/corelib/animation/qanimationgroup.h
@@ -76,7 +76,7 @@ protected:
private:
Q_DISABLE_COPY(QAnimationGroup)
- Q_DECLARE_SCOPED_PRIVATE(QAnimationGroup)
+ Q_DECLARE_PRIVATE(QAnimationGroup)
};
#endif //QT_NO_ANIMATION
diff --git a/src/corelib/animation/qanimationgroup_p.h b/src/corelib/animation/qanimationgroup_p.h
index 8e668f0..01252c5 100644
--- a/src/corelib/animation/qanimationgroup_p.h
+++ b/src/corelib/animation/qanimationgroup_p.h
@@ -59,6 +59,8 @@
#include "private/qabstractanimation_p.h"
+#ifndef QT_NO_ANIMATION
+
QT_BEGIN_NAMESPACE
class QAnimationGroupPrivate : public QAbstractAnimationPrivate
@@ -76,4 +78,6 @@ public:
QT_END_NAMESPACE
+#endif //QT_NO_ANIMATION
+
#endif //QANIMATIONGROUP_P_H
diff --git a/src/corelib/animation/qparallelanimationgroup.cpp b/src/corelib/animation/qparallelanimationgroup.cpp
index 5e4b0d2..8aa04a4 100644
--- a/src/corelib/animation/qparallelanimationgroup.cpp
+++ b/src/corelib/animation/qparallelanimationgroup.cpp
@@ -214,7 +214,8 @@ void QParallelAnimationGroup::updateState(QAbstractAnimation::State oldState,
d->connectUncontrolledAnimations();
for (int i = 0; i < d->animations.size(); ++i) {
QAbstractAnimation *animation = d->animations.at(i);
- animation->stop();
+ if (oldState == Stopped)
+ animation->stop();
animation->setDirection(d->direction);
animation->start();
}
diff --git a/src/corelib/animation/qparallelanimationgroup.h b/src/corelib/animation/qparallelanimationgroup.h
index 8422102..07808f1 100644
--- a/src/corelib/animation/qparallelanimationgroup.h
+++ b/src/corelib/animation/qparallelanimationgroup.h
@@ -73,7 +73,7 @@ protected:
private:
Q_DISABLE_COPY(QParallelAnimationGroup)
- Q_DECLARE_SCOPED_PRIVATE(QParallelAnimationGroup)
+ Q_DECLARE_PRIVATE(QParallelAnimationGroup)
Q_PRIVATE_SLOT(d_func(), void _q_uncontrolledAnimationFinished())
};
diff --git a/src/corelib/animation/qparallelanimationgroup_p.h b/src/corelib/animation/qparallelanimationgroup_p.h
index 201eb16..949a9b2 100644
--- a/src/corelib/animation/qparallelanimationgroup_p.h
+++ b/src/corelib/animation/qparallelanimationgroup_p.h
@@ -57,6 +57,8 @@
#include "private/qanimationgroup_p.h"
#include <QtCore/QHash>
+#ifndef QT_NO_ANIMATION
+
QT_BEGIN_NAMESPACE
class QParallelAnimationGroupPrivate : public QAnimationGroupPrivate
@@ -82,4 +84,6 @@ public:
QT_END_NAMESPACE
+#endif //QT_NO_ANIMATION
+
#endif //QPARALLELANIMATIONGROUP_P_H
diff --git a/src/corelib/animation/qpauseanimation.h b/src/corelib/animation/qpauseanimation.h
index b84e940..6907d0a 100644
--- a/src/corelib/animation/qpauseanimation.h
+++ b/src/corelib/animation/qpauseanimation.h
@@ -72,7 +72,7 @@ protected:
private:
Q_DISABLE_COPY(QPauseAnimation)
- Q_DECLARE_SCOPED_PRIVATE(QPauseAnimation)
+ Q_DECLARE_PRIVATE(QPauseAnimation)
};
#endif //QT_NO_ANIMATION
diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp
index 7526a81..5f224aa 100644
--- a/src/corelib/animation/qpropertyanimation.cpp
+++ b/src/corelib/animation/qpropertyanimation.cpp
@@ -100,10 +100,6 @@
QT_BEGIN_NAMESPACE
-typedef QPair<QObject *, QByteArray> QPropertyAnimationPair;
-typedef QHash<QPropertyAnimationPair, QPropertyAnimation*> QPropertyAnimationHash;
-Q_GLOBAL_STATIC(QPropertyAnimationHash, _q_runningAnimations)
-
void QPropertyAnimationPrivate::updateMetaProperty()
{
if (!target || propertyName.isEmpty())
@@ -286,19 +282,21 @@ void QPropertyAnimation::updateState(QAbstractAnimation::State oldState,
QPropertyAnimation *animToStop = 0;
{
- QPropertyAnimationHash * hash = _q_runningAnimations();
- QMutexLocker locker(QMutexPool::globalInstanceGet(hash));
+ QMutexLocker locker(QMutexPool::globalInstanceGet(&staticMetaObject));
+ typedef QPair<QObject *, QByteArray> QPropertyAnimationPair;
+ typedef QHash<QPropertyAnimationPair, QPropertyAnimation*> QPropertyAnimationHash;
+ static QPropertyAnimationHash hash;
QPropertyAnimationPair key(d->target, d->propertyName);
if (newState == Running) {
d->updateMetaProperty();
- animToStop = hash->value(key, 0);
- hash->insert(key, this);
+ animToStop = hash.value(key, 0);
+ hash.insert(key, this);
// update the default start value
if (oldState == Stopped) {
d->setDefaultStartValue(d->target->property(d->propertyName.constData()));
}
- } else if (hash->value(key) == this) {
- hash->remove(key);
+ } else if (hash.value(key) == this) {
+ hash.remove(key);
}
}
diff --git a/src/corelib/animation/qpropertyanimation.h b/src/corelib/animation/qpropertyanimation.h
index 6631f67..e07444c 100644
--- a/src/corelib/animation/qpropertyanimation.h
+++ b/src/corelib/animation/qpropertyanimation.h
@@ -78,7 +78,7 @@ protected:
private:
Q_PRIVATE_SLOT(d_func(), void _q_targetDestroyed())
Q_DISABLE_COPY(QPropertyAnimation)
- Q_DECLARE_SCOPED_PRIVATE(QPropertyAnimation)
+ Q_DECLARE_PRIVATE(QPropertyAnimation)
};
#endif //QT_NO_ANIMATION
diff --git a/src/corelib/animation/qpropertyanimation_p.h b/src/corelib/animation/qpropertyanimation_p.h
index 68b2519..a2ae5ec 100644
--- a/src/corelib/animation/qpropertyanimation_p.h
+++ b/src/corelib/animation/qpropertyanimation_p.h
@@ -58,6 +58,8 @@
#include "private/qvariantanimation_p.h"
+#ifndef QT_NO_ANIMATION
+
QT_BEGIN_NAMESPACE
class QPropertyAnimationPrivate : public QVariantAnimationPrivate
@@ -86,4 +88,6 @@ public:
QT_END_NAMESPACE
-#endif
+#endif //QT_NO_ANIMATION
+
+#endif //QPROPERTYANIMATION_P_H
diff --git a/src/corelib/animation/qsequentialanimationgroup.cpp b/src/corelib/animation/qsequentialanimationgroup.cpp
index 5932e7c..05dc307 100644
--- a/src/corelib/animation/qsequentialanimationgroup.cpp
+++ b/src/corelib/animation/qsequentialanimationgroup.cpp
@@ -269,8 +269,10 @@ QSequentialAnimationGroup::~QSequentialAnimationGroup()
/*!
Adds a pause of \a msecs to this animation group.
- The pause is considered as a special type of animation, thus count() will be
+ The pause is considered as a special type of animation, thus
+ \l{QAnimationGroup::animationCount()}{animationCount} will be
increased by one.
+
\sa insertPauseAt(), QAnimationGroup::addAnimation()
*/
QPauseAnimation *QSequentialAnimationGroup::addPause(int msecs)
diff --git a/src/corelib/animation/qsequentialanimationgroup.h b/src/corelib/animation/qsequentialanimationgroup.h
index 81a7ff5..5d43356 100644
--- a/src/corelib/animation/qsequentialanimationgroup.h
+++ b/src/corelib/animation/qsequentialanimationgroup.h
@@ -83,7 +83,7 @@ protected:
private:
Q_DISABLE_COPY(QSequentialAnimationGroup)
- Q_DECLARE_SCOPED_PRIVATE(QSequentialAnimationGroup)
+ Q_DECLARE_PRIVATE(QSequentialAnimationGroup)
Q_PRIVATE_SLOT(d_func(), void _q_uncontrolledAnimationFinished())
};
diff --git a/src/corelib/animation/qsequentialanimationgroup_p.h b/src/corelib/animation/qsequentialanimationgroup_p.h
index 555b696..8db79a0 100644
--- a/src/corelib/animation/qsequentialanimationgroup_p.h
+++ b/src/corelib/animation/qsequentialanimationgroup_p.h
@@ -56,6 +56,7 @@
#include "qsequentialanimationgroup.h"
#include "private/qanimationgroup_p.h"
+#ifndef QT_NO_ANIMATION
QT_BEGIN_NAMESPACE
@@ -108,4 +109,6 @@ public:
QT_END_NAMESPACE
+#endif //QT_NO_ANIMATION
+
#endif //QSEQUENTIALANIMATIONGROUP_P_H
diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp
index 48e5ec1..fdd98c2 100644
--- a/src/corelib/animation/qvariantanimation.cpp
+++ b/src/corelib/animation/qvariantanimation.cpp
@@ -267,7 +267,7 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress)
localProgress);
qSwap(currentValue, ret);
q->updateCurrentValue(currentValue);
- if ((connectedSignals & changedSignalMask) && currentValue != ret) {
+ if ((connectedSignals[0] & changedSignalMask) && currentValue != ret) {
//the value has changed
emit q->valueChanged(currentValue);
}
diff --git a/src/corelib/animation/qvariantanimation.h b/src/corelib/animation/qvariantanimation.h
index 0afe80f..3e397ca 100644
--- a/src/corelib/animation/qvariantanimation.h
+++ b/src/corelib/animation/qvariantanimation.h
@@ -62,7 +62,7 @@ class Q_CORE_EXPORT QVariantAnimation : public QAbstractAnimation
Q_OBJECT
Q_PROPERTY(QVariant startValue READ startValue WRITE setStartValue)
Q_PROPERTY(QVariant endValue READ endValue WRITE setEndValue)
- Q_PROPERTY(QVariant currentValue READ currentValue NOTIFY currentValueChanged)
+ Q_PROPERTY(QVariant currentValue READ currentValue NOTIFY valueChanged)
Q_PROPERTY(int duration READ duration WRITE setDuration)
Q_PROPERTY(QEasingCurve easingCurve READ easingCurve WRITE setEasingCurve)
@@ -113,7 +113,7 @@ private:
static void registerInterpolator(Interpolator func, int interpolationType);
Q_DISABLE_COPY(QVariantAnimation)
- Q_DECLARE_SCOPED_PRIVATE(QVariantAnimation)
+ Q_DECLARE_PRIVATE(QVariantAnimation)
};
template <typename T>
diff --git a/src/corelib/animation/qvariantanimation_p.h b/src/corelib/animation/qvariantanimation_p.h
index b848e12..69e23dc 100644
--- a/src/corelib/animation/qvariantanimation_p.h
+++ b/src/corelib/animation/qvariantanimation_p.h
@@ -60,6 +60,8 @@
#include "private/qabstractanimation_p.h"
+#ifndef QT_NO_ANIMATION
+
QT_BEGIN_NAMESPACE
class QVariantAnimationPrivate : public QAbstractAnimationPrivate
@@ -120,4 +122,6 @@ template<typename T > inline QVariant _q_interpolateVariant(const T &from, const
QT_END_NAMESPACE
+#endif //QT_NO_ANIMATION
+
#endif //QANIMATION_P_H