aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/controls/data/tst_dialogbuttonbox.qml
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-11-08 14:56:29 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2018-02-22 14:59:37 +0000
commitf1f884d353c5a9190e200cc04e94d4658c69a23b (patch)
tree23d3d44ab447842dca6b9c22b6bf12c887ccd151 /tests/auto/controls/data/tst_dialogbuttonbox.qml
parente80d273e6f19ba0a6a0f4e830724a36785ef19f6 (diff)
DialogButtonBox: workaround implicit size calculation with one buttonv5.11.0-beta1
When there's only one button in the dialog button box, the Default and Universal styles resize the button to cover half of the button box. This works in typical scenarios when the dialog button box is assigned as a footer of a dialog, and thus, gets resized together with the dialog. However, if the dialog button box is placed into a layout, or otherwise not given an explicit size, the implicit size calculation loops until it reaches zero. 1) button box gets the implicit size of the content (one button) 2) button box resizes the button to cover half of the box width 3) button box re-calculates its implicit size => step 1 Avoid the problem by providing a reasonable hard-coded implicit size for this special case. Notice that this is just a temporary workaround to avoid the problem. This can be fixed properly in dev by providing separate contentWidth and contentHeight properties that cleanly propagate the content size to QML. Task-number: QTBUG-59719 Change-Id: I552e0824ae6bff26b570c699252a3e4f09bd3397 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/controls/data/tst_dialogbuttonbox.qml')
-rw-r--r--tests/auto/controls/data/tst_dialogbuttonbox.qml28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_dialogbuttonbox.qml b/tests/auto/controls/data/tst_dialogbuttonbox.qml
index 044c9593..6faf0db4 100644
--- a/tests/auto/controls/data/tst_dialogbuttonbox.qml
+++ b/tests/auto/controls/data/tst_dialogbuttonbox.qml
@@ -195,4 +195,32 @@ TestCase {
compare(clickedSpy.signalArguments[0][0], button)
compare(roleSpy.count, 1)
}
+
+ function test_implicitSize_data() {
+ return [
+ { tag: "Ok", standardButtons: DialogButtonBox.Ok },
+ { tag: "Yes|No", standardButtons: DialogButtonBox.Yes | DialogButtonBox.No }
+ ]
+ }
+
+ // QTBUG-59719
+ function test_implicitSize(data) {
+ var control = createTemporaryObject(buttonBox, testCase, {standardButtons: data.standardButtons})
+ verify(control)
+
+ var listView = control.contentItem
+ verify(listView && listView.hasOwnProperty("contentWidth"))
+ waitForRendering(listView)
+
+ var implicitContentWidth = control.leftPadding + control.rightPadding
+ for (var i = 0; i < listView.contentItem.children.length; ++i) {
+ var button = listView.contentItem.children[i]
+ if (!button.hasOwnProperty("text"))
+ continue
+ implicitContentWidth += button.implicitWidth
+ }
+
+ verify(implicitContentWidth > control.leftPadding + control.rightPadding)
+ verify(control.implicitWidth >= implicitContentWidth, qsTr("implicit width (%1) is less than content width (%2)").arg(control.implicitWidth).arg(implicitContentWidth))
+ }
}