diff options
author | Charles Yin <yinyunqiao@gmail.com> | 2012-03-08 00:12:58 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-13 23:50:52 +0100 |
commit | c67ed6887a8ee2fac935d81630b4b77926486c9b (patch) | |
tree | 1b9dff98f2fe8e83927400b3743923db93fa9a42 /src/qml/animations/qabstractanimationjob.cpp | |
parent | c291efff26c13963cf98c127bfa759f89f103e48 (diff) |
More refactoring on animation controller
Add a flag and helper functions for disabling user control in QAbstractAnimationJob
class and make it synchronized with QDeclarativeAnimation class's disableUserControl
flag.
Change-Id: Ifa84ab0c78291941469c33f2cafe5f61ee718b2c
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'src/qml/animations/qabstractanimationjob.cpp')
-rw-r--r-- | src/qml/animations/qabstractanimationjob.cpp | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/src/qml/animations/qabstractanimationjob.cpp b/src/qml/animations/qabstractanimationjob.cpp index a540382847..fecd8fbc5d 100644 --- a/src/qml/animations/qabstractanimationjob.cpp +++ b/src/qml/animations/qabstractanimationjob.cpp @@ -161,6 +161,9 @@ void QQmlAnimationTimer::stopTimer() void QQmlAnimationTimer::registerAnimation(QAbstractAnimationJob *animation, bool isTopLevel) { + if (animation->userControlDisabled()) + return; + QQmlAnimationTimer *inst = instance(true); //we create the instance if needed inst->registerRunningAnimation(animation); if (isTopLevel) { @@ -206,6 +209,8 @@ void QQmlAnimationTimer::unregisterAnimation(QAbstractAnimationJob *animation) void QQmlAnimationTimer::registerRunningAnimation(QAbstractAnimationJob *animation) { + Q_ASSERT(!animation->userControlDisabled()); + if (animation->m_isGroup) return; @@ -217,6 +222,9 @@ void QQmlAnimationTimer::registerRunningAnimation(QAbstractAnimationJob *animati void QQmlAnimationTimer::unregisterRunningAnimation(QAbstractAnimationJob *animation) { + if (animation->userControlDisabled()) + return; + if (animation->m_isGroup) return; @@ -248,20 +256,21 @@ int QQmlAnimationTimer::closestPauseAnimationTimeToFinish() ///////////////////////////////////////////////////////////////////////////////////////////////////////// QAbstractAnimationJob::QAbstractAnimationJob() - : m_isPause(false) - , m_isGroup(false) - , m_loopCount(1) + : m_loopCount(1) , m_group(0) , m_direction(QAbstractAnimationJob::Forward) , m_state(QAbstractAnimationJob::Stopped) , m_totalCurrentTime(0) , m_currentTime(0) , m_currentLoop(0) - , m_hasRegisteredTimer(false) , m_uncontrolledFinishTime(-1) - , m_wasDeleted(0) , m_nextSibling(0) , m_previousSibling(0) + , m_wasDeleted(0) + , m_hasRegisteredTimer(false) + , m_isPause(false) + , m_isGroup(false) + , m_disableUserControl(false) { } @@ -482,6 +491,23 @@ void QAbstractAnimationJob::resume() setState(Running); } +void QAbstractAnimationJob::setEnableUserControl() +{ + m_disableUserControl = false; +} + +bool QAbstractAnimationJob::userControlDisabled() const +{ + return m_disableUserControl; +} + +void QAbstractAnimationJob::setDisableUserControl() +{ + m_disableUserControl = true; + start(); + pause(); +} + void QAbstractAnimationJob::updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState) { |