diff options
author | Shawn Rutledge <shawn.rutledge@digia.com> | 2013-12-16 15:22:14 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-03 17:02:18 +0100 |
commit | ba9ba084124403bd8930e29d8afcea9d64b6c0b6 (patch) | |
tree | e8c3a10eeaef753cf3c65673556bbd7f663933aa /examples | |
parent | c34ce66f7b3dc7cb46d14181d46e438536a4d5f2 (diff) | |
download | qtquickcontrols-ba9ba084124403bd8930e29d8afcea9d64b6c0b6.tar.gz |
move QtQuick.Dialogs from qtdeclarative to qtquickcontrols
This will enable using Controls in the QML dialog implementations.
For now, Controls are used only as drop-in replacements for the
Button, Checkbox, and TextField which were custom implementations
in the qtdeclarative module before.
Change-Id: Ic79e9e8e5715a72ce51f4c724bfdfd33653300f2
Reviewed-by: Liang Qi <liang.qi@digia.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/examples.pro | 1 | ||||
-rw-r--r-- | examples/quick/dialogs/dialogs.pro | 4 | ||||
-rw-r--r-- | examples/quick/dialogs/systemdialogs/ColorDialogs.qml | 145 | ||||
-rw-r--r-- | examples/quick/dialogs/systemdialogs/FileDialogs.qml | 185 | ||||
-rw-r--r-- | examples/quick/dialogs/systemdialogs/FontDialogs.qml | 152 | ||||
-rw-r--r-- | examples/quick/dialogs/systemdialogs/MessageDialogs.qml | 307 | ||||
-rw-r--r-- | examples/quick/dialogs/systemdialogs/doc/images/systemdialogs-example.jpg | bin | 0 -> 47413 bytes | |||
-rw-r--r-- | examples/quick/dialogs/systemdialogs/doc/src/systemdialogs.qdoc | 48 | ||||
-rw-r--r-- | examples/quick/dialogs/systemdialogs/main.cpp | 49 | ||||
-rw-r--r-- | examples/quick/dialogs/systemdialogs/systemdialogs.pro | 18 | ||||
-rw-r--r-- | examples/quick/dialogs/systemdialogs/systemdialogs.qml | 71 | ||||
-rw-r--r-- | examples/quick/dialogs/systemdialogs/systemdialogs.qrc | 9 |
12 files changed, 989 insertions, 0 deletions
diff --git a/examples/examples.pro b/examples/examples.pro index 505dc0c2..266358ca 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -1,3 +1,4 @@ TEMPLATE = subdirs SUBDIRS += quick/controls +SUBDIRS += quick/dialogs diff --git a/examples/quick/dialogs/dialogs.pro b/examples/quick/dialogs/dialogs.pro new file mode 100644 index 00000000..538e7568 --- /dev/null +++ b/examples/quick/dialogs/dialogs.pro @@ -0,0 +1,4 @@ +TEMPLATE = subdirs + +SUBDIRS = \ + systemdialogs diff --git a/examples/quick/dialogs/systemdialogs/ColorDialogs.qml b/examples/quick/dialogs/systemdialogs/ColorDialogs.qml new file mode 100644 index 00000000..08c3ffe9 --- /dev/null +++ b/examples/quick/dialogs/systemdialogs/ColorDialogs.qml @@ -0,0 +1,145 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc and its Subsidiary(-ies) 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 2.0 +import QtQuick.Controls 1.1 +import QtQuick.Dialogs 1.1 + +Item { + width: 320 + height: 240 + SystemPalette { id: palette } + clip: true + + //! [colordialog] + ColorDialog { + id: colorDialog + visible: colorDialogVisible.checked + modality: colorDialogModal.checked ? Qt.WindowModal : Qt.NonModal + title: "Choose a color" + color: "green" + showAlphaChannel: colorDialogAlpha.checked + onAccepted: { console.log("Accepted: " + color) } + onRejected: { console.log("Rejected") } + } + //! [colordialog] + + Column { + anchors.fill: parent + anchors.margins: 12 + spacing: 8 + Text { + font.bold: true + text: "Color dialog properties:" + } + CheckBox { + id: colorDialogModal + text: "Modal" + checked: true + Binding on checked { value: colorDialog.modality != Qt.NonModal } + } + CheckBox { + id: colorDialogAlpha + text: "Show alpha channel" + Binding on checked { value: colorDialog.showAlphaChannel } + } + CheckBox { + id: colorDialogVisible + text: "Visible" + Binding on checked { value: colorDialog.visible } + } + Row { + id: colorRow + spacing: parent.spacing + height: colorLabel.implicitHeight * 2.0 + Rectangle { + color: colorDialog.color + height: parent.height + width: height * 2 + border.color: "black" + MouseArea { + anchors.fill: parent + onClicked: colorDialog.open() + } + } + Text { + id: colorLabel + color: palette.windowText + text: "<b>current color:</b> " + colorDialog.color + anchors.verticalCenter: parent.verticalCenter + } + } + } + + Rectangle { + anchors { + left: parent.left + right: parent.right + bottom: parent.bottom + } + height: buttonRow.height * 1.2 + color: Qt.darker(palette.window, 1.1) + border.color: Qt.darker(palette.window, 1.3) + Row { + id: buttonRow + spacing: 6 + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: 12 + height: implicitHeight + width: parent.width + Button { + text: "Open" + anchors.verticalCenter: parent.verticalCenter + onClicked: colorDialog.open() + } + Button { + text: "Close" + anchors.verticalCenter: parent.verticalCenter + onClicked: colorDialog.close() + } + Button { + text: "set to green" + anchors.verticalCenter: parent.verticalCenter + onClicked: colorDialog.color = "green" + } + } + } +} diff --git a/examples/quick/dialogs/systemdialogs/FileDialogs.qml b/examples/quick/dialogs/systemdialogs/FileDialogs.qml new file mode 100644 index 00000000..ccfff2d6 --- /dev/null +++ b/examples/quick/dialogs/systemdialogs/FileDialogs.qml @@ -0,0 +1,185 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc and its Subsidiary(-ies) 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 2.0 +import QtQuick.Controls 1.1 +import QtQuick.Dialogs 1.1 +import QtQuick.Window 2.0 + +Item { + width: 580 + height: 400 + SystemPalette { id: palette } + clip: true + + //! [filedialog] + FileDialog { + id: fileDialog + visible: fileDialogVisible.checked + modality: fileDialogModal.checked ? Qt.WindowModal : Qt.NonModal + title: fileDialogSelectFolder.checked ? "Choose a folder" : + (fileDialogSelectMultiple.checked ? "Choose some files" : "Choose a file") + selectExisting: fileDialogSelectExisting.checked + selectMultiple: fileDialogSelectMultiple.checked + selectFolder: fileDialogSelectFolder.checked + nameFilters: [ "Image files (*.png *.jpg)", "All files (*)" ] + selectedNameFilter: "All files (*)" + onAccepted: { + console.log("Accepted: " + fileUrls) + if (fileDialogOpenFiles.checked) + for (var i = 0; i < fileUrls.length; ++i) + Qt.openUrlExternally(fileUrls[i]) + } + onRejected: { console.log("Rejected") } + } + //! [filedialog] + + Column { + anchors.fill: parent + anchors.margins: 12 + spacing: 8 + Text { + color: palette.windowText + font.bold: true + text: "File dialog properties:" + } + CheckBox { + id: fileDialogModal + text: "Modal" + checked: true + Binding on checked { value: fileDialog.modality != Qt.NonModal } + } + CheckBox { + id: fileDialogSelectFolder + text: "Select Folder" + Binding on checked { value: fileDialog.selectFolder } + } + CheckBox { + id: fileDialogSelectExisting + text: "Select Existing Files" + checked: true + Binding on checked { value: fileDialog.selectExisting } + } + CheckBox { + id: fileDialogSelectMultiple + text: "Select Multiple Files" + Binding on checked { value: fileDialog.selectMultiple } + } + CheckBox { + id: fileDialogOpenFiles + text: "Open Files After Accepting" + } + CheckBox { + id: fileDialogVisible + text: "Visible" + Binding on checked { value: fileDialog.visible } + } + Text { + color: palette.windowText + text: "<b>current view folder:</b> " + fileDialog.folder + } + Text { + color: palette.windowText + text: "<b>name filters:</b> {" + fileDialog.nameFilters + "}" + width: parent.width + wrapMode: Text.Wrap + } + Text { + color: palette.windowText + text: "<b>current filter:</b>" + fileDialog.selectedNameFilter + width: parent.width + wrapMode: Text.Wrap + } + Text { + color: palette.windowText + text: "<b>chosen files:</b> " + fileDialog.fileUrls + width: parent.width + wrapMode: Text.Wrap + } + Text { + color: palette.windowText + text: "<b>chosen single path:</b> " + fileDialog.fileUrl + width: parent.width + wrapMode: Text.Wrap + } + } + + Rectangle { + anchors { + left: parent.left + right: parent.right + bottom: parent.bottom + } + height: buttonRow.height * 1.2 + color: Qt.darker(palette.window, 1.1) + border.color: Qt.darker(palette.window, 1.3) + Row { + id: buttonRow + spacing: 6 + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: 12 + height: implicitHeight + width: parent.width + Button { + text: "Open" + anchors.verticalCenter: parent.verticalCenter + onClicked: fileDialog.open() + } + Button { + text: "Close" + anchors.verticalCenter: parent.verticalCenter + onClicked: fileDialog.close() + } + Button { + text: "go to /tmp" + anchors.verticalCenter: parent.verticalCenter + // TODO: QTBUG-29814 This isn't portable, but we don't expose QDir::tempPath to QML yet. + onClicked: fileDialog.folder = "/tmp" // file:///tmp would also be OK + } + Button { + text: "home dir" + anchors.verticalCenter: parent.verticalCenter + // TODO: QTBUG-29814 This isn't portable, but we don't expose QDir::tempPath to QML yet. + onClicked: fileDialog.folder = "~" + } + } + } +} diff --git a/examples/quick/dialogs/systemdialogs/FontDialogs.qml b/examples/quick/dialogs/systemdialogs/FontDialogs.qml new file mode 100644 index 00000000..3eac625e --- /dev/null +++ b/examples/quick/dialogs/systemdialogs/FontDialogs.qml @@ -0,0 +1,152 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc and its Subsidiary(-ies) 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 2.2 +import QtQuick.Controls 1.1 +import QtQuick.Dialogs 1.1 + +Item { + width: 320 + height: 360 + SystemPalette { id: palette } + clip: true + + FontDialog { + id: fontDialog + visible: fontDialogVisible.checked + modality: fontDialogModal.checked ? Qt.WindowModal : Qt.NonModal + scalableFonts: fontDialogScalableFonts.checked + nonScalableFonts: fontDialogNonScalableFonts.checked + monospacedFonts: fontDialogMonospacedFonts.checked + proportionalFonts: fontDialogProportionalFonts.checked + title: "Choose a font" + font: Qt.font({ family: "Arial", pointSize: 24, weight: Font.Normal }) + onAccepted: { console.log("Accepted: " + font) } + onRejected: { console.log("Rejected") } + } + + Column { + id: optionsColumn + anchors.fill: parent + anchors.margins: 12 + spacing: 8 + Text { + font.bold: true + text: "Font dialog properties:" + } + CheckBox { + id: fontDialogModal + text: "Modal" + checked: true + Binding on checked { value: fontDialog.modality != Qt.NonModal } + } + CheckBox { + id: fontDialogScalableFonts + text: "Scalable fonts" + Binding on checked { value: fontDialog.scalableFonts } + } + CheckBox { + id: fontDialogNonScalableFonts + text: "Non scalable fonts" + Binding on checked { value: fontDialog.nonScalableFonts } + } + CheckBox { + id: fontDialogMonospacedFonts + text: "Monospaced fonts" + Binding on checked { value: fontDialog.monospacedFonts } + } + CheckBox { + id: fontDialogProportionalFonts + text: "Proportional fonts" + Binding on checked { value: fontDialog.proportionalFonts } + } + CheckBox { + id: fontDialogVisible + text: "Visible" + Binding on checked { value: fontDialog.visible } + } + Text { + text: "Current font:" + } + Text { + id: fontLabel + color: palette.windowText + text: "<b>" + fontDialog.font.family + " - " + fontDialog.font.pointSize + "</b>" + MouseArea { + anchors.fill: parent + onClicked: fontDialog.open() + } + } + } + + Rectangle { + anchors { + left: parent.left + right: parent.right + bottom: parent.bottom + } + height: buttonRow.height * 1.2 + color: Qt.darker(palette.window, 1.1) + border.color: Qt.darker(palette.window, 1.3) + Row { + id: buttonRow + spacing: 6 + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: 12 + width: parent.width + Button { + text: "Open" + anchors.verticalCenter: parent.verticalCenter + onClicked: fontDialog.open() + } + Button { + text: "Close" + anchors.verticalCenter: parent.verticalCenter + onClicked: fontDialog.close() + } + Button { + text: "set to default" + anchors.verticalCenter: parent.verticalCenter + onClicked: fontDialog.font = Qt.font({ family: "Arial", pointSize: 24, weight: Font.Normal }) + } + } + } +} diff --git a/examples/quick/dialogs/systemdialogs/MessageDialogs.qml b/examples/quick/dialogs/systemdialogs/MessageDialogs.qml new file mode 100644 index 00000000..6be99742 --- /dev/null +++ b/examples/quick/dialogs/systemdialogs/MessageDialogs.qml @@ -0,0 +1,307 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc and its Subsidiary(-ies) 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 2.1 +import QtQuick.Controls 1.1 +import QtQuick.Dialogs 1.1 +import QtQuick.Window 2.0 + +Item { + id: root + width: 580 + height: 400 + SystemPalette { id: palette } + clip: true + + //! [messagedialog] + MessageDialog { + id: messageDialog + visible: messageDialogVisible.checked + modality: messageDialogModal.checked ? Qt.WindowModal : Qt.NonModal + title: windowTitleField.text + text: customizeText.checked ? textField.text : "" + informativeText: customizeInformativeText.checked ? informativeTextField.text : "" + detailedText: customizeDetailedText.checked ? detailedTextField.text : "" + onButtonClicked: console.log("clicked button " + clickedButton) + onAccepted: lastChosen.text = "Accepted " + + (clickedButton == StandardButton.Ok ? "(OK)" : (clickedButton == StandardButton.Retry ? "(Retry)" : "(Ignore)")) + onRejected: lastChosen.text = "Rejected " + + (clickedButton == StandardButton.Close ? "(Close)" : (clickedButton == StandardButton.Abort ? "(Abort)" : "(Cancel)")) + onHelp: lastChosen.text = "Yelped for help!" + onYes: lastChosen.text = (clickedButton == StandardButton.Yes ? "Yeessss!!" : "Yes, now and always") + onNo: lastChosen.text = (clickedButton == StandardButton.No ? "Oh No." : "No, no, a thousand times no!") + onApply: lastChosen.text = "Apply" + onReset: lastChosen.text = "Reset" + } + //! [messagedialog] + + Column { + anchors.fill: parent + anchors.margins: 12 + spacing: 8 + Text { + color: palette.windowText + font.bold: true + text: "Message dialog properties:" + } + CheckBox { + id: messageDialogModal + text: "Modal" + checked: true + Binding on checked { value: messageDialog.modality != Qt.NonModal } + } + CheckBox { + id: customizeTitle + text: "Window Title" + checked: true + width: parent.width + TextField { + id: windowTitleField + anchors.right: parent.right + width: informativeTextField.width + text: "Alert" + } + } + Row { + spacing: 8 + property bool updating: false + function updateIcon(icon, checked) { + if (updating) return + updating = true + messageDialog.icon = (checked ? icon : StandardIcon.NoIcon) + for (var i = 0; i < children.length; ++i) + if (children[i].icon !== icon) + children[i].checked = false + updating = false + } + + CheckBox { + id: iconInformation + text: "Information" + property int icon: StandardIcon.Information + onCheckedChanged: parent.updateIcon(icon, checked) + } + + CheckBox { + id: iconWarning + text: "Warning" + checked: true + property int icon: StandardIcon.Warning + onCheckedChanged: parent.updateIcon(icon, checked) + Component.onCompleted: parent.updateIcon(icon, true) + } + + CheckBox { + id: iconCritical + text: "Critical" + property int icon: StandardIcon.Critical + onCheckedChanged: parent.updateIcon(icon, checked) + } + + CheckBox { + id: iconQuestion + text: "Question" + property int icon: StandardIcon.Question + onCheckedChanged: parent.updateIcon(icon, checked) + } + } + + CheckBox { + id: customizeText + text: "Primary Text" + checked: true + width: parent.width + TextField { + id: textField + anchors.right: parent.right + width: informativeTextField.width + text: "Attention Please" + } + } + CheckBox { + id: customizeInformativeText + text: "Informative Text" + checked: true + width: parent.width + TextField { + id: informativeTextField + anchors.right: parent.right + width: root.width - customizeInformativeText.implicitWidth - 20 + text: "Be alert!" + } + } + Text { + text: "Buttons:" + } + Flow { + spacing: 8 + width: parent.width + property bool updating: false + function updateButtons(button, checked) { + if (updating) return + updating = true + var buttons = 0 + for (var i = 0; i < children.length; ++i) + if (children[i].checked) + buttons |= children[i].button + if (!buttons) + buttons = StandardButton.Ok + messageDialog.standardButtons = buttons + updating = false + } + + CheckBox { + text: "Help" + property int button: StandardButton.Help + onCheckedChanged: parent.updateButtons(button, checked) + } + + CheckBox { + text: "Abort" + property int button: StandardButton.Abort + onCheckedChanged: parent.updateButtons(button, checked) + } + + CheckBox { + text: "Close" + property int button: StandardButton.Close + onCheckedChanged: parent.updateButtons(button, checked) + } + + CheckBox { + text: "Cancel" + property int button: StandardButton.Cancel + onCheckedChanged: parent.updateButtons(button, checked) + } + + CheckBox { + text: "NoToAll" + property int button: StandardButton.NoToAll + onCheckedChanged: parent.updateButtons(button, checked) + } + + CheckBox { + text: "No" + property int button: StandardButton.No + onCheckedChanged: parent.updateButtons(button, checked) + } + + CheckBox { + text: "YesToAll" + property int button: StandardButton.YesToAll + onCheckedChanged: parent.updateButtons(button, checked) + } + + CheckBox { + text: "Yes" + property int button: StandardButton.Yes + onCheckedChanged: parent.updateButtons(button, checked) + } + + CheckBox { + text: "Ignore" + property int button: StandardButton.Ignore + onCheckedChanged: parent.updateButtons(button, checked) + } + + CheckBox { + text: "Retry" + property int button: StandardButton.Retry + onCheckedChanged: parent.updateButtons(button, checked) + } + + CheckBox { + text: "OK" + checked: true + property int button: StandardButton.Ok + onCheckedChanged: parent.updateButtons(button, checked) + } + } + CheckBox { + id: customizeDetailedText + text: "Detailed Text" + checked: true + width: parent.width + TextField { + id: detailedTextField + anchors.right: parent.right + width: informativeTextField.width + text: "The world needs more lerts." + } + } + CheckBox { + id: messageDialogVisible + text: "Visible" + Binding on checked { value: messageDialog.visible } + } + Text { + id: lastChosen + } + } + + Rectangle { + anchors { + left: parent.left + right: parent.right + bottom: parent.bottom + } + height: buttonRow.height * 1.2 + color: Qt.darker(palette.window, 1.1) + border.color: Qt.darker(palette.window, 1.3) + Row { + id: buttonRow + spacing: 6 + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: 12 + width: parent.width + Button { + text: "Open" + anchors.verticalCenter: parent.verticalCenter + onClicked: messageDialog.open() + } + Button { + text: "Close" + anchors.verticalCenter: parent.verticalCenter + onClicked: messageDialog.close() + } + } + } +} diff --git a/examples/quick/dialogs/systemdialogs/doc/images/systemdialogs-example.jpg b/examples/quick/dialogs/systemdialogs/doc/images/systemdialogs-example.jpg Binary files differnew file mode 100644 index 00000000..4517a393 --- /dev/null +++ b/examples/quick/dialogs/systemdialogs/doc/images/systemdialogs-example.jpg diff --git a/examples/quick/dialogs/systemdialogs/doc/src/systemdialogs.qdoc b/examples/quick/dialogs/systemdialogs/doc/src/systemdialogs.qdoc new file mode 100644 index 00000000..9788be73 --- /dev/null +++ b/examples/quick/dialogs/systemdialogs/doc/src/systemdialogs.qdoc @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \title Qt Quick System Dialog Examples + \example systemdialogs + \brief This example demonstrates the system dialog types in QML + \image systemdialogs-example.jpg + \ingroup qtquickdialog_examples + + This example demonstrates the system dialogs in the \l{Qt Quick Dialogs} + module. The appearance and behavior is platform-dependent. + + A \l FileDialog is used to choose a single file, multiple files or a + single directory, depending on how it is configured. + \snippet systemdialogs/FileDialogs.qml filedialog + + A \l ColorDialog is used to choose a color, with or without alpha (transparency) + depending on how it is configured. + \snippet systemdialogs/ColorDialogs.qml colordialog + + The example can be built as a standalone executable, but each + type of dialog is demonstrated in a separate QML file which can + also be run separately with qmlscene. +*/ diff --git a/examples/quick/dialogs/systemdialogs/main.cpp b/examples/quick/dialogs/systemdialogs/main.cpp new file mode 100644 index 00000000..fd882200 --- /dev/null +++ b/examples/quick/dialogs/systemdialogs/main.cpp @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc and its Subsidiary(-ies) 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 "qtquickcontrolsapplication.h" +#include <QtQml/QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QtQuickControlsApplication app(argc, argv); + QQmlApplicationEngine engine(QUrl("qrc:/dialogs/systemdialogs/systemdialogs.qml")); + return app.exec(); +} diff --git a/examples/quick/dialogs/systemdialogs/systemdialogs.pro b/examples/quick/dialogs/systemdialogs/systemdialogs.pro new file mode 100644 index 00000000..fcc61bb8 --- /dev/null +++ b/examples/quick/dialogs/systemdialogs/systemdialogs.pro @@ -0,0 +1,18 @@ +QT += qml quick +!android: !ios: !blackberry: qtHaveModule(widgets): QT += widgets + +QT += quick qml +SOURCES += main.cpp +include(../../controls/shared/shared.pri) + +OTHER_FILES += \ + systemdialogs.qml \ + FileDialogs.qml \ + ColorDialogs.qml \ + FontDialogs.qml \ + MessageDialogs.qml + +target.path = $$[QT_INSTALL_EXAMPLES]/quick/dialogs/systemdialogs +INSTALLS += target + +RESOURCES += systemdialogs.qrc diff --git a/examples/quick/dialogs/systemdialogs/systemdialogs.qml b/examples/quick/dialogs/systemdialogs/systemdialogs.qml new file mode 100644 index 00000000..4b44a1e6 --- /dev/null +++ b/examples/quick/dialogs/systemdialogs/systemdialogs.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc and its Subsidiary(-ies) 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 2.2 +import QtQuick.Controls 1.1 + +ApplicationWindow { + visible: true + title: "System Dialogs Gallery" + width: 580 + height: 480 + + TabView { + anchors.fill: parent + anchors.margins: 8 + Tab { + id: controlPage + title: "File Dialog" + FileDialogs { } + } + Tab { + title: "Color Dialog" + ColorDialogs { } + } + Tab { + title: "Font Dialog" + FontDialogs { anchors.fill: parent } + } + Tab { + title: "Message Dialog" + MessageDialogs { anchors.fill:parent } + } + } +} diff --git a/examples/quick/dialogs/systemdialogs/systemdialogs.qrc b/examples/quick/dialogs/systemdialogs/systemdialogs.qrc new file mode 100644 index 00000000..2193088c --- /dev/null +++ b/examples/quick/dialogs/systemdialogs/systemdialogs.qrc @@ -0,0 +1,9 @@ +<RCC> + <qresource prefix="/dialogs/systemdialogs"> + <file>systemdialogs.qml</file> + <file>FileDialogs.qml</file> + <file>ColorDialogs.qml</file> + <file>FontDialogs.qml</file> + <file>MessageDialogs.qml</file> + </qresource> +</RCC> |