diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-04-28 11:45:23 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-04-29 06:29:47 (GMT) |
commit | 6293521a6e5ee0ce010180a40e6fda3ef3a8b245 (patch) | |
tree | 49b7fe5aa6a850e1a8c9157f0c1cd891e1449836 /src | |
parent | 4f6b9b1779fe33f876f96c196c3feef7e72992a0 (diff) | |
download | Qt-6293521a6e5ee0ce010180a40e6fda3ef3a8b245.zip Qt-6293521a6e5ee0ce010180a40e6fda3ef3a8b245.tar.gz Qt-6293521a6e5ee0ce010180a40e6fda3ef3a8b245.tar.bz2 |
add animationsEnabled property
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/statemachine/qstatemachine.cpp | 47 | ||||
-rw-r--r-- | src/corelib/statemachine/qstatemachine.h | 6 | ||||
-rw-r--r-- | src/corelib/statemachine/qstatemachine_p.h | 2 |
3 files changed, 47 insertions, 8 deletions
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index 1434bc0..8d5317a 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -177,6 +177,14 @@ QT_BEGIN_NAMESPACE \brief the error string of this state machine */ +#ifndef QT_NO_ANIMATION +/*! + \property QStateMachine::animationsEnabled + + \brief whether animations are enabled +*/ +#endif + // #define QSTATEMACHINE_DEBUG QStateMachinePrivate::QStateMachinePrivate() @@ -192,6 +200,9 @@ QStateMachinePrivate::QStateMachinePrivate() #ifndef QT_STATEMACHINE_SOLUTION signalEventGenerator = 0; #endif +#ifndef QT_NO_ANIMATION + animationsEnabled = true; +#endif } QStateMachinePrivate::~QStateMachinePrivate() @@ -622,17 +633,19 @@ void QStateMachinePrivate::applyProperties(const QList<QAbstractTransition*> &tr // Find the animations to use for the state change. QList<QAbstractAnimation*> selectedAnimations; - for (int i = 0; i < transitionList.size(); ++i) { - QAbstractTransition *transition = transitionList.at(i); + if (animationsEnabled) { + for (int i = 0; i < transitionList.size(); ++i) { + QAbstractTransition *transition = transitionList.at(i); - selectedAnimations << transition->animations(); - selectedAnimations << defaultAnimationsForSource.values(transition->sourceState()); + selectedAnimations << transition->animations(); + selectedAnimations << defaultAnimationsForSource.values(transition->sourceState()); - QList<QAbstractState *> targetStates = transition->targetStates(); - for (int j=0; j<targetStates.size(); ++j) - selectedAnimations << defaultAnimationsForTarget.values(targetStates.at(j)); + QList<QAbstractState *> targetStates = transition->targetStates(); + for (int j=0; j<targetStates.size(); ++j) + selectedAnimations << defaultAnimationsForTarget.values(targetStates.at(j)); + } + selectedAnimations << defaultAnimations; } - selectedAnimations << defaultAnimations; #else Q_UNUSED(transitionList); #endif @@ -1866,6 +1879,24 @@ void QStateMachine::endMicrostep(QEvent *event) #ifndef QT_NO_ANIMATION /*! + Returns whether animations are enabled for this state machine. +*/ +bool QStateMachine::animationsEnabled() const +{ + Q_D(const QStateMachine); + return d->animationsEnabled; +} + +/*! + Sets whether animations are \a enabled for this state machine. +*/ +void QStateMachine::setAnimationsEnabled(bool enabled) +{ + Q_D(QStateMachine); + d->animationsEnabled = enabled; +} + +/*! Adds a default \a animation to be considered for any transition. */ void QStateMachine::addDefaultAnimation(QAbstractAnimation *animation) diff --git a/src/corelib/statemachine/qstatemachine.h b/src/corelib/statemachine/qstatemachine.h index 9a7a6fc..3ad215b 100644 --- a/src/corelib/statemachine/qstatemachine.h +++ b/src/corelib/statemachine/qstatemachine.h @@ -74,6 +74,9 @@ class Q_CORE_EXPORT QStateMachine : public QObject Q_PROPERTY(QString errorString READ errorString) Q_PROPERTY(RestorePolicy globalRestorePolicy READ globalRestorePolicy WRITE setGlobalRestorePolicy) Q_ENUMS(RestorePolicy) +#ifndef QT_NO_ANIMATION + Q_PROPERTY(bool animationsEnabled READ animationsEnabled WRITE setAnimationsEnabled) +#endif public: enum RestorePolicy { DoNotRestoreProperties, @@ -105,6 +108,9 @@ public: void clearError(); #ifndef QT_NO_ANIMATION + bool animationsEnabled() const; + void setAnimationsEnabled(bool enabled); + void addDefaultAnimation(QAbstractAnimation *animation); QList<QAbstractAnimation *> defaultAnimations() const; void removeDefaultAnimation(QAbstractAnimation *animation); diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h index 323473d..bb58edc 100644 --- a/src/corelib/statemachine/qstatemachine_p.h +++ b/src/corelib/statemachine/qstatemachine_p.h @@ -179,6 +179,8 @@ public: QAbstractState *initialErrorStateForRoot; #ifndef QT_NO_ANIMATION + bool animationsEnabled; + QPair<QList<QAbstractAnimation*>, QList<QAbstractAnimation*> > initializeAnimation(QAbstractAnimation *abstractAnimation, const QPropertyAssignment &prop); |