1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the plugins 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 The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/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 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or (at your option) the GNU General |
28 | ** Public license version 3 or any later version approved by the KDE Free |
29 | ** Qt Foundation. The licenses are as published by the Free Software |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
31 | ** included in the packaging of this file. Please review the following |
32 | ** information to ensure the GNU General Public License requirements will |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
35 | ** |
36 | ** $QT_END_LICENSE$ |
37 | ** |
38 | ****************************************************************************/ |
39 | |
40 | #ifndef QGTK3DIALOGHELPERS_H |
41 | #define QGTK3DIALOGHELPERS_H |
42 | |
43 | #include <QtCore/qhash.h> |
44 | #include <QtCore/qlist.h> |
45 | #include <QtCore/qurl.h> |
46 | #include <QtCore/qscopedpointer.h> |
47 | #include <QtCore/qstring.h> |
48 | #include <qpa/qplatformdialoghelper.h> |
49 | |
50 | typedef struct _GtkDialog GtkDialog; |
51 | typedef struct _GtkFileFilter GtkFileFilter; |
52 | |
53 | QT_BEGIN_NAMESPACE |
54 | |
55 | class QGtk3Dialog; |
56 | class QColor; |
57 | |
58 | class QGtk3ColorDialogHelper : public QPlatformColorDialogHelper |
59 | { |
60 | Q_OBJECT |
61 | |
62 | public: |
63 | QGtk3ColorDialogHelper(); |
64 | ~QGtk3ColorDialogHelper(); |
65 | |
66 | bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) override; |
67 | void exec() override; |
68 | void hide() override; |
69 | |
70 | void setCurrentColor(const QColor &color) override; |
71 | QColor currentColor() const override; |
72 | |
73 | private Q_SLOTS: |
74 | void onAccepted(); |
75 | |
76 | private: |
77 | static void onColorChanged(QGtk3ColorDialogHelper *helper); |
78 | void applyOptions(); |
79 | |
80 | QScopedPointer<QGtk3Dialog> d; |
81 | }; |
82 | |
83 | class QGtk3FileDialogHelper : public QPlatformFileDialogHelper |
84 | { |
85 | Q_OBJECT |
86 | |
87 | public: |
88 | QGtk3FileDialogHelper(); |
89 | ~QGtk3FileDialogHelper(); |
90 | |
91 | bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) override; |
92 | void exec() override; |
93 | void hide() override; |
94 | |
95 | bool defaultNameFilterDisables() const override; |
96 | void setDirectory(const QUrl &directory) override; |
97 | QUrl directory() const override; |
98 | void selectFile(const QUrl &filename) override; |
99 | QList<QUrl> selectedFiles() const override; |
100 | void setFilter() override; |
101 | void selectNameFilter(const QString &filter) override; |
102 | QString selectedNameFilter() const override; |
103 | |
104 | private Q_SLOTS: |
105 | void onAccepted(); |
106 | |
107 | private: |
108 | static void onSelectionChanged(GtkDialog *dialog, QGtk3FileDialogHelper *helper); |
109 | static void onCurrentFolderChanged(QGtk3FileDialogHelper *helper); |
110 | static void onFilterChanged(QGtk3FileDialogHelper *helper); |
111 | void applyOptions(); |
112 | void setNameFilters(const QStringList &filters); |
113 | void selectFileInternal(const QUrl &filename); |
114 | void setFileChooserAction(); |
115 | |
116 | QUrl _dir; |
117 | QList<QUrl> _selection; |
118 | QHash<QString, GtkFileFilter*> _filters; |
119 | QHash<GtkFileFilter*, QString> _filterNames; |
120 | QScopedPointer<QGtk3Dialog> d; |
121 | }; |
122 | |
123 | class QGtk3FontDialogHelper : public QPlatformFontDialogHelper |
124 | { |
125 | Q_OBJECT |
126 | |
127 | public: |
128 | QGtk3FontDialogHelper(); |
129 | ~QGtk3FontDialogHelper(); |
130 | |
131 | bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) override; |
132 | void exec() override; |
133 | void hide() override; |
134 | |
135 | void setCurrentFont(const QFont &font) override; |
136 | QFont currentFont() const override; |
137 | |
138 | private Q_SLOTS: |
139 | void onAccepted(); |
140 | |
141 | private: |
142 | static void onFontChanged(QGtk3FontDialogHelper *helper); |
143 | void applyOptions(); |
144 | |
145 | QScopedPointer<QGtk3Dialog> d; |
146 | }; |
147 | |
148 | QT_END_NAMESPACE |
149 | |
150 | #endif // QGTK3DIALOGHELPERS_H |
151 | |