aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quickdialogs/qquickcolordialogimpl/data/colorDialogWithoutWindowVisibleTrue.qml
diff options
context:
space:
mode:
authorOliver Eftevaag <oliver.eftevaag@qt.io>2022-09-15 19:18:09 +0200
committerOliver Eftevaag <oliver.eftevaag@qt.io>2024-01-17 10:12:18 +0100
commit4369353527abd987a788943d52104de06c19f2db (patch)
tree72740dd77ca6a2f900340c9648f2396f5b6e195c /tests/auto/quickdialogs/qquickcolordialogimpl/data/colorDialogWithoutWindowVisibleTrue.qml
parent45e24489171adf2f3379424079728852522f3424 (diff)
Dialogs: Defer automatic window resolving until dialog is opened
The qml tool, as well as the QQuickView class are creating their own window outside of the root qml file that is passed to them. This caused an issue where no dialog were able to find a window when componentComplete() was first called, which would make them return early in the QPlatformDialogHelper::show() re-implementations, and thus never show the dialogs when open() was called. This patch solves the issue by waiting until open() is called, before trying to find a window in any of the parent items. Since Window always has a contentItem, it was also possible to simplify the logic that searches for a window, by only trying to cast the parent to QQuickItem*. Another issue that came up, was the fact that dialogs with visible set to true, aka: FileDialog { visible: true } Should open as soon as possible upon its creation. To get around this, open() is called during componentComplete() if a window can be found during this time. Otherwise, the call to open() is deferred until the nearest parent item emits the windowChanged() signal. Note that calling setParentWindow() will now take priority over the implicit window search, unless the argument for setParentWindow is null. Meaning that moving a dialog to a different window, by modifying parents, will not happen for dialogs that are explicitly binding a value to parentWindow. Fixes: QTBUG-106598 Pick-to: 6.5 Change-Id: Idd7c0ecdeea6cbf26e8d41168788563ee9794118 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit f233a5ff9d04daf3ba792cc196da7e5f190b415c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit ba596daec67fb41d87d6c4a0b31f215fc0a1359d)
Diffstat (limited to 'tests/auto/quickdialogs/qquickcolordialogimpl/data/colorDialogWithoutWindowVisibleTrue.qml')
-rw-r--r--tests/auto/quickdialogs/qquickcolordialogimpl/data/colorDialogWithoutWindowVisibleTrue.qml28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/quickdialogs/qquickcolordialogimpl/data/colorDialogWithoutWindowVisibleTrue.qml b/tests/auto/quickdialogs/qquickcolordialogimpl/data/colorDialogWithoutWindowVisibleTrue.qml
new file mode 100644
index 0000000000..b146d61513
--- /dev/null
+++ b/tests/auto/quickdialogs/qquickcolordialogimpl/data/colorDialogWithoutWindowVisibleTrue.qml
@@ -0,0 +1,28 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Dialogs
+
+Rectangle {
+ width: 480
+ height: 640
+ color: dialog.selectedColor
+
+ property alias dialog: dialog
+
+ function doneAccepted() {
+ dialog.done(ColorDialog.Accepted)
+ }
+
+ function doneRejected() {
+ dialog.done(ColorDialog.Rejected)
+ }
+
+ ColorDialog {
+ id: dialog
+ objectName: "ColorDialog"
+ visible: true
+ }
+}