1
/****************************************************************************
3
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
4
** Contact: http://www.qt-project.org/legal
6
** This file is part of the QtQuick.Dialogs module of the Qt Toolkit.
8
** $QT_BEGIN_LICENSE:LGPL$
9
** Commercial License Usage
10
** Licensees holding valid commercial Qt licenses may use this file in
11
** accordance with the commercial license agreement provided with the
12
** Software or, alternatively, in accordance with the terms contained in
13
** a written agreement between you and Digia. For licensing terms and
14
** conditions see http://qt.digia.com/licensing. For further information
15
** use the contact form at http://qt.digia.com/contact-us.
17
** GNU Lesser General Public License Usage
18
** Alternatively, this file may be used under the terms of the GNU Lesser
19
** General Public License version 2.1 as published by the Free Software
20
** Foundation and appearing in the file LICENSE.LGPL included in the
21
** packaging of this file. Please review the following information to
22
** ensure the GNU Lesser General Public License version 2.1 requirements
23
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25
** In addition, as a special exception, Digia gives you certain additional
26
** rights. These rights are described in the Digia Qt LGPL Exception
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29
** GNU General Public License Usage
30
** Alternatively, this file may be used under the terms of the GNU
31
** General Public License version 3.0 as published by the Free Software
32
** Foundation and appearing in the file LICENSE.GPL included in the
33
** packaging of this file. Please review the following information to
34
** ensure the GNU General Public License version 3.0 requirements will be
35
** met: http://www.gnu.org/copyleft/gpl.html.
40
****************************************************************************/
42
#include "qquickqfontdialog_p.h"
43
#include "qquickitem.h"
45
#include <private/qguiapplication_p.h>
46
#include <private/qqmlcontext_p.h>
48
#include <QQuickWindow>
49
#include <QFontDialog>
53
class QFontDialogHelper : public QPlatformFontDialogHelper
57
QPlatformFontDialogHelper()
59
connect(&m_dialog, SIGNAL(currentFontChanged(const QFont &)), this, SIGNAL(currentFontChanged(const QFont &)));
60
connect(&m_dialog, SIGNAL(fontSelected(const QFont &)), this, SIGNAL(fontSelected(const QFont &)));
61
connect(&m_dialog, SIGNAL(accepted()), this, SIGNAL(accept()));
62
connect(&m_dialog, SIGNAL(rejected()), this, SIGNAL(reject()));
65
virtual void setCurrentFont(const QFont &font) { m_dialog.setCurrentFont(font); }
66
virtual QFont currentFont() const { return m_dialog.currentFont(); }
68
virtual void exec() { m_dialog.exec(); }
70
virtual bool show(Qt::WindowFlags f, Qt::WindowModality m, QWindow *parent) {
72
QWindow *window = m_dialog.windowHandle();
74
window->setTransientParent(parent);
76
m_dialog.windowHandle()->setTransientParent(parent);
77
m_dialog.windowHandle()->setFlags(f);
78
m_dialog.setWindowModality(m);
79
m_dialog.setWindowTitle(QPlatformFontDialogHelper::options()->windowTitle());
80
m_dialog.setOptions((QFontDialog::FontDialogOptions)((int)(QPlatformFontDialogHelper::options()->options())));
82
return m_dialog.isVisible();
85
virtual void hide() { m_dialog.hide(); }
93
\instantiates QQuickQFontDialog
94
\inqmlmodule QtQuick.PrivateWidgets 1
95
\ingroup qtquick-visual
96
\brief Dialog component for choosing files from a local filesystem.
100
QtFontDialog provides a means to instantiate and manage a QFontDialog.
101
It is not recommended to be used directly; it is an implementation
102
detail of \l FontDialog in the \l QtQuick.Dialogs module.
104
To use this type, you will need to import the module with the following line:
106
import QtQuick.PrivateWidgets 1.1
111
\qmlsignal QtQuick::Dialogs::FontDialog::accepted
113
The \a accepted signal is emitted when the user has finished using the
114
dialog. You can then inspect the \a filePath or \a filePaths properties to
121
onAccepted: { console.log("Selected file: " + filePath) }
127
\qmlsignal QtQuick::Dialogs::FontDialog::rejected
129
The \a rejected signal is emitted when the user has dismissed the dialog,
130
either by closing the dialog window or by pressing the Cancel button.
134
\class QQuickQFontDialog
135
\inmodule QtQuick.PrivateWidgets
138
\brief The QQuickQFontDialog class is a wrapper for a QFontDialog.
144
Constructs a file dialog with parent window \a parent.
146
QQuickQFontDialog::QQuickQFontDialog(QObject *parent)
147
: QQuickAbstractFontDialog(parent)
152
Destroys the file dialog.
154
QQuickQFontDialog::~QQuickQFontDialog()
161
QPlatformFontDialogHelper *QQuickQFontDialog::helper()
163
QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent());
165
m_parentWindow = parentItem->window();
168
m_dlgHelper = new QFontDialogHelper();
169
connect(m_dlgHelper, SIGNAL(currentFontChanged(const QFont &)), this, SLOT(setFont(const QFont &)));
170
connect(m_dlgHelper, SIGNAL(fontSelected(const QFont &)), this, SLOT(setFont(const QFont &)));
171
connect(m_dlgHelper, SIGNAL(accept()), this, SLOT(accept()));
172
connect(m_dlgHelper, SIGNAL(reject()), this, SLOT(reject()));