~ubuntu-branches/ubuntu/wily/qtdeclarative-opensource-src/wily-proposed

« back to all changes in this revision

Viewing changes to src/imports/widgets/qquickqfontdialog.cpp

  • Committer: Package Import Robot
  • Author(s): Ricardo Salveti de Araujo, Ricardo Salveti de Araujo, Timo Jyrinki
  • Date: 2014-06-19 02:39:21 UTC
  • mfrom: (0.1.18 experimental)
  • Revision ID: package-import@ubuntu.com-20140619023921-yb2oasnuetz9b0fc
Tags: 5.3.0-3ubuntu4
[ Ricardo Salveti de Araujo ]
* debian/control:
  - Updating dependencies as we now also have libqt5quickwidgets5-gles
* libqt5quickwidgets5.symbols: updating to allow gles variant

[ Timo Jyrinki ]
* Update libqt5quickparticles5.symbols from build logs

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/****************************************************************************
2
 
**
3
 
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
4
 
** Contact: http://www.qt-project.org/legal
5
 
**
6
 
** This file is part of the QtQuick.Dialogs module of the Qt Toolkit.
7
 
**
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.
16
 
**
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.
24
 
**
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.
28
 
**
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.
36
 
**
37
 
**
38
 
** $QT_END_LICENSE$
39
 
**
40
 
****************************************************************************/
41
 
 
42
 
#include "qquickqfontdialog_p.h"
43
 
#include "qquickitem.h"
44
 
 
45
 
#include <private/qguiapplication_p.h>
46
 
#include <private/qqmlcontext_p.h>
47
 
#include <QWindow>
48
 
#include <QQuickWindow>
49
 
#include <QFontDialog>
50
 
 
51
 
QT_BEGIN_NAMESPACE
52
 
 
53
 
class QFontDialogHelper : public QPlatformFontDialogHelper
54
 
{
55
 
public:
56
 
    QFontDialogHelper() :
57
 
        QPlatformFontDialogHelper()
58
 
    {
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()));
63
 
    }
64
 
 
65
 
    virtual void setCurrentFont(const QFont &font) { m_dialog.setCurrentFont(font); }
66
 
    virtual QFont currentFont() const { return m_dialog.currentFont(); }
67
 
 
68
 
    virtual void exec() { m_dialog.exec(); }
69
 
 
70
 
    virtual bool show(Qt::WindowFlags f, Qt::WindowModality m, QWindow *parent) {
71
 
        m_dialog.winId();
72
 
        QWindow *window = m_dialog.windowHandle();
73
 
        Q_ASSERT(window);
74
 
        window->setTransientParent(parent);
75
 
        window->setFlags(f);
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())));
81
 
        m_dialog.show();
82
 
        return m_dialog.isVisible();
83
 
    }
84
 
 
85
 
    virtual void hide() { m_dialog.hide(); }
86
 
 
87
 
private:
88
 
    QFontDialog m_dialog;
89
 
};
90
 
 
91
 
/*!
92
 
    \qmltype QtFontDialog
93
 
    \instantiates QQuickQFontDialog
94
 
    \inqmlmodule QtQuick.PrivateWidgets 1
95
 
    \ingroup qtquick-visual
96
 
    \brief Dialog component for choosing files from a local filesystem.
97
 
    \since 5.2
98
 
    \internal
99
 
 
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.
103
 
 
104
 
    To use this type, you will need to import the module with the following line:
105
 
    \code
106
 
    import QtQuick.PrivateWidgets 1.1
107
 
    \endcode
108
 
*/
109
 
 
110
 
/*!
111
 
    \qmlsignal QtQuick::Dialogs::FontDialog::accepted
112
 
 
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
115
 
    get the selection.
116
 
 
117
 
    Example:
118
 
 
119
 
    \qml
120
 
    FontDialog {
121
 
        onAccepted: { console.log("Selected file: " + filePath) }
122
 
    }
123
 
    \endqml
124
 
*/
125
 
 
126
 
/*!
127
 
    \qmlsignal QtQuick::Dialogs::FontDialog::rejected
128
 
 
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.
131
 
*/
132
 
 
133
 
/*!
134
 
    \class QQuickQFontDialog
135
 
    \inmodule QtQuick.PrivateWidgets
136
 
    \internal
137
 
 
138
 
    \brief The QQuickQFontDialog class is a wrapper for a QFontDialog.
139
 
 
140
 
    \since 5.2
141
 
*/
142
 
 
143
 
/*!
144
 
    Constructs a file dialog with parent window \a parent.
145
 
*/
146
 
QQuickQFontDialog::QQuickQFontDialog(QObject *parent)
147
 
    : QQuickAbstractFontDialog(parent)
148
 
{
149
 
}
150
 
 
151
 
/*!
152
 
    Destroys the file dialog.
153
 
*/
154
 
QQuickQFontDialog::~QQuickQFontDialog()
155
 
{
156
 
    if (m_dlgHelper)
157
 
        m_dlgHelper->hide();
158
 
    delete m_dlgHelper;
159
 
}
160
 
 
161
 
QPlatformFontDialogHelper *QQuickQFontDialog::helper()
162
 
{
163
 
    QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent());
164
 
    if (parentItem)
165
 
        m_parentWindow = parentItem->window();
166
 
 
167
 
    if (!m_dlgHelper) {
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()));
173
 
    }
174
 
 
175
 
    return m_dlgHelper;
176
 
}
177
 
 
178
 
QT_END_NAMESPACE