diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/animation/qpropertyanimation.cpp | 22 | ||||
-rw-r--r-- | src/corelib/animation/qvariantanimation_p.h | 14 | ||||
-rw-r--r-- | src/gui/animation/qguivariantanimation.cpp | 7 |
3 files changed, 20 insertions, 23 deletions
diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp index edcabaa..9a0c5bc 100644 --- a/src/corelib/animation/qpropertyanimation.cpp +++ b/src/corelib/animation/qpropertyanimation.cpp @@ -49,7 +49,7 @@ by itself as a simple animation class, or as part of more complex animations through QAnimationGroup. - The most common way to use QPropertyAnimation is to construct an instance + The most common way to use QPropertyAnimation is to construct an instance of it by passing a pointer to a QObject or a QWidget, and the name of the property you would like to animate to QPropertyAnimation's constructor. @@ -220,11 +220,20 @@ void QPropertyAnimation::updateCurrentValue(const QVariant &value) /*! \reimp + + If the startValue is not defined when the state of the animation changes from Stopped to Running, + the current property value is used as the initial value for the animation. */ void QPropertyAnimation::updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState) { Q_D(QPropertyAnimation); + + if (!d->target) { + qWarning("QPropertyAnimation::updateState: Changing state of an animation without target"); + return; + } + QVariantAnimation::updateState(oldState, newState); QMutexLocker locker(guardHashLock()); QPropertyAnimationHash * hash = _q_runningAnimations(); @@ -235,20 +244,19 @@ void QPropertyAnimation::updateState(QAbstractAnimation::State oldState, if (oldAnim) { // try to stop the top level group QAbstractAnimation *current = oldAnim; - while(current->group() && current->state() != Stopped) current = current->group(); + while (current->group() && current->state() != Stopped) + current = current->group(); current->stop(); } hash->insert(key, this); - // Initialize start value - // ### review this line below, d->atEnd() ? - // ### avoid entering a state where start value is not set - if (d->target && (d->atBeginning() || d->atEnd())) { + + // update the default start value + if (oldState == Stopped) { d->setDefaultStartValue(d->target->property(d->propertyName.constData())); } } else if (hash->value(key) == this) { hash->remove(key); } - } #include "moc_qpropertyanimation.cpp" diff --git a/src/corelib/animation/qvariantanimation_p.h b/src/corelib/animation/qvariantanimation_p.h index 66910c1..14a3ef6 100644 --- a/src/corelib/animation/qvariantanimation_p.h +++ b/src/corelib/animation/qvariantanimation_p.h @@ -88,18 +88,6 @@ public: return q->d_func(); } - - //some helper functions - bool atBeginning() const - { - return currentTime == 0; - } - - bool atEnd() const - { - return currentTime == duration && currentLoop == (loopCount - 1); - } - void setDefaultStartValue(const QVariant &value); int duration; @@ -109,7 +97,7 @@ public: QVariant currentValue; QVariant defaultStartValue; bool hasStartValue; - + //this is used to keep track of the KeyValue interval in which we currently are struct { diff --git a/src/gui/animation/qguivariantanimation.cpp b/src/gui/animation/qguivariantanimation.cpp index fab377a..ed18caa 100644 --- a/src/gui/animation/qguivariantanimation.cpp +++ b/src/gui/animation/qguivariantanimation.cpp @@ -41,8 +41,6 @@ #ifndef QT_NO_ANIMATION -/*QT_BEGIN_NAMESPACE - #ifdef QT_EXPERIMENTAL_SOLUTION # include "qvariantanimation.h" # include "qvariantanimation_p.h" @@ -51,6 +49,9 @@ #include <private/qvariantanimation_p.h> #endif +#include <QtGui/qcolor.h> + +QT_BEGIN_NAMESPACE template<> Q_INLINE_TEMPLATE QColor _q_interpolate(const QColor &f,const QColor &t, qreal progress) { @@ -74,6 +75,6 @@ static int qUnregisterGuiGetInterpolator() } Q_DESTRUCTOR_FUNCTION(qUnregisterGuiGetInterpolator) -QT_END_NAMESPACE*/ +QT_END_NAMESPACE #endif //QT_NO_ANIMATION |