diff options
author | Leonardo Sobral Cunha <leo.cunha@nokia.com> | 2010-02-11 20:08:02 (GMT) |
---|---|---|
committer | Leonardo Sobral Cunha <leo.cunha@nokia.com> | 2010-02-11 22:48:57 (GMT) |
commit | 5624c360505a11b9380d2d1e47b2b3477ccc229c (patch) | |
tree | ce5a88b4f678a367cc3ca9aa89ef0e9da4bf6710 /src/declarative | |
parent | c3996d0dc64b0815968a86d44866d9fe45de731b (diff) | |
download | Qt-5624c360505a11b9380d2d1e47b2b3477ccc229c.zip Qt-5624c360505a11b9380d2d1e47b2b3477ccc229c.tar.gz Qt-5624c360505a11b9380d2d1e47b2b3477ccc229c.tar.bz2 |
Animations are running by default when used as property source value
When you assign an animation to a property (used as source value),
the animation will automatically start running, which is the most
common behavior for this use case.
Reviewed-by: Michael Brasser
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/util/qmlanimation.cpp | 10 | ||||
-rw-r--r-- | src/declarative/util/qmlanimation_p_p.h | 3 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index ba096b3..abffefe 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -201,7 +201,8 @@ QmlAbstractAnimation::QmlAbstractAnimation(QmlAbstractAnimationPrivate &dd, QObj Animations can also be started and stopped imperatively from JavaScript using the \c start() and \c stop() methods. - By default, animations are not running. + By default, animations are not running. Though, when the animations are assigned to properties, + as property value sources, they are set to running by default. */ bool QmlAbstractAnimation::isRunning() const { @@ -237,6 +238,10 @@ QmlMetaProperty QmlAbstractAnimationPrivate::createProperty(QObject *obj, const void QmlAbstractAnimation::setRunning(bool r) { Q_D(QmlAbstractAnimation); + + if (r == false) + d->avoidPropertyValueSourceStart = true; + if (d->running == r) return; @@ -531,6 +536,9 @@ void QmlAbstractAnimation::setTarget(const QmlMetaProperty &p) Q_D(QmlAbstractAnimation); if (d->userProperty.isNull) d->userProperty = p; + + if (!d->avoidPropertyValueSourceStart) + setRunning(true); } //prepare is called before an animation begins diff --git a/src/declarative/util/qmlanimation_p_p.h b/src/declarative/util/qmlanimation_p_p.h index 2f911b4..d680194 100644 --- a/src/declarative/util/qmlanimation_p_p.h +++ b/src/declarative/util/qmlanimation_p_p.h @@ -205,7 +205,7 @@ public: QmlAbstractAnimationPrivate() : running(false), paused(false), alwaysRunToEnd(false), repeat(false), connectedTimeLine(false), componentComplete(true), startOnCompletion(false), - group(0) {} + avoidPropertyValueSourceStart(false), group(0) {} bool running:1; bool paused:1; @@ -215,6 +215,7 @@ public: bool componentComplete:1; bool startOnCompletion:1; + bool avoidPropertyValueSourceStart:1; void commence(); |