aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/util
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2011-08-04 10:30:46 +1000
committerQt by Nokia <qt-info@nokia.com>2011-08-04 04:25:29 +0200
commit29af49fc979b888f5b5ea20616f3f6da48b009b0 (patch)
treee0f7bbe40a7960ab620ee6d69c2676e763967ba1 /src/declarative/util
parent02a19405aab1df31a40896de3d928d8878402052 (diff)
Add enabled property to Transition.
Task-number: QTBUG-14488 Change-Id: I3619a0d26e99e2c19f50a63013dedc151b07154c Reviewed-on: http://codereview.qt.nokia.com/2591 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src/declarative/util')
-rw-r--r--src/declarative/util/qdeclarativestategroup.cpp2
-rw-r--r--src/declarative/util/qdeclarativetransition.cpp46
-rw-r--r--src/declarative/util/qdeclarativetransition_p.h5
3 files changed, 52 insertions, 1 deletions
diff --git a/src/declarative/util/qdeclarativestategroup.cpp b/src/declarative/util/qdeclarativestategroup.cpp
index c098a38f9c..d52d54bc6e 100644
--- a/src/declarative/util/qdeclarativestategroup.cpp
+++ b/src/declarative/util/qdeclarativestategroup.cpp
@@ -372,6 +372,8 @@ QDeclarativeTransition *QDeclarativeStateGroupPrivate::findTransition(const QStr
for (int ii = 0; !done && ii < transitions.count(); ++ii) {
QDeclarativeTransition *t = transitions.at(ii);
+ if (!t->enabled())
+ continue;
for (int ii = 0; ii < 2; ++ii)
{
if (ii && (!t->reversible() ||
diff --git a/src/declarative/util/qdeclarativetransition.cpp b/src/declarative/util/qdeclarativetransition.cpp
index b63407c66a..45d0721c86 100644
--- a/src/declarative/util/qdeclarativetransition.cpp
+++ b/src/declarative/util/qdeclarativetransition.cpp
@@ -113,7 +113,7 @@ class QDeclarativeTransitionPrivate : public QObjectPrivate
public:
QDeclarativeTransitionPrivate()
: fromState(QLatin1String("*")), toState(QLatin1String("*")),
- reversed(false), reversible(false), endState(0)
+ reversed(false), reversible(false), enabled(true), endState(0)
{
group.trans = this;
}
@@ -122,6 +122,7 @@ public:
QString toState;
bool reversed;
bool reversible;
+ bool enabled;
ParallelAnimationWrapper group;
QDeclarativeTransitionManager *endState;
@@ -319,6 +320,49 @@ void QDeclarativeTransition::setToState(const QString &t)
}
/*!
+ \qmlproperty bool Transition::enabled
+
+ This property holds whether the Transition will be run when moving
+ from the \c from state to the \c to state.
+
+ By default a Transition is enabled.
+
+ Note that in some circumstances disabling a Transition may cause an
+ alternative Transition to be used in its place. In the following
+ example, the generic Transition will be used to animate the change
+ from \c state1 to \c state2, as the more specific Transition has
+ been disabled.
+
+ \qml
+ Item {
+ states: [
+ State { name: "state1" ... }
+ State { name: "state2" ... }
+ ]
+ transitions: [
+ Transition { from: "state1"; to: "state2"; enabled: false ... }
+ Transition { ... }
+ ]
+ }
+ \endqml
+*/
+
+bool QDeclarativeTransition::enabled() const
+{
+ Q_D(const QDeclarativeTransition);
+ return d->enabled;
+}
+
+void QDeclarativeTransition::setEnabled(bool enabled)
+{
+ Q_D(QDeclarativeTransition);
+ if (d->enabled == enabled)
+ return;
+ d->enabled = enabled;
+ emit enabledChanged();
+}
+
+/*!
\qmlproperty list<Animation> Transition::animations
\default
diff --git a/src/declarative/util/qdeclarativetransition_p.h b/src/declarative/util/qdeclarativetransition_p.h
index 115b947109..db102582d2 100644
--- a/src/declarative/util/qdeclarativetransition_p.h
+++ b/src/declarative/util/qdeclarativetransition_p.h
@@ -66,6 +66,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeTransition : public QObject
Q_PROPERTY(QString to READ toState WRITE setToState NOTIFY toChanged)
Q_PROPERTY(bool reversible READ reversible WRITE setReversible NOTIFY reversibleChanged)
Q_PROPERTY(QDeclarativeListProperty<QDeclarativeAbstractAnimation> animations READ animations)
+ Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
Q_CLASSINFO("DefaultProperty", "animations")
Q_CLASSINFO("DeferredPropertyNames", "animations")
@@ -82,6 +83,9 @@ public:
bool reversible() const;
void setReversible(bool);
+ bool enabled() const;
+ void setEnabled(bool enabled);
+
QDeclarativeListProperty<QDeclarativeAbstractAnimation> animations();
void prepare(QDeclarativeStateOperation::ActionList &actions,
@@ -95,6 +99,7 @@ Q_SIGNALS:
void fromChanged();
void toChanged();
void reversibleChanged();
+ void enabledChanged();
};
QT_END_NAMESPACE