aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickitemviewtransition.cpp
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2021-10-13 14:10:27 +0200
committerIvan Solovev <ivan.solovev@qt.io>2021-10-14 16:53:03 +0200
commit5339b3eb13f4a175372d46d91e2fc0be3c145344 (patch)
treea51f64eac88292e727a6727b7380b7f0accb8101 /src/quick/items/qquickitemviewtransition.cpp
parentf2eeba67846dbf6fe66066a2296e50b02533e672 (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 <fabian.kosmale@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quick/items/qquickitemviewtransition.cpp')
-rw-r--r--src/quick/items/qquickitemviewtransition.cpp30
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