aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@digia.com>2013-09-11 07:22:08 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-18 22:33:36 +0200
commitd375a65ce10d2854cf6a4643bc9ffb221df99494 (patch)
treef413ee872af2ec206151a12221bba9d9e49cd727 /examples
parent93ecd34c323852812f8f74a4fe6d7dad8e43f35a (diff)
Add FontDialog to QtQuick.Dialogs
As with FileDialog, it tries QPA, then QFontDialog, and falls back to a QML implementation (which is also provided here) if neither type of native dialog is available. The update of plugins.qmltypes files will be in a separate commit. Task-number: QTBUG-31852 Done-with: Shawn Rutledge <shawn.rutledge@digia.com> Change-Id: I066ebbcf44c413af26020ddf8414252b99f5218b Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/quick/dialogs/systemdialogs/FontDialogs.qml153
-rw-r--r--examples/quick/dialogs/systemdialogs/systemdialogs.pro3
-rw-r--r--examples/quick/dialogs/systemdialogs/systemdialogs.qml8
-rw-r--r--examples/quick/dialogs/systemdialogs/systemdialogs.qrc1
4 files changed, 163 insertions, 2 deletions
diff --git a/examples/quick/dialogs/systemdialogs/FontDialogs.qml b/examples/quick/dialogs/systemdialogs/FontDialogs.qml
new file mode 100644
index 0000000000..7d4328994b
--- /dev/null
+++ b/examples/quick/dialogs/systemdialogs/FontDialogs.qml
@@ -0,0 +1,153 @@
+/****************************************************************************
+**
+** 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.Dialogs 1.1
+import "../../shared"
+
+Rectangle {
+ width: 320
+ height: 360
+ color: palette.window
+ 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/systemdialogs.pro b/examples/quick/dialogs/systemdialogs/systemdialogs.pro
index 4e520d1a5d..4f1f71e389 100644
--- a/examples/quick/dialogs/systemdialogs/systemdialogs.pro
+++ b/examples/quick/dialogs/systemdialogs/systemdialogs.pro
@@ -7,7 +7,8 @@ RESOURCES += systemdialogs.qrc ../../shared/shared.qrc
OTHER_FILES += \
systemdialogs.qml \
FileDialogs.qml \
- ColorDialogs.qml
+ ColorDialogs.qml \
+ FontDialogs.qml
target.path = $$[QT_INSTALL_EXAMPLES]/quick/dialogs/systemdialogs
INSTALLS += target
diff --git a/examples/quick/dialogs/systemdialogs/systemdialogs.qml b/examples/quick/dialogs/systemdialogs/systemdialogs.qml
index 6ef1f4b507..167df94c40 100644
--- a/examples/quick/dialogs/systemdialogs/systemdialogs.qml
+++ b/examples/quick/dialogs/systemdialogs/systemdialogs.qml
@@ -38,7 +38,7 @@
**
****************************************************************************/
-import QtQuick 2.0
+import QtQuick 2.2
import "../../shared"
TabSet {
@@ -56,4 +56,10 @@ TabSet {
anchors.fill: parent
color: "#e3e3e3" // to match tab.png
}
+
+ FontDialogs {
+ property string title: "Font Dialog"
+ anchors.fill: parent
+ color: "#e3e3e3" // to match tab.png
+ }
}
diff --git a/examples/quick/dialogs/systemdialogs/systemdialogs.qrc b/examples/quick/dialogs/systemdialogs/systemdialogs.qrc
index e9a46022b2..df576577af 100644
--- a/examples/quick/dialogs/systemdialogs/systemdialogs.qrc
+++ b/examples/quick/dialogs/systemdialogs/systemdialogs.qrc
@@ -3,5 +3,6 @@
<file>systemdialogs.qml</file>
<file>FileDialogs.qml</file>
<file>ColorDialogs.qml</file>
+ <file>FontDialogs.qml</file>
</qresource>
</RCC>