aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/dialogs
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 /src/imports/dialogs
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 'src/imports/dialogs')
-rw-r--r--src/imports/dialogs/DefaultFontDialog.qml457
-rw-r--r--src/imports/dialogs/WidgetFontDialog.qml44
-rw-r--r--src/imports/dialogs/dialogs.pro14
-rw-r--r--src/imports/dialogs/images/checkmark.pngbin0 -> 809 bytes
-rw-r--r--src/imports/dialogs/plugin.cpp11
-rw-r--r--src/imports/dialogs/qml/CheckBox.qml96
-rw-r--r--src/imports/dialogs/qml/qmldir1
-rw-r--r--src/imports/dialogs/qquickabstractfontdialog.cpp150
-rw-r--r--src/imports/dialogs/qquickabstractfontdialog_p.h113
-rw-r--r--src/imports/dialogs/qquickfontdialog.cpp120
-rw-r--r--src/imports/dialogs/qquickfontdialog_p.h80
-rw-r--r--src/imports/dialogs/qquickplatformfontdialog.cpp251
-rw-r--r--src/imports/dialogs/qquickplatformfontdialog_p.h78
13 files changed, 1413 insertions, 2 deletions
diff --git a/src/imports/dialogs/DefaultFontDialog.qml b/src/imports/dialogs/DefaultFontDialog.qml
new file mode 100644
index 0000000000..87bb812c42
--- /dev/null
+++ b/src/imports/dialogs/DefaultFontDialog.qml
@@ -0,0 +1,457 @@
+/*****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQuick.Dialogs module of 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.Window 2.1
+import QtQuick.Dialogs 1.1
+import QtQuick.Dialogs.Private 1.1
+import "qml"
+
+AbstractFontDialog {
+ id: root
+
+ property alias font: content.externalFont
+
+ Rectangle {
+ id: content
+ property int maxSize: Math.min(Screen.desktopAvailableWidth, Screen.desktopAvailableHeight)
+ implicitWidth: settings.implicitWidth + changeableWidth + outerSpacing * 2
+ implicitHeight: writingSystemLabel.implicitHeight + changeableHeight + buttonRow.height + outerSpacing * 2
+ color: palette.window
+ property real spacing: 8
+ property real outerSpacing: 12
+ property real listMargins: 4
+ property color borderColor: Qt.darker(palette.button, 1.5)
+
+ property font font: Qt.font({ family: "Helvetica", pointSize: 24, weight: Font.Normal })
+ property font externalFont
+ property string writingSystem
+ property string writingSystemSample
+ property var pointSizes
+
+ property real changeableWidth: 160
+ property real changeableHeight: 120
+
+ onFontChanged: externalFont = font
+
+ onExternalFontChanged: {
+ if (content.font != content.externalFont) {
+ font = externalFont
+ wsListView.reset()
+ fontListView.reset()
+ weightListView.reset()
+ }
+ }
+
+ SystemPalette { id: palette }
+
+ Grid {
+ id: settings
+ anchors {
+ top: parent.top
+ bottom: buttonRow.top
+ left: parent.left
+ margins: content.outerSpacing
+ }
+ columns: 5
+ spacing: content.spacing
+
+ Text { id: writingSystemLabel; text: qsTr("Writing System") }
+ Text { id: fontNameLabel; text: qsTr("Font") }
+ Text { id: weightLabel; text: qsTr("Weight") }
+ Text { id: sizeLabel; text: qsTr("Size") }
+ Text { id: optionsLabel; text: qsTr("Others") }
+ Rectangle {
+ radius: 3
+ color: palette.window
+ border.color: content.borderColor
+ implicitWidth: Math.max(writingSystemLabel.implicitWidth + content.listMargins * 2, 80)
+ implicitHeight: Math.max(content.changeableHeight, sampleRectangle.height)
+ clip: true
+ ListView {
+ id: wsListView
+ anchors.fill: parent
+ anchors.margins: content.listMargins
+ anchors.topMargin: 2
+ highlightMoveDuration: 0
+ function reset() {
+ if (wsModel.count > 0) {
+ content.writingSystem = wsModel.get(0).name;
+ fontModel.writingSystem = content.writingSystem;
+ content.writingSystemSample = wsModel.get(0).sample;
+ }
+ }
+
+ model: WritingSystemListModel {
+ id: wsModel
+ Component.onCompleted: wsListView.reset()
+ }
+ highlight: Rectangle {
+ color: palette.highlight
+ x: 2 - wsListView.anchors.margins
+ width: wsListView.parent.width - 4
+ }
+ delegate: Item {
+ width: parent.width
+ height: wsText.height
+ Text {
+ id: wsText
+ text: name
+ width: parent.width
+ elide: Text.ElideRight
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ wsListView.currentIndex = index;
+ content.writingSystem = wsModel.get(wsListView.currentIndex).name;
+ fontModel.writingSystem = content.writingSystem;
+ content.writingSystemSample = wsModel.get(wsListView.currentIndex).sample;
+ }
+ }
+ }
+ }
+ }
+ Rectangle {
+ radius: 3
+ color: palette.window
+ border.color: content.borderColor
+ implicitWidth: Math.max(fontNameLabel.implicitWidth + content.listMargins * 2, 100, (root.width - 400) / 3)
+ implicitHeight: Math.max(content.changeableHeight, sampleRectangle.height)
+ clip: true
+ ListView {
+ id: fontListView
+ anchors.fill: parent
+ anchors.margins: content.listMargins
+ anchors.topMargin: 2
+ highlightMoveDuration: 0
+ function reset() {
+ fontModel.findIndex()
+ content.pointSizes = fontModel.pointSizes()
+ fontModel.findPointSizesIndex()
+ }
+
+ model: FontListModel {
+ id: fontModel
+ scalableFonts: root.scalableFonts
+ nonScalableFonts: root.nonScalableFonts
+ monospacedFonts: root.monospacedFonts
+ proportionalFonts: root.proportionalFonts
+ Component.onCompleted: fontListView.reset()
+ onModelReset: { findIndex(); }
+ function findIndex() {
+ if (fontModel.count <= 0)
+ return
+
+ if (content.font.family == "") {
+ content.font.family = fontModel.get(0).family
+ fontListView.currentIndex = 0
+ } else {
+ var find = false
+ for (var i = 0; i < fontModel.count; ++i) {
+ if (content.font.family == fontModel.get(i).family) {
+ find = true
+ fontListView.currentIndex = i
+ break
+ }
+ }
+ if (find == false) {
+ content.font.family = fontModel.get(0).family
+ fontListView.currentIndex = 0
+ }
+ }
+ }
+ function findPointSizesIndex() {
+ if (content.pointSizes.length <= 0)
+ return
+
+ var find = false
+ for (var i = 0; i < content.pointSizes.length; ++i) {
+ if (content.font.pointSize == content.pointSizes[i]) {
+ find = true
+ pointSizesListView.currentIndex = i
+ break
+ }
+ }
+ if (find == false) {
+ content.font.pointSize = content.pointSizes[0]
+ pointSizesListView.currentIndex = 0
+ }
+ }
+ }
+ highlight: Rectangle {
+ color: palette.highlight
+ x: 2 - fontListView.anchors.margins
+ width: fontListView.parent.width - 4
+ }
+ delegate: Item {
+ width: parent.width
+ height: fontText.height
+ Text {
+ id: fontText
+ text: family
+ width: parent.width
+ elide: Text.ElideRight
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ fontListView.currentIndex = index
+ content.font.family = fontModel.get(fontListView.currentIndex).family
+ }
+ }
+ }
+ }
+ }
+ Rectangle {
+ radius: 3
+ color: palette.window
+ border.color: content.borderColor
+ implicitWidth: Math.max(weightLabel.implicitWidth + content.listMargins * 2, 80)
+ implicitHeight: Math.max(content.changeableHeight, sampleRectangle.height)
+ clip: true
+ ListView {
+ anchors.fill: parent
+ anchors.margins: content.listMargins
+ anchors.topMargin: 2
+ highlightMoveDuration: 0
+ id: weightListView
+ function reset() {
+ weightModel.findIndex()
+ }
+
+ model: ListModel {
+ id: weightModel
+ ListElement {
+ name: "Light"
+ weight: Font.Light
+ }
+ ListElement {
+ name: "Normal"
+ weight: Font.Normal
+ }
+ ListElement {
+ name: "DemiBold"
+ weight: Font.DemiBold
+ }
+ ListElement {
+ name: "Bold"
+ weight: Font.Bold
+ }
+ ListElement {
+ name: "Black"
+ weight: Font.Black
+ }
+ Component.onCompleted: weightListView.reset()
+ function findIndex() {
+ var find = false
+ for (var i = 0; i < weightModel.count; ++i) {
+ if (content.font.weight == weightModel.get(i).weight) {
+ find = true
+ weightListView.currentIndex = i
+ break
+ }
+ }
+ if (find == false) {
+ content.font.weight = weightModel.get(1).family
+ fontListView.currentIndex = 1
+ }
+ }
+ }
+ highlight: Rectangle {
+ color: palette.highlight
+ x: 2 - weightListView.anchors.margins
+ width: weightListView.parent.width - 4
+ }
+ delegate: Item {
+ width: parent.width
+ height: weightText.height
+ Text {
+ id: weightText
+ text: name
+ width: parent.width
+ elide: Text.ElideRight
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ weightListView.currentIndex = index
+ content.font.weight = weightModel.get(weightListView.currentIndex).weight
+ }
+ }
+ }
+ }
+ }
+ Rectangle {
+ radius: 3
+ color: palette.window
+ border.color: content.borderColor
+ implicitWidth: Math.max(sizeLabel.implicitWidth + content.listMargins * 2, 60)
+ implicitHeight: Math.max(content.changeableHeight, sampleRectangle.height)
+ clip: true
+ ListView {
+ anchors.fill: parent
+ anchors.margins: content.listMargins
+ anchors.topMargin: 2
+ highlightMoveDuration: 0
+ id: pointSizesListView
+ model: content.pointSizes
+ highlight: Rectangle {
+ color: palette.highlight
+ x: 2 - weightListView.anchors.margins
+ width: weightListView.parent.width - 4
+ }
+ delegate: Item {
+ width: parent.width
+ height: pointSizesText.height
+ Text {
+ id: pointSizesText
+ text: content.pointSizes[index]
+ width: parent.width
+ elide: Text.ElideRight
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ pointSizesListView.currentIndex = index
+ content.font.pointSize = content.pointSizes[pointSizesListView.currentIndex]
+ }
+ }
+ }
+ }
+ }
+ Column {
+ id: optionsColumn
+ anchors.margins: 2
+ spacing: 2
+ CheckBox {
+ id: italicCheckBox
+ text: qsTr("Italic")
+ checked: content.font.italic
+ onClicked: { content.font.italic = italicCheckBox.checked }
+ }
+ CheckBox {
+ id: underlineCheckBox
+ text: qsTr("Underline")
+ checked: content.font.underline
+ onClicked: { content.font.underline = underlineCheckBox.checked }
+ }
+ CheckBox {
+ id: overlineCheckBox
+ text: qsTr("Overline")
+ checked: content.font.overline
+ onClicked: { content.font.overline = overlineCheckBox.checked }
+ }
+ CheckBox {
+ id: strikeoutCheckBox
+ text: qsTr("Strikeout")
+ checked: content.font.strikeout
+ onClicked: { content.font.strikeout = strikeoutCheckBox.checked }
+ }
+ }
+ }
+
+ Rectangle {
+ id: fixsampleRectangle
+ color: palette.window
+ anchors {
+ top: parent.top
+ left: settings.right
+ right: parent.right
+ margins: content.outerSpacing
+ }
+ implicitWidth: fixsampleText.implicitWidth
+ implicitHeight: fixsampleText.implicitHeight
+ Text { id: fixsampleText; anchors.left: parent.left; text: qsTr("Sample") }
+ }
+ Rectangle {
+ id: sampleRectangle
+ clip: true
+ anchors {
+ top: fixsampleRectangle.bottom
+ bottom: buttonRow.top
+ left: fixsampleRectangle.left
+ right: parent.right
+ margins: content.outerSpacing
+ }
+ implicitWidth: content.changeableWidth
+ implicitHeight: content.changeableHeight
+ color: palette.window
+ border.color: content.borderColor
+ Text {
+ id: sample
+ anchors.centerIn: parent
+ font: content.font
+ text: content.writingSystemSample
+ }
+ }
+
+ Item {
+ id: buttonRow
+ height: buttonsOnly.height
+ width: parent.width
+ anchors {
+ left: parent.left
+ right: parent.right
+ bottom: content.bottom
+ margins: content.outerSpacing
+ }
+ Row {
+ id: buttonsOnly
+ spacing: content.spacing
+ anchors.right: parent.right
+ Button {
+ id: cancelButton
+ text: qsTr("Cancel")
+ onClicked: root.reject()
+ }
+ Button {
+ id: okButton
+ text: qsTr("OK")
+ onClicked: {
+ root.font = content.font
+ root.accept()
+ }
+ }
+ }
+ }
+ }
+}
+
diff --git a/src/imports/dialogs/WidgetFontDialog.qml b/src/imports/dialogs/WidgetFontDialog.qml
new file mode 100644
index 0000000000..69f98b28a2
--- /dev/null
+++ b/src/imports/dialogs/WidgetFontDialog.qml
@@ -0,0 +1,44 @@
+/*****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQuick.Dialogs module 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.PrivateWidgets 1.1
+
+QtFontDialog { }
diff --git a/src/imports/dialogs/dialogs.pro b/src/imports/dialogs/dialogs.pro
index e745d52e2b..c1d7041263 100644
--- a/src/imports/dialogs/dialogs.pro
+++ b/src/imports/dialogs/dialogs.pro
@@ -1,7 +1,7 @@
CXX_MODULE = qml
TARGET = dialogplugin
TARGETPATH = QtQuick/Dialogs
-IMPORT_VERSION = 1.0
+IMPORT_VERSION = 1.1
QMAKE_DOCS = $$PWD/doc/qtquickdialogs.qdocconf
@@ -12,6 +12,9 @@ SOURCES += \
qquickabstractcolordialog.cpp \
qquickplatformcolordialog.cpp \
qquickcolordialog.cpp \
+ qquickabstractfontdialog.cpp \
+ qquickplatformfontdialog.cpp \
+ qquickfontdialog.cpp \
qquickabstractdialog.cpp \
plugin.cpp
@@ -22,6 +25,9 @@ HEADERS += \
qquickabstractcolordialog_p.h \
qquickplatformcolordialog_p.h \
qquickcolordialog_p.h \
+ qquickabstractfontdialog_p.h \
+ qquickplatformfontdialog_p.h \
+ qquickfontdialog_p.h \
qquickabstractdialog_p.h
QML_FILES += \
@@ -29,12 +35,16 @@ QML_FILES += \
WidgetFileDialog.qml \
DefaultColorDialog.qml \
WidgetColorDialog.qml \
+ DefaultFontDialog.qml \
+ WidgetFontDialog.qml \
qml/Button.qml \
+ qml/CheckBox.qml \
qml/ColorSlider.qml \
qml/DefaultWindowDecoration.qml \
qml/TextField.qml \
qml/qmldir \
images/checkers.png \
+ images/checkmark.png \
images/copy.png \
images/crosshairs.png \
images/slider_handle.png \
@@ -43,6 +53,6 @@ QML_FILES += \
images/folder.png \
images/up.png
-QT += quick-private gui-private core-private
+QT += quick-private gui gui-private core core-private qml
load(qml_plugin)
diff --git a/src/imports/dialogs/images/checkmark.png b/src/imports/dialogs/images/checkmark.png
new file mode 100644
index 0000000000..821aafccdd
--- /dev/null
+++ b/src/imports/dialogs/images/checkmark.png
Binary files differ
diff --git a/src/imports/dialogs/plugin.cpp b/src/imports/dialogs/plugin.cpp
index 8fa87bfc0b..e8c669cb49 100644
--- a/src/imports/dialogs/plugin.cpp
+++ b/src/imports/dialogs/plugin.cpp
@@ -47,6 +47,9 @@
#include "qquickcolordialog_p.h"
#include "qquickabstractcolordialog_p.h"
#include "qquickplatformcolordialog_p.h"
+#include "qquickfontdialog_p.h"
+#include "qquickabstractfontdialog_p.h"
+#include "qquickplatformfontdialog_p.h"
#include <private/qguiapplication_p.h>
#include <qpa/qplatformintegration.h>
@@ -113,6 +116,14 @@ public:
else
#endif
registerWidgetOrQmlImplementation<QQuickColorDialog>(widgetsDir, qmlDir, "ColorDialog", uri, hasTopLevelWindows, 1, 0);
+
+ // FontDialog
+#ifndef PURE_QML_ONLY
+ if (QGuiApplicationPrivate::platformTheme()->usePlatformNativeDialog(QPlatformTheme::FontDialog))
+ qmlRegisterType<QQuickPlatformFontDialog>(uri, 1, 1, "FontDialog");
+ else
+#endif
+ registerWidgetOrQmlImplementation<QQuickFontDialog>(widgetsDir, qmlDir, "FontDialog", uri, hasTopLevelWindows, 1, 1);
}
protected:
diff --git a/src/imports/dialogs/qml/CheckBox.qml b/src/imports/dialogs/qml/CheckBox.qml
new file mode 100644
index 0000000000..32b0e6ff70
--- /dev/null
+++ b/src/imports/dialogs/qml/CheckBox.qml
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQuick.Dialogs module 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
+
+Item {
+ id: root
+ implicitHeight: frame.height
+ implicitWidth: row.implicitWidth
+ width: implicitWidth
+ height: implicitHeight
+ property alias text: label.text
+ property bool checked
+ property alias pressed: mouseArea.pressed
+ signal clicked
+
+ SystemPalette { id: palette }
+
+ Row {
+ id: row
+ anchors.verticalCenter: parent.verticalCenter
+ spacing: 6
+ Rectangle {
+ id: frame
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: mouseArea.pressed ? Qt.darker(palette.button, 1.3) : palette.button }
+ GradientStop { position: 1.0; color: Qt.darker(palette.button, 1.3) }
+ }
+ height: label.implicitHeight * 1.5
+ width: height
+ anchors.margins: 1
+ radius: 3
+ antialiasing: true
+ border.color: Qt.darker(palette.button, 1.5)
+ Image {
+ id: theX
+ source: "../images/checkmark.png"
+ anchors.fill: frame
+ anchors.margins: frame.width / 5
+ fillMode: Image.PreserveAspectFit
+ smooth: true
+ visible: checked
+ }
+ }
+ Text {
+ id: label
+ color: palette.text
+ anchors.verticalCenter: frame.verticalCenter
+ }
+ }
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: {
+ parent.checked = !parent.checked
+ parent.clicked()
+ }
+ }
+}
diff --git a/src/imports/dialogs/qml/qmldir b/src/imports/dialogs/qml/qmldir
index c475502cf1..39cbc937e5 100644
--- a/src/imports/dialogs/qml/qmldir
+++ b/src/imports/dialogs/qml/qmldir
@@ -1,3 +1,4 @@
Button 1.0 Button.qml
+CheckBox 1.1 CheckBox.qml
ColorSlider 1.0 ColorSlider.qml
TextField 1.0 TextField.qml
diff --git a/src/imports/dialogs/qquickabstractfontdialog.cpp b/src/imports/dialogs/qquickabstractfontdialog.cpp
new file mode 100644
index 0000000000..29dd15e8cc
--- /dev/null
+++ b/src/imports/dialogs/qquickabstractfontdialog.cpp
@@ -0,0 +1,150 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQuick.Dialogs module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickabstractfontdialog_p.h"
+#include "qquickitem.h"
+
+#include <private/qguiapplication_p.h>
+#include <QWindow>
+#include <QQuickWindow>
+
+QT_BEGIN_NAMESPACE
+
+QQuickAbstractFontDialog::QQuickAbstractFontDialog(QObject *parent)
+ : QQuickAbstractDialog(parent)
+ , m_dlgHelper(0)
+ , m_options(QSharedPointer<QFontDialogOptions>(new QFontDialogOptions()))
+{
+ // On the Mac, modality doesn't work unless you call exec(). But this is a reasonable default anyway.
+ m_modality = Qt::NonModal;
+ connect(this, SIGNAL(accepted()), this, SIGNAL(selectionAccepted()));
+}
+
+QQuickAbstractFontDialog::~QQuickAbstractFontDialog()
+{
+}
+
+void QQuickAbstractFontDialog::setVisible(bool v)
+{
+ if (helper() && v) {
+ m_dlgHelper->setOptions(m_options);
+ // Due to the fact that QFontDialogOptions doesn't have currentFont...
+ m_dlgHelper->setCurrentFont(m_font);
+ }
+ QQuickAbstractDialog::setVisible(v);
+}
+
+void QQuickAbstractFontDialog::setModality(Qt::WindowModality m)
+{
+#ifdef Q_OS_MAC
+ // On the Mac, modality doesn't work unless you call exec()
+ m_modality = Qt::NonModal;
+ emit modalityChanged();
+ return;
+#endif
+ QQuickAbstractDialog::setModality(m);
+}
+
+QString QQuickAbstractFontDialog::title() const
+{
+ return m_options->windowTitle();
+}
+
+bool QQuickAbstractFontDialog::scalableFonts() const
+{
+ return m_options->testOption(QFontDialogOptions::ScalableFonts);
+}
+
+bool QQuickAbstractFontDialog::nonScalableFonts() const
+{
+ return m_options->testOption(QFontDialogOptions::NonScalableFonts);
+}
+
+bool QQuickAbstractFontDialog::monospacedFonts() const
+{
+ return m_options->testOption(QFontDialogOptions::MonospacedFonts);
+}
+
+bool QQuickAbstractFontDialog::proportionalFonts() const
+{
+ return m_options->testOption(QFontDialogOptions::ProportionalFonts);
+}
+
+void QQuickAbstractFontDialog::setTitle(const QString &t)
+{
+ if (m_options->windowTitle() == t) return;
+ m_options->setWindowTitle(t);
+ emit titleChanged();
+}
+
+void QQuickAbstractFontDialog::setFont(const QFont &arg)
+{
+ if (m_font != arg) {
+ m_font = arg;
+ emit fontChanged();
+ }
+}
+
+void QQuickAbstractFontDialog::setScalableFonts(bool arg)
+{
+ m_options->setOption(QFontDialogOptions::ScalableFonts, arg);
+ emit scalableFontsChanged();
+}
+
+void QQuickAbstractFontDialog::setNonScalableFonts(bool arg)
+{
+ m_options->setOption(QFontDialogOptions::NonScalableFonts, arg);
+ emit nonScalableFontsChanged();
+}
+
+void QQuickAbstractFontDialog::setMonospacedFonts(bool arg)
+{
+ m_options->setOption(QFontDialogOptions::MonospacedFonts, arg);
+ emit monospacedFontsChanged();
+}
+
+void QQuickAbstractFontDialog::setProportionalFonts(bool arg)
+{
+ m_options->setOption(QFontDialogOptions::ProportionalFonts, arg);
+ emit proportionalFontsChanged();
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/dialogs/qquickabstractfontdialog_p.h b/src/imports/dialogs/qquickabstractfontdialog_p.h
new file mode 100644
index 0000000000..858a0d3eac
--- /dev/null
+++ b/src/imports/dialogs/qquickabstractfontdialog_p.h
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQuick.Dialogs module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKABSTRACTFONTDIALOG_P_H
+#define QQUICKABSTRACTFONTDIALOG_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtQml>
+#include <QQuickView>
+#include <QtGui/qpa/qplatformdialoghelper.h>
+#include <QtGui/qfont.h>
+#include <qpa/qplatformtheme.h>
+#include "qquickabstractdialog_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QQuickAbstractFontDialog : public QQuickAbstractDialog
+{
+ Q_OBJECT
+ Q_PROPERTY(bool scalableFonts READ scalableFonts WRITE setScalableFonts NOTIFY scalableFontsChanged)
+ Q_PROPERTY(bool nonScalableFonts READ nonScalableFonts WRITE setNonScalableFonts NOTIFY nonScalableFontsChanged)
+ Q_PROPERTY(bool monospacedFonts READ monospacedFonts WRITE setMonospacedFonts NOTIFY monospacedFontsChanged)
+ Q_PROPERTY(bool proportionalFonts READ proportionalFonts WRITE setProportionalFonts NOTIFY proportionalFontsChanged)
+ Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
+
+public:
+ QQuickAbstractFontDialog(QObject *parent = 0);
+ virtual ~QQuickAbstractFontDialog();
+
+ virtual QString title() const;
+ bool scalableFonts() const;
+ bool nonScalableFonts() const;
+ bool monospacedFonts() const;
+ bool proportionalFonts() const;
+ QFont font() const { return m_font; }
+
+public Q_SLOTS:
+ void setVisible(bool v);
+ void setModality(Qt::WindowModality m);
+ void setTitle(const QString &t);
+ void setFont(const QFont &arg);
+ void setScalableFonts(bool arg);
+ void setNonScalableFonts(bool arg);
+ void setMonospacedFonts(bool arg);
+ void setProportionalFonts(bool arg);
+
+Q_SIGNALS:
+ void scalableFontsChanged();
+ void nonScalableFontsChanged();
+ void monospacedFontsChanged();
+ void proportionalFontsChanged();
+ void fontChanged();
+ void selectionAccepted();
+
+protected:
+ QPlatformFontDialogHelper *m_dlgHelper;
+ QSharedPointer<QFontDialogOptions> m_options;
+ QFont m_font;
+
+ Q_DISABLE_COPY(QQuickAbstractFontDialog)
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKABSTRACTFONTDIALOG_P_H
diff --git a/src/imports/dialogs/qquickfontdialog.cpp b/src/imports/dialogs/qquickfontdialog.cpp
new file mode 100644
index 0000000000..2f3c6d83bb
--- /dev/null
+++ b/src/imports/dialogs/qquickfontdialog.cpp
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQuick.Dialogs module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickfontdialog_p.h"
+#include <QQuickItem>
+#include <private/qguiapplication_p.h>
+#include <qpa/qplatformintegration.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype AbstractFontDialog
+ \instantiates QQuickFontDialog
+ \inqmlmodule QtQuick.Dialogs 1
+ \ingroup qtquick-visual
+ \brief API wrapper for QML font dialog implementations
+ \since 5.2
+ \internal
+
+ AbstractFontDialog provides only the API for implementing a font dialog.
+ The implementation (e.g. a Window or preferably an Item, in case it is
+ shown on a device that doesn't support multiple windows) can be provided as
+ \l implementation, which is the default property (the only allowed child
+ element).
+*/
+
+/*!
+ \qmlsignal QtQuick::Dialogs::AbstractFontDialog::accepted
+
+ The \a accepted signal is emitted by \l accept().
+*/
+
+/*!
+ \qmlsignal QtQuick::Dialogs::AbstractFontDialog::rejected
+
+ The \a accepted signal is emitted by \l reject().
+*/
+
+/*!
+ \class QQuickFontDialog
+ \inmodule QtQuick.Dialogs
+ \internal
+
+ The QQuickFontDialog class is a concrete subclass of \l
+ QQuickAbstractFontDialog, but it is abstract from the QML perspective
+ because it needs to enclose a graphical implementation. It exists in order
+ to provide accessors and helper functions which the QML implementation will
+ need.
+
+ \since 5.2
+*/
+
+/*!
+ Constructs a font dialog wrapper with parent window \a parent.
+*/
+QQuickFontDialog::QQuickFontDialog(QObject *parent)
+ : QQuickAbstractFontDialog(parent)
+{
+}
+
+
+/*!
+ Destroys the font dialog wrapper.
+*/
+QQuickFontDialog::~QQuickFontDialog()
+{
+}
+
+/*!
+ \qmlproperty bool AbstractFontDialog::visible
+
+ This property holds whether the dialog is visible. By default this is false.
+*/
+
+/*!
+ \qmlproperty QObject AbstractFontDialog::implementation
+
+ The QML object which implements the actual font dialog. Should be either a
+ \l Window or an \l Item.
+*/
+
+QT_END_NAMESPACE
diff --git a/src/imports/dialogs/qquickfontdialog_p.h b/src/imports/dialogs/qquickfontdialog_p.h
new file mode 100644
index 0000000000..a8e2d82e6f
--- /dev/null
+++ b/src/imports/dialogs/qquickfontdialog_p.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQuick.Dialogs module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKFONTDIALOG_P_H
+#define QQUICKFONTDIALOG_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qquickabstractfontdialog_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QQuickFontDialog : public QQuickAbstractFontDialog
+{
+ Q_OBJECT
+ Q_PROPERTY(QObject* implementation READ qmlImplementation WRITE setQmlImplementation DESIGNABLE false)
+ Q_CLASSINFO("DefaultProperty", "implementation")
+
+public:
+ explicit QQuickFontDialog(QObject *parent = 0);
+ ~QQuickFontDialog();
+
+protected:
+ virtual QPlatformFontDialogHelper *helper() { return 0; }
+
+ Q_DISABLE_COPY(QQuickFontDialog)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickFontDialog *)
+
+#endif // QQUICKFONTDIALOG_P_H
diff --git a/src/imports/dialogs/qquickplatformfontdialog.cpp b/src/imports/dialogs/qquickplatformfontdialog.cpp
new file mode 100644
index 0000000000..8b2e0e0501
--- /dev/null
+++ b/src/imports/dialogs/qquickplatformfontdialog.cpp
@@ -0,0 +1,251 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQuick.Dialogs module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickplatformfontdialog_p.h"
+#include "qquickitem.h"
+
+#include <private/qguiapplication_p.h>
+#include <QWindow>
+#include <QQuickView>
+#include <QQuickWindow>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype FontDialog
+ \instantiates QQuickPlatformFontDialog
+ \inqmlmodule QtQuick.Dialogs 1
+ \ingroup qtquick-visual
+ \brief Dialog component for choosing a font.
+ \since 5.2
+
+ FontDialog allows the user to select a font. The dialog is initially
+ invisible. You need to set the properties as desired first, then set
+ \l visible to true or call \l open().
+
+ Here is a minimal example to open a font dialog and exit after the user
+ chooses a font:
+
+ \qml
+ import QtQuick 2.2
+ import QtQuick.Dialogs 1.1
+
+ FontDialog {
+ id: fontDialog
+ title: "Please choose a font"
+ font: Qt.font({ family: "Arial", pointSize: 24, weight: Font.Normal })
+ onAccepted: {
+ console.log("You chose: " + fontDialog.font)
+ Qt.quit()
+ }
+ onRejected: {
+ console.log("Canceled")
+ Qt.quit()
+ }
+ Component.onCompleted: visible = true
+ }
+ \endqml
+
+ A FontDialog window is automatically transient for its parent window. So
+ whether you declare the dialog inside an \l Item or inside a \l Window, the
+ dialog will appear centered over the window containing the item, or over
+ the Window that you declared.
+
+ The implementation of FontDialog will be a platform font dialog if
+ possible. If that isn't possible, then it will try to instantiate a
+ \l QFontDialog. If that also isn't possible, then it will fall back to a QML
+ implementation, DefaultFontDialog.qml. In that case you can customize the
+ appearance by editing this file. DefaultFontDialog.qml contains a Rectangle
+ to hold the dialog's contents, because certain embedded systems do not
+ support multiple top-level windows. When the dialog becomes visible, it
+ will automatically be wrapped in a Window if possible, or simply reparented
+ on top of the main window if there can only be one window.
+*/
+
+/*!
+ \qmlsignal QtQuick::Dialogs::FontDialog::accepted
+
+ The \a accepted signal is emitted when the user has finished using the
+ dialog. You can then inspect the \a font property to get the selection.
+
+ Example:
+
+ \qml
+ FontDialog {
+ onAccepted: { console.log("Selected font: " + font) }
+ }
+ \endqml
+*/
+
+/*!
+ \qmlsignal QtQuick::Dialogs::FontDialog::rejected
+
+ The \a rejected signal is emitted when the user has dismissed the dialog,
+ either by closing the dialog window or by pressing the Cancel button.
+*/
+
+/*!
+ \class QQuickPlatformFontDialog
+ \inmodule QtQuick.Dialogs
+ \internal
+
+ \brief The QQuickPlatformFontDialog class provides a font dialog
+
+ The dialog is implemented via the QQuickPlatformFontDialogHelper when possible;
+ otherwise it falls back to a QFontDialog or a QML implementation.
+
+ \since 5.2
+*/
+
+/*!
+ Constructs a file dialog with parent window \a parent.
+*/
+QQuickPlatformFontDialog::QQuickPlatformFontDialog(QObject *parent) :
+ QQuickAbstractFontDialog(parent)
+{
+}
+
+/*!
+ Destroys the file dialog.
+*/
+QQuickPlatformFontDialog::~QQuickPlatformFontDialog()
+{
+ if (m_dlgHelper)
+ m_dlgHelper->hide();
+ delete m_dlgHelper;
+}
+
+QPlatformFontDialogHelper *QQuickPlatformFontDialog::helper()
+{
+ QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent());
+ if (parentItem)
+ m_parentWindow = parentItem->window();
+
+ if ( !m_dlgHelper && QGuiApplicationPrivate::platformTheme()->
+ usePlatformNativeDialog(QPlatformTheme::FontDialog) ) {
+ m_dlgHelper = static_cast<QPlatformFontDialogHelper *>(QGuiApplicationPrivate::platformTheme()
+ ->createPlatformDialogHelper(QPlatformTheme::FontDialog));
+ if (!m_dlgHelper)
+ return m_dlgHelper;
+ connect(m_dlgHelper, SIGNAL(accept()), this, SLOT(accept()));
+ connect(m_dlgHelper, SIGNAL(reject()), this, SLOT(reject()));
+ connect(m_dlgHelper, SIGNAL(currentFontChanged(const QFont&)), this, SLOT(setFont(const QFont&)));
+ connect(m_dlgHelper, SIGNAL(fontSelected(const QFont&)), this, SLOT(setFont(const QFont&)));
+ }
+
+ return m_dlgHelper;
+}
+
+/*!
+ \qmlproperty bool FontDialog::visible
+
+ This property holds whether the dialog is visible. By default this is
+ false.
+
+ \sa modality
+*/
+
+/*!
+ \qmlproperty Qt::WindowModality FontDialog::modality
+
+ Whether the dialog should be shown modal with respect to the window
+ containing the dialog's parent Item, modal with respect to the whole
+ application, or non-modal.
+
+ By default it is \l WindowModal.
+
+ Modality does not mean that there are any blocking calls to wait for the
+ dialog to be accepted or rejected; it's only that the user will be
+ prevented from interacting with the parent window and/or the application
+ windows at the same time. You probably need to write an onAccepted handler
+ to actually load or save the chosen file.
+*/
+
+/*!
+ \qmlmethod void FontDialog::open()
+
+ Shows the dialog to the user. It is equivalent to setting \l visible to
+ true.
+*/
+
+/*!
+ \qmlmethod void FontDialog::close()
+
+ Closes the dialog.
+*/
+
+/*!
+ \qmlproperty string FontDialog::title
+
+ The title of the dialog window.
+*/
+
+/*!
+ \qmlproperty bool FontDialog::scalableFonts
+
+ Whether the dialog will show scalable fonts or not.
+*/
+
+/*!
+ \qmlproperty bool FontDialog::nonScalableFonts
+
+ Whether the dialog will show non scalable fonts or not.
+*/
+
+/*!
+ \qmlproperty bool FontDialog::monospacedFonts
+
+ Whether the dialog will show monospaced fonts or not.
+*/
+
+/*!
+ \qmlproperty bool FontDialog::proportionalFonts
+
+ Whether the dialog will show proportional fonts or not.
+*/
+
+/*!
+ \qmlproperty font FontDialog::font
+
+ The font which the user selected.
+*/
+
+QT_END_NAMESPACE
diff --git a/src/imports/dialogs/qquickplatformfontdialog_p.h b/src/imports/dialogs/qquickplatformfontdialog_p.h
new file mode 100644
index 0000000000..743b24ad87
--- /dev/null
+++ b/src/imports/dialogs/qquickplatformfontdialog_p.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQuick.Dialogs module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKPLATFORMFONTDIALOG_P_H
+#define QQUICKPLATFORMFONTDIALOG_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qquickabstractfontdialog_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QQuickPlatformFontDialog : public QQuickAbstractFontDialog
+{
+ Q_OBJECT
+
+public:
+ QQuickPlatformFontDialog(QObject *parent = 0);
+ virtual ~QQuickPlatformFontDialog();
+
+protected:
+ QPlatformFontDialogHelper *helper();
+
+ Q_DISABLE_COPY(QQuickPlatformFontDialog)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickPlatformFontDialog *)
+
+#endif // QQUICKPLATFORMFONTDIALOG_P_H