113 &UntypedProxyProperty::getter,
114 &UntypedProxyProperty::setter,
115 &UntypedProxyProperty::bindingGetter,
116 &UntypedProxyProperty::bindingSetter,
117 &UntypedProxyProperty::makeBinding,
118 &UntypedProxyProperty::setObserver,
361void QQuickBehavior::write(
const QVariant &value)
364 const bool targetValueHasChanged = d->targetValue != value;
365 if (targetValueHasChanged) {
366 d->targetValue = value;
367 emit targetValueChanged();
369 bool bypass = !d->enabled || !d->finalized || QQmlEnginePrivate::designerMode();
371 qmlExecuteDeferred(
this);
372 if (QQmlData::wasDeleted(d->animation) || bypass) {
373 if (d->animationInstance)
374 d->animationInstance->stop();
375 QQmlPropertyPrivate::write(d->property, value, QQmlPropertyData::BypassInterceptor | QQmlPropertyData::DontRemoveBinding);
379 bool behaviorActive = d->animation->isRunning();
380 if (behaviorActive && !targetValueHasChanged)
383 if (d->animationInstance
384 && (d->animationInstance->duration() != -1
385 || d->animationInstance->isRenderThreadProxy())
386 && !d->animationInstance->isStopped()) {
387 d->blockRunningChanged =
true;
388 d->animationInstance->stop();
392 const QVariant ¤tValue = d->property.read();
397 if (!behaviorActive && d->targetValue == currentValue) {
398 QQmlPropertyPrivate::write(d->property, value, QQmlPropertyData::BypassInterceptor | QQmlPropertyData::DontRemoveBinding);
402 QQuickStateOperation::ActionList actions;
403 QQuickStateAction action;
404 action.property = d->property;
405 action.fromValue = currentValue;
406 action.toValue = value;
409 QList<QQmlProperty> after;
410 auto *newInstance = d->animation->transition(actions, after, QQuickAbstractAnimation::Forward);
411 Q_ASSERT(!newInstance || newInstance != d->animationInstance);
412 delete d->animationInstance;
413 d->animationInstance = newInstance;
415 if (d->animationInstance) {
416 if (d->animation->threadingModel() == QQuickAbstractAnimation::RenderThread)
417 d->animationInstance =
new QQuickAnimatorProxyJob(d->animationInstance, d->animation);
419 d->animationInstance->addAnimationChangeListener(d, QAbstractAnimationJob::StateChange);
420 d->animationInstance->start();
421 d->blockRunningChanged =
false;
424 if (!after.contains(d->property))
425 QQmlPropertyPrivate::write(d->property, value, QQmlPropertyData::BypassInterceptor | QQmlPropertyData::DontRemoveBinding);
437void QQuickBehavior::setTarget(
const QQmlProperty &property)
440 d->property = property;
442 d->animation->setDefaultTarget(property);
444 if (QMetaProperty metaProp = property.property(); metaProp.isBindable()) {
445 QUntypedBindable untypedBindable = metaProp.bindable(property.object());
446 d->propertyProxy = std::make_unique<UntypedProxyProperty>(untypedBindable, d);
447 if (untypedBindable.hasBinding()) {
449 UntypedProxyProperty::bindingSetter(d->propertyProxy.get(), untypedBindable.takeBinding());
453 Q_EMIT targetPropertyChanged();