diff options
author | Ivan Solovev <[email protected]> | 2021-10-13 14:10:27 +0200 |
---|---|---|
committer | Ivan Solovev <[email protected]> | 2021-10-14 16:53:03 +0200 |
commit | 5339b3eb13f4a175372d46d91e2fc0be3c145344 (patch) | |
tree | a51f64eac88292e727a6727b7380b7f0accb8101 /src/quick/items/qquickitemviewtransition.cpp | |
parent | f2eeba67846dbf6fe66066a2296e50b02533e672 (diff) |
StackView: complete animations when using StackView.Immediate transition
The idea behind using StackView.Immediate is to immediately move the
stack view item into the new state without running any animations.
However the preexisting code in QQuickStackViewPrivate::completeTransition
was doing nothing, because the animations didn't have the proper target set.
So they could never be started and/or completed.
As a result, the pushed stack view item could appear at the wrong position
and with the other properties set incorrectly (for example, opacity).
The new code uses the same approach, as in startTransition(), but simplifies
it to execute only the animations.
Instead of actually running the animations, a new
QAbstractAnimationJob::complete() method is added, which simulates the
animation progress by starting the animation, forwarding it to the end, and
completing it. This results in all the properties receiving the correct
values, and the stack view items being shown correctly.
Fixes: QTBUG-96966
Fixes: QTBUG-61496
Pick-to: 6.2
Change-Id: I990a133881c66e3ecb83887c60596a5d45e570d9
Reviewed-by: Fabian Kosmale <[email protected]>
Reviewed-by: Mitch Curtis <[email protected]>
Diffstat (limited to 'src/quick/items/qquickitemviewtransition.cpp')
-rw-r--r-- | src/quick/items/qquickitemviewtransition.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/quick/items/qquickitemviewtransition.cpp b/src/quick/items/qquickitemviewtransition.cpp index b7649c9952..eb0c1483ac 100644 --- a/src/quick/items/qquickitemviewtransition.cpp +++ b/src/quick/items/qquickitemviewtransition.cpp @@ -500,6 +500,36 @@ void QQuickItemViewTransitionableItem::startTransition(QQuickItemViewTransitione clearCurrentScheduledTransition(); } +void QQuickItemViewTransitionableItem::completeTransition(QQuickTransition *quickTransition) +{ + if (nextTransitionType == QQuickItemViewTransitioner::NoTransition) + return; + + if (!prepared) { + qWarning("QQuickViewItem::prepareTransition() not called!"); + return; + } + + if (!item) { + qWarning("No target for transition!"); + return; + } + + if (!transition || transition->m_type != nextTransitionType || transition->m_isTarget != isTransitionTarget) { + if (transition) + RETURN_IF_DELETED(transition->cancel()); + delete transition; + transition = new QQuickItemViewTransitionJob; + } + + QQuickStateOperation::ActionList actions; // not used + QList<QQmlProperty> after; // not used + auto instance = quickTransition->prepare(actions, after, transition, item); + RETURN_IF_DELETED(instance->complete()); + + clearCurrentScheduledTransition(); +} + void QQuickItemViewTransitionableItem::setNextTransition(QQuickItemViewTransitioner::TransitionType type, bool isTargetItem) { // Don't reset nextTransitionToSet - once it is set, it cannot be changed |