aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util/qquickbehavior.cpp
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2018-12-12 21:45:03 +0100
committerPaolo Angelelli <paolo.angelelli@qt.io>2018-12-21 19:33:19 +0000
commit92dff998b3bf73ee0ad9d636454379869318975f (patch)
tree0a74f43a415594af31352f540fa2496888f508e8 /src/quick/util/qquickbehavior.cpp
parentfd9d88e3a9f24eb84d029fb9324b4f03ae58ffeb (diff)
Expose the target value in Behaviors
So that nested animation can use it. Change-Id: Ief40cda1dfe1ad9a38cf0d18fbf34456dc36e2ee Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/quick/util/qquickbehavior.cpp')
-rw-r--r--src/quick/util/qquickbehavior.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/quick/util/qquickbehavior.cpp b/src/quick/util/qquickbehavior.cpp
index d024c0099b..76d464e7f8 100644
--- a/src/quick/util/qquickbehavior.cpp
+++ b/src/quick/util/qquickbehavior.cpp
@@ -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())