aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2020-08-07 15:05:23 +0200
committerMitch Curtis <mitch.curtis@qt.io>2021-01-14 10:29:23 +0100
commit83f49d3f4c0041bf2c74ff1ff2eb03c5d37aa1f4 (patch)
tree3130df827a1c5de85c794267e5fd980d6d13229d /tests/auto
parent10bfc067d005d6156ba549f581fb2394c4ff8ef1 (diff)
SwipeDelegate: ensure background and contentItem are resized
When the geometry of a control changes, this code is called: void QQuickControl::geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) { Q_D(QQuickControl); QQuickItem::geometryChange(newGeometry, oldGeometry); d->resizeBackground(); d->resizeContent(); if (!qFuzzyCompare(newGeometry.width(), oldGeometry.width())) emit availableWidthChanged(); if (!qFuzzyCompare(newGeometry.height(), oldGeometry.height())) emit availableHeightChanged(); } SwipeDelegate works by moving the background and contentItem together when it is swiped to expose the various delegates. Because this involves setting the position of the background, the check for background's x position being 0 in QQuickControlPrivate::resizeBackground() would fail and the background would not be resized at all. Fix this by making resizeBackground() virtual and don't check the x when checking if we should set the width. Similarly, in QQuickSwipeDelegatePrivate::resizeContent(), we should set the contentItem's width instead of just repositioning and resizing it vertically. Fixes: QTBUG-85770 Pick-to: 5.15 6.0 Change-Id: I36684bf2797719db87fe93063cc7685efe594eea Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/controls/data/tst_swipedelegate.qml35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_swipedelegate.qml b/tests/auto/controls/data/tst_swipedelegate.qml
index 6788e67a..78483406 100644
--- a/tests/auto/controls/data/tst_swipedelegate.qml
+++ b/tests/auto/controls/data/tst_swipedelegate.qml
@@ -1713,4 +1713,39 @@ TestCase {
break;
}
}
+
+ function test_resizeParent() {
+ let container = createTemporaryObject(itemComponent, testCase, { objectName: "container", width: 100, height: 200 })
+ verify(container)
+
+ let control = swipeDelegateComponent.createObject(container, { width: Qt.binding(function() { return container.width }) })
+ verify(control)
+
+ // Resize while closed.
+ container.width = 200
+ compare(container.width, 200)
+ compare(control.width, 200)
+ compare(control.background.width, 200)
+ compare(control.contentItem.width, 200 - control.leftPadding - control.rightPadding)
+
+ // Return to original size.
+ container.width = 100
+ compare(control.width, 100)
+ compare(control.background.width, 100)
+ compare(control.contentItem.width, 100 - control.leftPadding - control.rightPadding)
+
+ // Swipe to the left to open.
+ swipe(control, 0, -1.0)
+ // Nothing should have changed except positions.
+ compare(control.width, 100)
+ compare(control.background.width, 100)
+ compare(control.contentItem.width, 100 - control.leftPadding - control.rightPadding)
+
+ // Resize while open.
+ container.width = 200
+ // The items should fill the width as usual.
+ compare(control.width, 200)
+ compare(control.background.width, 200)
+ compare(control.contentItem.width, 200 - control.leftPadding - control.rightPadding)
+ }
}