diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/dialogs/DefaultFontDialog.qml | 3 | ||||
| -rw-r--r-- | src/dialogs/qquickabstractfontdialog.cpp | 9 | ||||
| -rw-r--r-- | src/dialogs/qquickabstractfontdialog_p.h | 5 | ||||
| -rw-r--r-- | src/dialogs/qquickfontdialog.cpp | 6 | ||||
| -rw-r--r-- | src/dialogs/qquickfontdialog_p.h | 3 | ||||
| -rw-r--r-- | src/dialogs/qquickplatformfontdialog.cpp | 8 |
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 |
