1 | // Copyright (C) 2017 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #include "qwidgetplatformfontdialog_p.h" |
5 | #include "qwidgetplatformdialog_p.h" |
6 | |
7 | #include <QtWidgets/qfontdialog.h> |
8 | |
9 | QT_BEGIN_NAMESPACE |
10 | |
11 | QWidgetPlatformFontDialog::QWidgetPlatformFontDialog(QObject *parent) |
12 | : m_dialog(new QFontDialog) |
13 | { |
14 | setParent(parent); |
15 | |
16 | connect(sender: m_dialog.data(), signal: &QFontDialog::accepted, context: this, slot: &QPlatformDialogHelper::accept); |
17 | connect(sender: m_dialog.data(), signal: &QFontDialog::rejected, context: this, slot: &QPlatformDialogHelper::reject); |
18 | connect(sender: m_dialog.data(), signal: &QFontDialog::currentFontChanged, context: this, slot: &QPlatformFontDialogHelper::currentFontChanged); |
19 | } |
20 | |
21 | QWidgetPlatformFontDialog::~QWidgetPlatformFontDialog() |
22 | { |
23 | } |
24 | |
25 | QFont QWidgetPlatformFontDialog::currentFont() const |
26 | { |
27 | return m_dialog->currentFont(); |
28 | } |
29 | |
30 | void QWidgetPlatformFontDialog::setCurrentFont(const QFont &font) |
31 | { |
32 | m_dialog->setCurrentFont(font); |
33 | } |
34 | |
35 | void QWidgetPlatformFontDialog::exec() |
36 | { |
37 | m_dialog->exec(); |
38 | } |
39 | |
40 | bool QWidgetPlatformFontDialog::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) |
41 | { |
42 | QSharedPointer<QFontDialogOptions> options = QPlatformFontDialogHelper::options(); |
43 | m_dialog->setWindowTitle(options->windowTitle()); |
44 | m_dialog->setOptions(static_cast<QFontDialog::FontDialogOptions>(int(options->options())) | QFontDialog::DontUseNativeDialog); |
45 | |
46 | return QWidgetPlatformDialog::show(dialog: m_dialog.data(), flags, modality, parent); |
47 | } |
48 | |
49 | void QWidgetPlatformFontDialog::hide() |
50 | { |
51 | m_dialog->hide(); |
52 | } |
53 | |
54 | QT_END_NAMESPACE |
55 | |
56 | #include "moc_qwidgetplatformfontdialog_p.cpp" |
57 | |