diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2010-03-24 05:26:23 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2010-03-24 06:10:31 (GMT) |
commit | e3563de2f453697e8640db507ea039166c0b5dc8 (patch) | |
tree | e50d9f1813cf510f1b847fcf2dbe729dc20b1cf6 /src | |
parent | e71d06bc420a837438c72616f88167b4a141b627 (diff) | |
download | Qt-e3563de2f453697e8640db507ea039166c0b5dc8.zip Qt-e3563de2f453697e8640db507ea039166c0b5dc8.tar.gz Qt-e3563de2f453697e8640db507ea039166c0b5dc8.tar.bz2 |
A StateChangeScript should never be run when leaving the state.
For a Transition running in reverse, stop ScriptAction from running any
StateSchageScripts.
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/util/qdeclarativeanimation.cpp | 13 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativeanimation_p_p.h | 3 |
2 files changed, 11 insertions, 5 deletions
diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index 6250132..c17012c 100644 --- a/src/declarative/util/qdeclarativeanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -668,7 +668,7 @@ void QDeclarativeColorAnimation::setTo(const QColor &t) } \endqml - When used as part of a Transition, you could also target a specific + When used as part of a Transition, you can also target a specific StateChangeScript to run using the \c scriptName property. \qml @@ -734,6 +734,9 @@ void QDeclarativeScriptAction::setScript(const QDeclarativeScriptString &script) This property is only valid when ScriptAction is used as part of a transition. If both script and scriptName are set, scriptName will be used. + + \note When using scriptName in a reversible transition, the script will only + be run when the transition is being run forwards. */ QString QDeclarativeScriptAction::stateChangeScriptName() const { @@ -749,6 +752,9 @@ void QDeclarativeScriptAction::setStateChangeScriptName(const QString &name) void QDeclarativeScriptActionPrivate::execute() { + if (hasRunScriptScript && reversing) + return; + QDeclarativeScriptString scriptStr = hasRunScriptScript ? runScriptScript : script; const QString &str = scriptStr.script(); @@ -764,19 +770,18 @@ void QDeclarativeScriptAction::transition(QDeclarativeStateActions &actions, { Q_D(QDeclarativeScriptAction); Q_UNUSED(modified); - Q_UNUSED(direction); d->hasRunScriptScript = false; + d->reversing = (direction == Backward); for (int ii = 0; ii < actions.count(); ++ii) { QDeclarativeAction &action = actions[ii]; if (action.event && action.event->typeName() == QLatin1String("StateChangeScript") && static_cast<QDeclarativeStateChangeScript*>(action.event)->name() == d->name) { - //### how should we handle reverse direction? d->runScriptScript = static_cast<QDeclarativeStateChangeScript*>(action.event)->script(); d->hasRunScriptScript = true; action.actionDone = true; - break; //assumes names are unique + break; //only match one (names should be unique) } } } diff --git a/src/declarative/util/qdeclarativeanimation_p_p.h b/src/declarative/util/qdeclarativeanimation_p_p.h index 55aacfa..decd993 100644 --- a/src/declarative/util/qdeclarativeanimation_p_p.h +++ b/src/declarative/util/qdeclarativeanimation_p_p.h @@ -264,7 +264,7 @@ class QDeclarativeScriptActionPrivate : public QDeclarativeAbstractAnimationPriv Q_DECLARE_PUBLIC(QDeclarativeScriptAction) public: QDeclarativeScriptActionPrivate() - : QDeclarativeAbstractAnimationPrivate(), hasRunScriptScript(false), proxy(this), rsa(0) {} + : QDeclarativeAbstractAnimationPrivate(), hasRunScriptScript(false), reversing(false), proxy(this), rsa(0) {} void init(); @@ -272,6 +272,7 @@ public: QString name; QDeclarativeScriptString runScriptScript; bool hasRunScriptScript; + bool reversing; void execute(); |