diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-05-07 10:44:01 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-05-07 10:44:01 (GMT) |
commit | 8da0e32d111bbada65d60fa26e14ca72211517b6 (patch) | |
tree | 1a988e6a8d4e3673b2676fd178d68a78e8d19341 | |
parent | 81eebfbe01edb002d55c3504cc2558689cf0f936 (diff) | |
parent | a99a849dffc51a76256e880a81e6829c76199559 (diff) | |
download | Qt-8da0e32d111bbada65d60fa26e14ca72211517b6.zip Qt-8da0e32d111bbada65d60fa26e14ca72211517b6.tar.gz Qt-8da0e32d111bbada65d60fa26e14ca72211517b6.tar.bz2 |
Merge branch 'kinetic-animations' into kinetic-statemachine
-rw-r--r-- | src/corelib/animation/qabstractanimation.cpp | 16 | ||||
-rw-r--r-- | src/corelib/animation/qabstractanimation_p.h | 3 | ||||
-rw-r--r-- | src/corelib/animation/qpropertyanimation.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp | 5 |
4 files changed, 21 insertions, 5 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index 440a37d..93ecc73 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -162,7 +162,7 @@ QT_BEGIN_NAMESPACE Q_GLOBAL_STATIC(QThreadStorage<QUnifiedTimer *>, unifiedTimer); -QUnifiedTimer::QUnifiedTimer() : QObject(), lastTick(0) +QUnifiedTimer::QUnifiedTimer() : QObject(), lastTick(0), consistentTimingInterval(0) { } @@ -189,12 +189,22 @@ void QUnifiedTimer::updateRecentlyStartedAnimations() animationsToStart.clear(); } +/* + this allows to haeve a consistent timer interval at each tick from the timer + not taking the real time that passed into account. + Just set this to 0 if you want to get back to a time-driven behaviour. + */ +void QUnifiedTimer::setConsitentTiming(int interval) +{ + consistentTimingInterval = interval; +} + void QUnifiedTimer::timerEvent(QTimerEvent *event) { //this is simply the time we last received a tick - int oldLastTick = lastTick; + const int oldLastTick = lastTick; if (time.isValid()) - lastTick = time.elapsed(); + lastTick = consistentTimingInterval > 0 ? oldLastTick + consistentTimingInterval : time.elapsed(); //we transfer the waiting animations into the "really running" state updateRecentlyStartedAnimations(); diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h index 666e6a7..0e10b9a 100644 --- a/src/corelib/animation/qabstractanimation_p.h +++ b/src/corelib/animation/qabstractanimation_p.h @@ -123,6 +123,8 @@ public: void registerAnimation(QAbstractAnimation *animation); void unregisterAnimation(QAbstractAnimation *animation); + void setConsitentTiming(int interval); + private: void updateRecentlyStartedAnimations(); @@ -130,6 +132,7 @@ private: QBasicTimer animationTimer, startStopAnimationTimer; QTime time; int lastTick; + int consistentTimingInterval; QList<QAbstractAnimation*> animations, animationsToStart; }; diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp index 9a0c5bc..65e2f57 100644 --- a/src/corelib/animation/qpropertyanimation.cpp +++ b/src/corelib/animation/qpropertyanimation.cpp @@ -97,6 +97,8 @@ void QPropertyAnimationPrivate::updateMetaProperty() property = mo->property(propertyIndex); propertyType = property.userType(); } else { + if (!target->dynamicPropertyNames().contains(propertyName)) + qWarning("QPropertyAnimation: you're trying to animate a non-existing property %s of your QObject", propertyName.constData()); hasMetaProperty = 2; } } diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp index f0deab5..2e5fd00 100644 --- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp @@ -624,6 +624,7 @@ QVariant xaxisQPointInterpolator(const QPointF &f, const QPointF &t, qreal progr void tst_QPropertyAnimation::interpolated() { QObject o; + o.setProperty("point", QPointF()); //this will avoid warnings o.setProperty("number", qVariantFromValue<Number>(Number(42))); QCOMPARE(qVariantValue<Number>(o.property("number")), Number(42)); { @@ -649,9 +650,9 @@ void tst_QPropertyAnimation::interpolated() anim.start(); anim.pause(); anim.setCurrentTime(100); - QCOMPARE(o.property("point").toPointF(), QPointF(10, 0)); + QCOMPARE(o.property("point"), QVariant(QPointF(10, 0))); anim.setCurrentTime(500); - QCOMPARE(o.property("point").toPointF(), QPointF(50, 0)); + QCOMPARE(o.property("point"), QVariant(QPointF(50, 0))); } { // unregister it and see if we get back the default behaviour |