diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2019-03-21 20:42:38 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2019-03-21 20:42:47 +0100 |
commit | 6767114285db9d0e16dc278d08f231e8561546b4 (patch) | |
tree | 0945902a2242fd7ec0a1f7fd3e6acbb769e723bd /src/quick/util/qquickbehavior.cpp | |
parent | ee076afedccbe1d37306a7972051f84eb036d655 (diff) | |
parent | c32b109e9dea44c6775c2dbf8f164870c1dc8971 (diff) |
Merge remote-tracking branch 'origin/dev' into wip/scenegraphng
Change-Id: Ib5662d80d5b2f58cf4634c54c054545ba9df807e
Diffstat (limited to 'src/quick/util/qquickbehavior.cpp')
-rw-r--r-- | src/quick/util/qquickbehavior.cpp | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/quick/util/qquickbehavior.cpp b/src/quick/util/qquickbehavior.cpp index a562ebd937..76d464e7f8 100644 --- a/src/quick/util/qquickbehavior.cpp +++ b/src/quick/util/qquickbehavior.cpp @@ -57,7 +57,7 @@ class QQuickBehaviorPrivate : public QObjectPrivate, public QAnimationJobChangeL { Q_DECLARE_PUBLIC(QQuickBehavior) public: - QQuickBehaviorPrivate() : animation(0), animationInstance(0), enabled(true), finalized(false) + QQuickBehaviorPrivate() : animation(nullptr), animationInstance(nullptr), enabled(true), finalized(false) , blockRunningChanged(false) {} void animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState) override; @@ -77,7 +77,7 @@ public: \inqmlmodule QtQuick \ingroup qtquick-transitions-animations \ingroup qtquick-interceptors - \brief Defines a default animation for a property change + \brief Defines a default animation for a property change. A Behavior defines the default animation to be applied whenever a particular property value changes. @@ -171,9 +171,28 @@ void QQuickBehavior::setEnabled(bool enabled) emit enabledChanged(); } +/*! + \qmlproperty Variant QtQuick::Behavior::targetValue + + This property holds the target value of the property being controlled by the Behavior. + This value is set by the Behavior before the animation is started. + + \since QtQuick 2.13 +*/ +QVariant QQuickBehavior::targetValue() const +{ + Q_D(const QQuickBehavior); + return d->targetValue; +} + void QQuickBehavior::write(const QVariant &value) { Q_D(QQuickBehavior); + const bool targetValueHasChanged = d->targetValue != value; + if (targetValueHasChanged) { + d->targetValue = value; + emit targetValueChanged(); // emitting the signal here should allow + } // d->enabled to change if scripted by the user. bool bypass = !d->enabled || !d->finalized || QQmlEnginePrivate::designerMode(); if (!bypass) qmlExecuteDeferred(this); @@ -181,16 +200,13 @@ void QQuickBehavior::write(const QVariant &value) if (d->animationInstance) d->animationInstance->stop(); QQmlPropertyPrivate::write(d->property, value, QQmlPropertyData::BypassInterceptor | QQmlPropertyData::DontRemoveBinding); - d->targetValue = value; return; } bool behaviorActive = d->animation->isRunning(); - if (behaviorActive && value == d->targetValue) + if (behaviorActive && !targetValueHasChanged) return; - d->targetValue = value; - if (d->animationInstance && (d->animationInstance->duration() != -1 || d->animationInstance->isRenderThreadProxy()) |