summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@digia.com>2014-02-03 06:49:28 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-03 12:18:36 +0100
commita1df3e8537b7474db08e81bd1f0faebb13caebf4 (patch)
tree882c6215ccad563f05024c197100679733455021 /src
parent0bbb32469adb3c49b110e2eb987caba58da80554 (diff)
Add currentFont property to FontDialog.
QFontDialog has this property. This patch effectively means that the font property will be set when the dialog closes, instead of whenever the current font in the dialog changes, so pressing cancel will revert the font to what it was before the dialog was opened. Align with e73d503b84be12e7bf28491356b459ca309e7c95 in qtdelarative, the similar change for color dialog. [ChangeLog][QtQuickControls][FontDialog] Added currentFont property. Task-number: QTBUG-36574 Change-Id: I4140966543a677d8e654dbaac170a2fe8d3579a1 Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com> Reviewed-by: Mitch Curtis <mitch.curtis@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/dialogs/DefaultFontDialog.qml3
-rw-r--r--src/dialogs/qquickabstractfontdialog.cpp9
-rw-r--r--src/dialogs/qquickabstractfontdialog_p.h5
-rw-r--r--src/dialogs/qquickfontdialog.cpp6
-rw-r--r--src/dialogs/qquickfontdialog_p.h3
-rw-r--r--src/dialogs/qquickplatformfontdialog.cpp8
6 files changed, 32 insertions, 2 deletions
diff --git a/src/dialogs/DefaultFontDialog.qml b/src/dialogs/DefaultFontDialog.qml
index b2e4764d4..a0e00f151 100644
--- a/src/dialogs/DefaultFontDialog.qml
+++ b/src/dialogs/DefaultFontDialog.qml
@@ -49,6 +49,7 @@ AbstractFontDialog {
id: root
property alias font: content.externalFont
+ property alias currentFont: content.font
Rectangle {
id: content
@@ -73,8 +74,6 @@ AbstractFontDialog {
property string writingSystemSample
property var pointSizes
- onFontChanged: externalFont = font
-
onExternalFontChanged: {
if (content.font != content.externalFont) {
font = externalFont
diff --git a/src/dialogs/qquickabstractfontdialog.cpp b/src/dialogs/qquickabstractfontdialog.cpp
index 29dd15e8c..c5b250748 100644
--- a/src/dialogs/qquickabstractfontdialog.cpp
+++ b/src/dialogs/qquickabstractfontdialog.cpp
@@ -121,6 +121,15 @@ void QQuickAbstractFontDialog::setFont(const QFont &arg)
m_font = arg;
emit fontChanged();
}
+ setCurrentFont(arg);
+}
+
+void QQuickAbstractFontDialog::setCurrentFont(const QFont &arg)
+{
+ if (m_currentFont != arg) {
+ m_currentFont = arg;
+ emit currentFontChanged();
+ }
}
void QQuickAbstractFontDialog::setScalableFonts(bool arg)
diff --git a/src/dialogs/qquickabstractfontdialog_p.h b/src/dialogs/qquickabstractfontdialog_p.h
index 858a0d3ea..2156eb793 100644
--- a/src/dialogs/qquickabstractfontdialog_p.h
+++ b/src/dialogs/qquickabstractfontdialog_p.h
@@ -70,6 +70,7 @@ class QQuickAbstractFontDialog : public QQuickAbstractDialog
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)
+ Q_PROPERTY(QFont currentFont READ currentFont WRITE setCurrentFont NOTIFY currentFontChanged)
public:
QQuickAbstractFontDialog(QObject *parent = 0);
@@ -81,12 +82,14 @@ public:
bool monospacedFonts() const;
bool proportionalFonts() const;
QFont font() const { return m_font; }
+ QFont currentFont() const { return m_currentFont; }
public Q_SLOTS:
void setVisible(bool v);
void setModality(Qt::WindowModality m);
void setTitle(const QString &t);
void setFont(const QFont &arg);
+ void setCurrentFont(const QFont &arg);
void setScalableFonts(bool arg);
void setNonScalableFonts(bool arg);
void setMonospacedFonts(bool arg);
@@ -98,12 +101,14 @@ Q_SIGNALS:
void monospacedFontsChanged();
void proportionalFontsChanged();
void fontChanged();
+ void currentFontChanged();
void selectionAccepted();
protected:
QPlatformFontDialogHelper *m_dlgHelper;
QSharedPointer<QFontDialogOptions> m_options;
QFont m_font;
+ QFont m_currentFont;
Q_DISABLE_COPY(QQuickAbstractFontDialog)
};
diff --git a/src/dialogs/qquickfontdialog.cpp b/src/dialogs/qquickfontdialog.cpp
index 2f3c6d83b..d17ce986e 100644
--- a/src/dialogs/qquickfontdialog.cpp
+++ b/src/dialogs/qquickfontdialog.cpp
@@ -117,4 +117,10 @@ QQuickFontDialog::~QQuickFontDialog()
\l Window or an \l Item.
*/
+void QQuickFontDialog::accept()
+{
+ setFont(m_currentFont);
+ QQuickAbstractFontDialog::accept();
+}
+
QT_END_NAMESPACE
diff --git a/src/dialogs/qquickfontdialog_p.h b/src/dialogs/qquickfontdialog_p.h
index a8e2d82e6..c51e1fd94 100644
--- a/src/dialogs/qquickfontdialog_p.h
+++ b/src/dialogs/qquickfontdialog_p.h
@@ -67,6 +67,9 @@ public:
explicit QQuickFontDialog(QObject *parent = 0);
~QQuickFontDialog();
+protected Q_SLOTS:
+ virtual void accept();
+
protected:
virtual QPlatformFontDialogHelper *helper() { return 0; }
diff --git a/src/dialogs/qquickplatformfontdialog.cpp b/src/dialogs/qquickplatformfontdialog.cpp
index 46ad5eb8d..05500489c 100644
--- a/src/dialogs/qquickplatformfontdialog.cpp
+++ b/src/dialogs/qquickplatformfontdialog.cpp
@@ -246,7 +246,15 @@ QPlatformFontDialogHelper *QQuickPlatformFontDialog::helper()
/*!
\qmlproperty font FontDialog::font
+ The font which the user selected and accepted.
+*/
+
+/*!
+ \qmlproperty font FontDialog::currentFont
+
The font which the user selected.
+
+ \since 5.3
*/
QT_END_NAMESPACE