diff options
author | Martin Jones <martin.jones@nokia.com> | 2011-09-28 10:12:08 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-09-28 05:25:55 +0200 |
commit | b081df4a405632da3923f66ec32240c12f4acce9 (patch) | |
tree | e11dc75a00ea96ce0797da72532be30785a48969 /src/declarative/util | |
parent | b3063cc60413e5a84aa37ae808529873e4e9b531 (diff) |
Use QBasicTimer rather than QTimer in SmoothedAnimation
QBasicTimer does the same job for lower cost.
Change-Id: I11d7033b9c456129f3f984c8baafa717f5b25d99
Reviewed-on: http://codereview.qt-project.org/5649
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'src/declarative/util')
-rw-r--r-- | src/declarative/util/qdeclarativesmoothedanimation.cpp | 15 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativesmoothedanimation_p_p.h | 5 |
2 files changed, 14 insertions, 6 deletions
diff --git a/src/declarative/util/qdeclarativesmoothedanimation.cpp b/src/declarative/util/qdeclarativesmoothedanimation.cpp index d306f8ab2b..dd7bfe2231 100644 --- a/src/declarative/util/qdeclarativesmoothedanimation.cpp +++ b/src/declarative/util/qdeclarativesmoothedanimation.cpp @@ -62,9 +62,6 @@ QSmoothedAnimation::QSmoothedAnimation(QObject *parent) reversingMode(QDeclarativeSmoothedAnimation::Eased), initialVelocity(0), trackVelocity(0), initialValue(0), invert(false), finalDuration(-1), lastTime(0) { - delayedStopTimer.setInterval(DELAY_STOP_TIMER_INTERVAL); - delayedStopTimer.setSingleShot(true); - connect(&delayedStopTimer, SIGNAL(timeout()), this, SLOT(stop())); } void QSmoothedAnimation::restart() @@ -82,10 +79,20 @@ void QSmoothedAnimation::updateState(QAbstractAnimation::State newState, QAbstra init(); } +void QSmoothedAnimation::timerEvent(QTimerEvent *event) +{ + if (event->timerId() == delayedStopTimer.timerId()) { + delayedStopTimer.stop(); + stop(); + } else { + QAbstractAnimation::timerEvent(event); + } +} + void QSmoothedAnimation::delayedStop() { if (!delayedStopTimer.isActive()) - delayedStopTimer.start(); + delayedStopTimer.start(DELAY_STOP_TIMER_INTERVAL, this); } int QSmoothedAnimation::duration() const diff --git a/src/declarative/util/qdeclarativesmoothedanimation_p_p.h b/src/declarative/util/qdeclarativesmoothedanimation_p_p.h index 161fb11491..224dc75f2f 100644 --- a/src/declarative/util/qdeclarativesmoothedanimation_p_p.h +++ b/src/declarative/util/qdeclarativesmoothedanimation_p_p.h @@ -61,7 +61,7 @@ #include <qparallelanimationgroup.h> #include <private/qobject_p.h> -#include <QTimer> +#include <QBasicTimer> QT_BEGIN_NAMESPACE @@ -89,6 +89,7 @@ public: protected: virtual void updateCurrentTime(int); virtual void updateState(QAbstractAnimation::State, QAbstractAnimation::State); + virtual void timerEvent(QTimerEvent *); private: qreal easeFollow(qreal); @@ -115,7 +116,7 @@ private: bool recalc(); void delayedStop(); - QTimer delayedStopTimer; + QBasicTimer delayedStopTimer; }; class QDeclarativeSmoothedAnimationPrivate : public QDeclarativePropertyAnimationPrivate |