From f9421abbdf4d2e2be06febf9f75a2b62e6875835 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 16 Nov 2020 16:34:56 +0100 Subject: Add QtQuick.Dialogs [ChangeLog][QtQuickDialogs] Added FileDialog. This is a native FileDialog on platforms that support it, and a non-native Qt Quick FileDialog on platforms that don't. Fixes: QTBUG-87797 Change-Id: Ia3a98b616479b818c96c232a0329750023079642 Reviewed-by: Fabian Kosmale --- tests/manual/dialogs/CMakeLists.txt | 31 +++ tests/manual/dialogs/FileDialogPage.qml | 357 ++++++++++++++++++++++++++++++++ tests/manual/dialogs/StringListView.qml | 79 +++++++ tests/manual/dialogs/Theme.qml | 57 +++++ tests/manual/dialogs/dialogs.cpp | 80 +++++++ tests/manual/dialogs/dialogs.pro | 11 + tests/manual/dialogs/dialogs.qml | 127 ++++++++++++ tests/manual/dialogs/qmldir | 3 + 8 files changed, 745 insertions(+) create mode 100644 tests/manual/dialogs/CMakeLists.txt create mode 100644 tests/manual/dialogs/FileDialogPage.qml create mode 100644 tests/manual/dialogs/StringListView.qml create mode 100644 tests/manual/dialogs/Theme.qml create mode 100644 tests/manual/dialogs/dialogs.cpp create mode 100644 tests/manual/dialogs/dialogs.pro create mode 100644 tests/manual/dialogs/dialogs.qml create mode 100644 tests/manual/dialogs/qmldir (limited to 'tests/manual/dialogs') diff --git a/tests/manual/dialogs/CMakeLists.txt b/tests/manual/dialogs/CMakeLists.txt new file mode 100644 index 00000000..d99d64b9 --- /dev/null +++ b/tests/manual/dialogs/CMakeLists.txt @@ -0,0 +1,31 @@ +if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) + cmake_minimum_required(VERSION 3.16) + project(dialogs LANGUAGES C CXX ASM) + find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) +endif() + +qt_internal_add_manual_test(dialogs + GUI + SOURCES + dialogs.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Qml + Qt::QuickControls2 +) + +# Resources: +set(qmake_immediate_resource_files + "dialogs.qml" + "FileDialogPage.qml" + "StringListView.qml" + "qmldir" + "Theme.qml" +) + +qt_internal_add_resource(dialogs "qmake_immediate" + PREFIX + "/" + FILES + ${qmake_immediate_resource_files} +) diff --git a/tests/manual/dialogs/FileDialogPage.qml b/tests/manual/dialogs/FileDialogPage.qml new file mode 100644 index 00000000..9faad47e --- /dev/null +++ b/tests/manual/dialogs/FileDialogPage.qml @@ -0,0 +1,357 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick +import QtQuick.Controls +import QtQuick.Dialogs +import QtQuick.Layouts + +import "." + +ColumnLayout { + property alias dialog: fileDialog + + // Put it all in another ColumnLayout so we can easily add margins. + ColumnLayout { + Layout.leftMargin: 12 + Layout.rightMargin: 12 + Layout.topMargin: 12 + Layout.bottomMargin: 12 + + GroupBox { + title: qsTr("Dialog properties") + + Layout.fillWidth: true + + GridLayout { + columns: 2 + anchors.fill: parent + + Label { + text: qsTr("modality") + + Layout.alignment: Qt.AlignTop + Layout.minimumWidth: ApplicationWindow.window.width * 0.2 + Layout.maximumWidth: ApplicationWindow.window.width * 0.2 + } + ButtonGroup { + id: modalityButtonGroup + buttons: modalityColumnLayout.children + } + ColumnLayout { + id: modalityColumnLayout + + RadioButton { + text: qsTr("Qt.NonModal") + + readonly property int modality: Qt.NonModal + } + RadioButton { + text: qsTr("Qt.WindowModal") + checked: true + + readonly property int modality: Qt.WindowModal + } + RadioButton { + text: qsTr("Qt.ApplicationModal") + + readonly property int modality: Qt.ApplicationModal + } + } + + Label { + text: qsTr("result") + } + TextField { + id: resultTextField + text: fileDialog.result === 1 ? qsTr("Accepted") : qsTr("Rejected") + readOnly: true + enabled: false + } + + Label { + text: qsTr("title") + } + TextField { + id: titleTextField + text: qsTr("Choose a file") + } + } + } + + GroupBox { + title: qsTr("FileDialog properties") + + Layout.fillWidth: true + + GridLayout { + columns: 2 + anchors.fill: parent + + Label { + text: qsTr("acceptLabel") + + Layout.minimumWidth: ApplicationWindow.window.width * 0.2 + Layout.maximumWidth: ApplicationWindow.window.width * 0.2 + } + TextField { + id: acceptLabelTextField + text: qsTr("OK") + } + + Label { + text: qsTr("currentFile") + } + TextField { + id: currentFileTextField + text: fileDialog.currentFile + readOnly: true + selectByMouse: true + + Layout.fillWidth: true + } + + Label { + text: qsTr("currentFolder") + } + TextField { + id: currentFolderTextField + text: fileDialog.currentFolder + readOnly: true + selectByMouse: true + + Layout.fillWidth: true + } + + Label { + text: qsTr("currentFiles") + + Layout.alignment: Qt.AlignTop + } + StringListView { + id: currentFilesListView + // QTBUG-72906 + model: [].concat(fileDialog.currentFiles) + } + + Label { + text: qsTr("fileOptions") + + Layout.alignment: Qt.AlignTop + } + ColumnLayout { + id: fileOptionsColumnLayout + + CheckBox { + id: dontResolveSymlinksCheckBox + text: qsTr("DontResolveSymlinks") + + readonly property int fileOption: checked ? FileDialog.DontResolveSymlinks : 0 + } + CheckBox { + id: dontConfirmOverwriteCheckBox + text: qsTr("DontConfirmOverwrite") + + readonly property int fileOption: checked ? FileDialog.DontConfirmOverwrite : 0 + } + CheckBox { + id: readOnlyCheckBox + text: qsTr("ReadOnly") + + readonly property int fileOption: checked ? FileDialog.ReadOnly : 0 + } + CheckBox { + id: hideNameFilterDetailsCheckBox + text: qsTr("HideNameFilterDetails") + + readonly property int fileOption: checked ? FileDialog.HideNameFilterDetails : 0 + } + } + + Label { + text: qsTr("fileMode") + + Layout.alignment: Qt.AlignTop + } + ButtonGroup { + id: fileModeButtonGroup + buttons: fileModeColumnLayout.children + } + ColumnLayout { + id: fileModeColumnLayout + + RadioButton { + text: qsTr("OpenFile") + + readonly property int fileMode: FileDialog.OpenFile + } + RadioButton { + text: qsTr("OpenFiles") + checked: true + + readonly property int fileMode: FileDialog.OpenFiles + } + RadioButton { + text: qsTr("SaveFile") + + readonly property int fileMode: FileDialog.SaveFile + } + } + + Label { + text: qsTr("nameFilters") + } + TextField { + id: nameFiltersTextField + text: ["Text files (*.txt)", "HTML files (*.html)"].join(",") + + Layout.fillWidth: true + + ToolTip.text: qsTr("For this example, a comma-separated string") + ToolTip.visible: hovered + ToolTip.delay: Theme.toolTipDelay + } + + Label { + text: qsTr("rejectLabel") + } + TextField { + id: rejectLabelTextField + text: qsTr("Cancel") + } + + Label { + text: qsTr("selectedFile") + } + TextField { + id: selectedFileTextField + text: fileDialog.selectedFile + readOnly: true + selectByMouse: true + + Layout.fillWidth: true + } + + Label { + text: qsTr("selectedFiles") + + Layout.alignment: Qt.AlignTop + } + StringListView { + id: selectedFilesListView + // QTBUG-72906 + model: [].concat(fileDialog.selectedFiles) + } + + Label { + text: qsTr("selectedNameFilter.name") + } + TextField { + id: selectedNameFilterNameTextField + text: fileDialog.selectedNameFilter.name + readOnly: true + selectByMouse: true + + Layout.fillWidth: true + } + + Label { + text: qsTr("selectedNameFilter.globs") + + Layout.alignment: Qt.AlignTop + } + StringListView { + id: selectedNameFilterGlobsListView + // QTBUG-72906 + model: [].concat(fileDialog.selectedNameFilter.globs) + } + + Label { + text: qsTr("selectedNameFilter.index") + } + TextField { + id: selectedNameFilterIndexTextField + text: fileDialog.selectedNameFilter.index + readOnly: true + selectByMouse: true + + Layout.fillWidth: true + } + + Label { + text: qsTr("selectedNameFilter.extensions") + + Layout.alignment: Qt.AlignTop + } + StringListView { + id: selectedNameFilterExtensionsListView + // QTBUG-72906 + model: [].concat(fileDialog.selectedNameFilter.extensions) + } + } + } + + FileDialog { + id: fileDialog + + modality: modalityButtonGroup.checkedButton.modality + title: titleTextField.text + + acceptLabel: acceptLabelTextField.text + fileMode: fileModeButtonGroup.checkedButton.fileMode + options: dontResolveSymlinksCheckBox.fileOption + | dontConfirmOverwriteCheckBox.fileOption + | readOnlyCheckBox.fileOption + | hideNameFilterDetailsCheckBox.fileOption + nameFilters: nameFiltersTextField.text.split(",") + rejectLabel: rejectLabelTextField.text + } + } +} diff --git a/tests/manual/dialogs/StringListView.qml b/tests/manual/dialogs/StringListView.qml new file mode 100644 index 00000000..4a229404 --- /dev/null +++ b/tests/manual/dialogs/StringListView.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts + +import "." + +ListView { + id: root + clip: true + boundsBehavior: Flickable.StopAtBounds + + Layout.fillWidth: true + Layout.preferredHeight: count > 0 ? 128 : noneLabel.implicitHeight + + ScrollBar.vertical: ScrollBar {} + + delegate: TextField { + width: root.width + text: modelData + readOnly: true + selectByMouse: true + } + + Label { + id: noneLabel + text: qsTr("(None)") + visible: root.count === 0 + } +} diff --git a/tests/manual/dialogs/Theme.qml b/tests/manual/dialogs/Theme.qml new file mode 100644 index 00000000..8114f14e --- /dev/null +++ b/tests/manual/dialogs/Theme.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +pragma Singleton + +import QtQml + +QtObject { + readonly property int toolTipDelay: 1000 +} diff --git a/tests/manual/dialogs/dialogs.cpp b/tests/manual/dialogs/dialogs.cpp new file mode 100644 index 00000000..8bab70e2 --- /dev/null +++ b/tests/manual/dialogs/dialogs.cpp @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QCoreApplication::setApplicationName("dialogs-manual-test"); + QCoreApplication::setOrganizationName("QtProject"); + + // Use native dialogs by default unless the user asked us not to. + QSettings settings; + const QVariant useNativeDialogs = settings.value("useNativeDialogs"); + if (useNativeDialogs.isValid()) { + if (!useNativeDialogs.toBool()) + QCoreApplication::setAttribute(Qt::AA_DontUseNativeDialogs); + } else { + // Set the default here so that we can use an alias in QML. + // Without this it defaults to CheckBox's checked default value, which is false. + settings.setValue("useNativeDialogs", true); + } + + QQmlApplicationEngine engine; + engine.setInitialProperties({{ "style", QQuickStyle::name() }}); + engine.load(QUrl(QStringLiteral("qrc:/dialogs.qml"))); + + return app.exec(); +} diff --git a/tests/manual/dialogs/dialogs.pro b/tests/manual/dialogs/dialogs.pro new file mode 100644 index 00000000..abb31492 --- /dev/null +++ b/tests/manual/dialogs/dialogs.pro @@ -0,0 +1,11 @@ +TEMPLATE = app +TARGET = dialogs +QT += qml quickcontrols2 + +SOURCES += dialogs.cpp +RESOURCES += \ + dialogs.qml \ + FileDialogPage.qml \ + StringListView.qml \ + qmldir \ + Theme.qml diff --git a/tests/manual/dialogs/dialogs.qml b/tests/manual/dialogs/dialogs.qml new file mode 100644 index 00000000..d1f54c08 --- /dev/null +++ b/tests/manual/dialogs/dialogs.qml @@ -0,0 +1,127 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts + +import Qt.labs.settings + +ApplicationWindow { + id: window + width: 800 + height: 600 + title: "dialogs - style: " + style + visible: true + + required property string style + + Component.onCompleted: { + x = Screen.width / 2 - width / 2 + y = Screen.height / 2 - height / 2 + } + + Settings { + id: settings + + property alias useNativeDialogs: useNativeDialogsCheckBox.checked + } + + Page { + anchors.fill: parent + + header: TabBar { + id: tabBar + + TabButton { + text: qsTr("FileDialog") + } + TabButton { + text: qsTr("Coming Soon...") + } + } + + ScrollView { + id: scrollView + anchors.fill: parent + clip: true + + StackLayout { + id: stackLayout + currentIndex: tabBar.currentIndex + width: scrollView.width + + FileDialogPage {} + } + } + } + + footer: ToolBar { + RowLayout { + anchors.fill: parent + + CheckBox { + id: useNativeDialogsCheckBox + text: qsTr("Use Native Dialogs (requires restart)") + checked: settings.useNativeDialogs + } + + Item { + Layout.fillWidth: true + } + + Button { + text: qsTr("Open") + + onClicked: stackLayout.children[stackLayout.currentIndex].dialog.open() + } + } + } +} diff --git a/tests/manual/dialogs/qmldir b/tests/manual/dialogs/qmldir new file mode 100644 index 00000000..4f4a6b7b --- /dev/null +++ b/tests/manual/dialogs/qmldir @@ -0,0 +1,3 @@ +module org.qtproject.examples.dialogs + +singleton Theme 1.0 Theme.qml -- cgit v1.2.3