diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2016-02-06 10:28:53 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2016-02-11 12:48:19 +0000 |
commit | 084dbb06d7b00c4a67edb6ce58956150036c35f2 (patch) | |
tree | 2a43e4a1db019fee4e869b69669bb463500aff1f /src | |
parent | 983a85e2222c0ed8e3e9bc0a8d03c28889952331 (diff) |
Fix Animators in itemview and positioner transitions
In itemview/positioner transitions, Animator's target-property is never
explicitly set. QQuickItemViewTransition passes the animation target as
a "default target" instead. This change adds missing handling for the
default target.
QQuickItemViewTransition sets up default "x" and "y" state actions.
If Animator drives opacity, scale, or basically anything else than x/y
animations, it failed to extract the from/to values from the state
action list.
This change fixes the issue that if the default state actions do not
match the animator property (x/y vs. scale/opacity), it uses from/to
values specified on the animator itself. Before, it did that only if
the default state action list was empty. This is not the case with
itemview/positioner transitions.
Change-Id: I0f15e20bc860ddec23e59efebbc9cd346317f4de
Task-number: QTBUG-50908
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/quick/util/qquickanimator.cpp | 19 | ||||
-rw-r--r-- | src/quick/util/qquickanimator_p_p.h | 2 |
2 files changed, 14 insertions, 7 deletions
diff --git a/src/quick/util/qquickanimator.cpp b/src/quick/util/qquickanimator.cpp index 8a5cad4011..ca6dc74519 100644 --- a/src/quick/util/qquickanimator.cpp +++ b/src/quick/util/qquickanimator.cpp @@ -211,7 +211,8 @@ qreal QQuickAnimator::from() const void QQuickAnimatorPrivate::apply(QQuickAnimatorJob *job, const QString &propertyName, QQuickStateActions &actions, - QQmlProperties &modified) + QQmlProperties &modified, + QObject *defaultTarget) { if (actions.size()) { @@ -243,14 +244,20 @@ void QQuickAnimatorPrivate::apply(QQuickAnimatorJob *job, // the item when a transition is cancelled. action.fromValue = action.toValue; } - } else { + } + + if (modified.isEmpty()) { job->setTarget(target); job->setFrom(from); job->setTo(to); } - if (!job->target() && defaultProperty.object()) - job->setTarget(qobject_cast<QQuickItem *>(defaultProperty.object())); + if (!job->target()) { + if (defaultProperty.object()) + job->setTarget(qobject_cast<QQuickItem *>(defaultProperty.object())); + else + job->setTarget(qobject_cast<QQuickItem *>(defaultTarget)); + } job->setDuration(duration); job->setLoopCount(loopCount); @@ -260,7 +267,7 @@ void QQuickAnimatorPrivate::apply(QQuickAnimatorJob *job, QAbstractAnimationJob *QQuickAnimator::transition(QQuickStateActions &actions, QQmlProperties &modified, TransitionDirection direction, - QObject *) + QObject *defaultTarget) { Q_D(QQuickAnimator); @@ -277,7 +284,7 @@ QAbstractAnimationJob *QQuickAnimator::transition(QQuickStateActions &actions, if (!job) return 0; - d->apply(job, propertyName(), actions, modified); + d->apply(job, propertyName(), actions, modified, defaultTarget); if (!job->target()) { delete job; diff --git a/src/quick/util/qquickanimator_p_p.h b/src/quick/util/qquickanimator_p_p.h index f5f0295f74..11598bf78e 100644 --- a/src/quick/util/qquickanimator_p_p.h +++ b/src/quick/util/qquickanimator_p_p.h @@ -76,7 +76,7 @@ public: uint isFromDefined : 1; uint isToDefined : 1; - void apply(QQuickAnimatorJob *job, const QString &propertyName, QQuickStateActions &actions, QQmlProperties &modified); + void apply(QQuickAnimatorJob *job, const QString &propertyName, QQuickStateActions &actions, QQmlProperties &modified, QObject *defaultTarget); }; class QQuickRotationAnimatorPrivate : public QQuickAnimatorPrivate |