Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qplatformdialoghelper.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||||||||
2 | ** | - | ||||||||||||||||||
3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||||||||
4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||||||||
5 | ** | - | ||||||||||||||||||
6 | ** This file is part of the QtGui module of the Qt Toolkit. | - | ||||||||||||||||||
7 | ** | - | ||||||||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||||||||
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 http://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||
15 | ** information use the contact form at http://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 2.1 or version 3 as published by the Free | - | ||||||||||||||||||
20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||||||||
21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||||||||
22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||||||||
23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||||||||
24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||||||||
25 | ** | - | ||||||||||||||||||
26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||||||||
27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||||||||
28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||||||||
29 | ** | - | ||||||||||||||||||
30 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||
31 | ** | - | ||||||||||||||||||
32 | ****************************************************************************/ | - | ||||||||||||||||||
33 | - | |||||||||||||||||||
34 | #include "qplatformdialoghelper.h" | - | ||||||||||||||||||
35 | - | |||||||||||||||||||
36 | #include <QtCore/QVariant> | - | ||||||||||||||||||
37 | #include <QtCore/QSharedData> | - | ||||||||||||||||||
38 | #include <QtCore/QSettings> | - | ||||||||||||||||||
39 | #include <QtCore/QUrl> | - | ||||||||||||||||||
40 | #include <QtGui/QColor> | - | ||||||||||||||||||
41 | - | |||||||||||||||||||
42 | #include <algorithm> | - | ||||||||||||||||||
43 | - | |||||||||||||||||||
44 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
45 | - | |||||||||||||||||||
46 | /*! | - | ||||||||||||||||||
47 | \class QPlatformDialogHelper | - | ||||||||||||||||||
48 | \since 5.0 | - | ||||||||||||||||||
49 | \internal | - | ||||||||||||||||||
50 | \ingroup qpa | - | ||||||||||||||||||
51 | - | |||||||||||||||||||
52 | \brief The QPlatformDialogHelper class allows for platform-specific customization of dialogs. | - | ||||||||||||||||||
53 | - | |||||||||||||||||||
54 | */ | - | ||||||||||||||||||
55 | - | |||||||||||||||||||
56 | static const int buttonRoleLayouts[2][5][14] = | - | ||||||||||||||||||
57 | { | - | ||||||||||||||||||
58 | // Qt::Horizontal | - | ||||||||||||||||||
59 | { | - | ||||||||||||||||||
60 | // WinLayout | - | ||||||||||||||||||
61 | { QPlatformDialogHelper::ResetRole, QPlatformDialogHelper::Stretch, QPlatformDialogHelper::YesRole, QPlatformDialogHelper::AcceptRole, | - | ||||||||||||||||||
62 | QPlatformDialogHelper::AlternateRole, QPlatformDialogHelper::DestructiveRole, QPlatformDialogHelper::NoRole, | - | ||||||||||||||||||
63 | QPlatformDialogHelper::ActionRole, QPlatformDialogHelper::RejectRole, QPlatformDialogHelper::ApplyRole, | - | ||||||||||||||||||
64 | QPlatformDialogHelper::HelpRole, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL }, | - | ||||||||||||||||||
65 | - | |||||||||||||||||||
66 | // MacLayout | - | ||||||||||||||||||
67 | { QPlatformDialogHelper::HelpRole, QPlatformDialogHelper::ResetRole, QPlatformDialogHelper::ApplyRole, QPlatformDialogHelper::ActionRole, | - | ||||||||||||||||||
68 | QPlatformDialogHelper::Stretch, QPlatformDialogHelper::DestructiveRole | QPlatformDialogHelper::Reverse, | - | ||||||||||||||||||
69 | QPlatformDialogHelper::AlternateRole | QPlatformDialogHelper::Reverse, QPlatformDialogHelper::RejectRole | QPlatformDialogHelper::Reverse, | - | ||||||||||||||||||
70 | QPlatformDialogHelper::AcceptRole | QPlatformDialogHelper::Reverse, QPlatformDialogHelper::NoRole | QPlatformDialogHelper::Reverse, | - | ||||||||||||||||||
71 | QPlatformDialogHelper::YesRole | QPlatformDialogHelper::Reverse, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL }, | - | ||||||||||||||||||
72 | - | |||||||||||||||||||
73 | // KdeLayout | - | ||||||||||||||||||
74 | { QPlatformDialogHelper::HelpRole, QPlatformDialogHelper::ResetRole, QPlatformDialogHelper::Stretch, QPlatformDialogHelper::YesRole, | - | ||||||||||||||||||
75 | QPlatformDialogHelper::NoRole, QPlatformDialogHelper::ActionRole, QPlatformDialogHelper::AcceptRole, QPlatformDialogHelper::AlternateRole, | - | ||||||||||||||||||
76 | QPlatformDialogHelper::ApplyRole, QPlatformDialogHelper::DestructiveRole, QPlatformDialogHelper::RejectRole, QPlatformDialogHelper::EOL }, | - | ||||||||||||||||||
77 | - | |||||||||||||||||||
78 | // GnomeLayout | - | ||||||||||||||||||
79 | { QPlatformDialogHelper::HelpRole, QPlatformDialogHelper::ResetRole, QPlatformDialogHelper::Stretch, QPlatformDialogHelper::ActionRole, | - | ||||||||||||||||||
80 | QPlatformDialogHelper::ApplyRole | QPlatformDialogHelper::Reverse, QPlatformDialogHelper::DestructiveRole | QPlatformDialogHelper::Reverse, | - | ||||||||||||||||||
81 | QPlatformDialogHelper::AlternateRole | QPlatformDialogHelper::Reverse, QPlatformDialogHelper::RejectRole | QPlatformDialogHelper::Reverse, | - | ||||||||||||||||||
82 | QPlatformDialogHelper::AcceptRole | QPlatformDialogHelper::Reverse, QPlatformDialogHelper::NoRole | QPlatformDialogHelper::Reverse, | - | ||||||||||||||||||
83 | QPlatformDialogHelper::YesRole | QPlatformDialogHelper::Reverse, QPlatformDialogHelper::EOL }, | - | ||||||||||||||||||
84 | - | |||||||||||||||||||
85 | // MacModelessLayout | - | ||||||||||||||||||
86 | { QPlatformDialogHelper::ResetRole, QPlatformDialogHelper::ApplyRole, QPlatformDialogHelper::ActionRole, QPlatformDialogHelper::Stretch, | - | ||||||||||||||||||
87 | QPlatformDialogHelper::HelpRole, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL, | - | ||||||||||||||||||
88 | QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL } | - | ||||||||||||||||||
89 | }, | - | ||||||||||||||||||
90 | - | |||||||||||||||||||
91 | // Qt::Vertical | - | ||||||||||||||||||
92 | { | - | ||||||||||||||||||
93 | // WinLayout | - | ||||||||||||||||||
94 | { QPlatformDialogHelper::ActionRole, QPlatformDialogHelper::YesRole, QPlatformDialogHelper::AcceptRole, QPlatformDialogHelper::AlternateRole, | - | ||||||||||||||||||
95 | QPlatformDialogHelper::DestructiveRole, QPlatformDialogHelper::NoRole, QPlatformDialogHelper::RejectRole, QPlatformDialogHelper::ApplyRole, QPlatformDialogHelper::ResetRole, | - | ||||||||||||||||||
96 | QPlatformDialogHelper::HelpRole, QPlatformDialogHelper::Stretch, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL }, | - | ||||||||||||||||||
97 | - | |||||||||||||||||||
98 | // MacLayout | - | ||||||||||||||||||
99 | { QPlatformDialogHelper::YesRole, QPlatformDialogHelper::NoRole, QPlatformDialogHelper::AcceptRole, QPlatformDialogHelper::RejectRole, | - | ||||||||||||||||||
100 | QPlatformDialogHelper::AlternateRole, QPlatformDialogHelper::DestructiveRole, QPlatformDialogHelper::Stretch, QPlatformDialogHelper::ActionRole, QPlatformDialogHelper::ApplyRole, | - | ||||||||||||||||||
101 | QPlatformDialogHelper::ResetRole, QPlatformDialogHelper::HelpRole, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL }, | - | ||||||||||||||||||
102 | - | |||||||||||||||||||
103 | // KdeLayout | - | ||||||||||||||||||
104 | { QPlatformDialogHelper::AcceptRole, QPlatformDialogHelper::AlternateRole, QPlatformDialogHelper::ApplyRole, QPlatformDialogHelper::ActionRole, | - | ||||||||||||||||||
105 | QPlatformDialogHelper::YesRole, QPlatformDialogHelper::NoRole, QPlatformDialogHelper::Stretch, QPlatformDialogHelper::ResetRole, | - | ||||||||||||||||||
106 | QPlatformDialogHelper::DestructiveRole, QPlatformDialogHelper::RejectRole, QPlatformDialogHelper::HelpRole, QPlatformDialogHelper::EOL }, | - | ||||||||||||||||||
107 | - | |||||||||||||||||||
108 | // GnomeLayout | - | ||||||||||||||||||
109 | { QPlatformDialogHelper::YesRole, QPlatformDialogHelper::NoRole, QPlatformDialogHelper::AcceptRole, QPlatformDialogHelper::RejectRole, | - | ||||||||||||||||||
110 | QPlatformDialogHelper::AlternateRole, QPlatformDialogHelper::DestructiveRole, QPlatformDialogHelper::ApplyRole, QPlatformDialogHelper::ActionRole, QPlatformDialogHelper::Stretch, | - | ||||||||||||||||||
111 | QPlatformDialogHelper::ResetRole, QPlatformDialogHelper::HelpRole, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL }, | - | ||||||||||||||||||
112 | - | |||||||||||||||||||
113 | // MacModelessLayout | - | ||||||||||||||||||
114 | { QPlatformDialogHelper::ActionRole, QPlatformDialogHelper::ApplyRole, QPlatformDialogHelper::ResetRole, QPlatformDialogHelper::Stretch, | - | ||||||||||||||||||
115 | QPlatformDialogHelper::HelpRole, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL, | - | ||||||||||||||||||
116 | QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL, QPlatformDialogHelper::EOL } | - | ||||||||||||||||||
117 | } | - | ||||||||||||||||||
118 | }; | - | ||||||||||||||||||
119 | - | |||||||||||||||||||
120 | QPlatformDialogHelper::QPlatformDialogHelper() | - | ||||||||||||||||||
121 | { | - | ||||||||||||||||||
122 | qRegisterMetaType<StandardButton>(); | - | ||||||||||||||||||
123 | qRegisterMetaType<ButtonRole>(); | - | ||||||||||||||||||
124 | } never executed: end of block | 0 | ||||||||||||||||||
125 | - | |||||||||||||||||||
126 | QPlatformDialogHelper::~QPlatformDialogHelper() | - | ||||||||||||||||||
127 | { | - | ||||||||||||||||||
128 | } | - | ||||||||||||||||||
129 | - | |||||||||||||||||||
130 | QVariant QPlatformDialogHelper::styleHint(StyleHint hint) const | - | ||||||||||||||||||
131 | { | - | ||||||||||||||||||
132 | return QPlatformDialogHelper::defaultStyleHint(hint); never executed: return QPlatformDialogHelper::defaultStyleHint(hint); | 0 | ||||||||||||||||||
133 | } | - | ||||||||||||||||||
134 | - | |||||||||||||||||||
135 | QVariant QPlatformDialogHelper::defaultStyleHint(QPlatformDialogHelper::StyleHint hint) | - | ||||||||||||||||||
136 | { | - | ||||||||||||||||||
137 | Q_UNUSED(hint); | - | ||||||||||||||||||
138 | return QVariant(); never executed: return QVariant(); | 0 | ||||||||||||||||||
139 | } | - | ||||||||||||||||||
140 | - | |||||||||||||||||||
141 | // Font dialog | - | ||||||||||||||||||
142 | - | |||||||||||||||||||
143 | class QFontDialogOptionsPrivate : public QSharedData | - | ||||||||||||||||||
144 | { | - | ||||||||||||||||||
145 | public: | - | ||||||||||||||||||
146 | QFontDialogOptionsPrivate() : options(0) {} never executed: end of block | 0 | ||||||||||||||||||
147 | - | |||||||||||||||||||
148 | QFontDialogOptions::FontDialogOptions options; | - | ||||||||||||||||||
149 | QString windowTitle; | - | ||||||||||||||||||
150 | }; | - | ||||||||||||||||||
151 | - | |||||||||||||||||||
152 | QFontDialogOptions::QFontDialogOptions() : d(new QFontDialogOptionsPrivate) | - | ||||||||||||||||||
153 | { | - | ||||||||||||||||||
154 | } never executed: end of block | 0 | ||||||||||||||||||
155 | - | |||||||||||||||||||
156 | QFontDialogOptions::QFontDialogOptions(const QFontDialogOptions &rhs) : d(rhs.d) | - | ||||||||||||||||||
157 | { | - | ||||||||||||||||||
158 | } never executed: end of block | 0 | ||||||||||||||||||
159 | - | |||||||||||||||||||
160 | QFontDialogOptions &QFontDialogOptions::operator=(const QFontDialogOptions &rhs) | - | ||||||||||||||||||
161 | { | - | ||||||||||||||||||
162 | if (this != &rhs)
| 0 | ||||||||||||||||||
163 | d = rhs.d; never executed: d = rhs.d; | 0 | ||||||||||||||||||
164 | return *this; never executed: return *this; | 0 | ||||||||||||||||||
165 | } | - | ||||||||||||||||||
166 | - | |||||||||||||||||||
167 | QFontDialogOptions::~QFontDialogOptions() | - | ||||||||||||||||||
168 | { | - | ||||||||||||||||||
169 | } | - | ||||||||||||||||||
170 | - | |||||||||||||||||||
171 | QString QFontDialogOptions::windowTitle() const | - | ||||||||||||||||||
172 | { | - | ||||||||||||||||||
173 | return d->windowTitle; never executed: return d->windowTitle; | 0 | ||||||||||||||||||
174 | } | - | ||||||||||||||||||
175 | - | |||||||||||||||||||
176 | void QFontDialogOptions::setWindowTitle(const QString &title) | - | ||||||||||||||||||
177 | { | - | ||||||||||||||||||
178 | d->windowTitle = title; | - | ||||||||||||||||||
179 | } never executed: end of block | 0 | ||||||||||||||||||
180 | - | |||||||||||||||||||
181 | void QFontDialogOptions::setOption(QFontDialogOptions::FontDialogOption option, bool on) | - | ||||||||||||||||||
182 | { | - | ||||||||||||||||||
183 | if (!(d->options & option) != !on)
| 0 | ||||||||||||||||||
184 | setOptions(d->options ^ option); never executed: setOptions(d->options ^ option); | 0 | ||||||||||||||||||
185 | } never executed: end of block | 0 | ||||||||||||||||||
186 | - | |||||||||||||||||||
187 | bool QFontDialogOptions::testOption(QFontDialogOptions::FontDialogOption option) const | - | ||||||||||||||||||
188 | { | - | ||||||||||||||||||
189 | return d->options & option; never executed: return d->options & option; | 0 | ||||||||||||||||||
190 | } | - | ||||||||||||||||||
191 | - | |||||||||||||||||||
192 | void QFontDialogOptions::setOptions(FontDialogOptions options) | - | ||||||||||||||||||
193 | { | - | ||||||||||||||||||
194 | if (options != d->options)
| 0 | ||||||||||||||||||
195 | d->options = options; never executed: d->options = options; | 0 | ||||||||||||||||||
196 | } never executed: end of block | 0 | ||||||||||||||||||
197 | - | |||||||||||||||||||
198 | QFontDialogOptions::FontDialogOptions QFontDialogOptions::options() const | - | ||||||||||||||||||
199 | { | - | ||||||||||||||||||
200 | return d->options; never executed: return d->options; | 0 | ||||||||||||||||||
201 | } | - | ||||||||||||||||||
202 | - | |||||||||||||||||||
203 | /*! | - | ||||||||||||||||||
204 | \class QPlatformFontDialogHelper | - | ||||||||||||||||||
205 | \since 5.0 | - | ||||||||||||||||||
206 | \internal | - | ||||||||||||||||||
207 | \ingroup qpa | - | ||||||||||||||||||
208 | - | |||||||||||||||||||
209 | \brief The QPlatformFontDialogHelper class allows for platform-specific customization of font dialogs. | - | ||||||||||||||||||
210 | - | |||||||||||||||||||
211 | */ | - | ||||||||||||||||||
212 | const QSharedPointer<QFontDialogOptions> &QPlatformFontDialogHelper::options() const | - | ||||||||||||||||||
213 | { | - | ||||||||||||||||||
214 | return m_options; never executed: return m_options; | 0 | ||||||||||||||||||
215 | } | - | ||||||||||||||||||
216 | - | |||||||||||||||||||
217 | void QPlatformFontDialogHelper::setOptions(const QSharedPointer<QFontDialogOptions> &options) | - | ||||||||||||||||||
218 | { | - | ||||||||||||||||||
219 | m_options = options; | - | ||||||||||||||||||
220 | } never executed: end of block | 0 | ||||||||||||||||||
221 | - | |||||||||||||||||||
222 | // Color dialog | - | ||||||||||||||||||
223 | - | |||||||||||||||||||
224 | class QColorDialogStaticData | - | ||||||||||||||||||
225 | { | - | ||||||||||||||||||
226 | public: | - | ||||||||||||||||||
227 | enum { CustomColorCount = 16, StandardColorCount = 6 * 8 }; | - | ||||||||||||||||||
228 | - | |||||||||||||||||||
229 | QColorDialogStaticData(); | - | ||||||||||||||||||
230 | inline void readSettings(); | - | ||||||||||||||||||
231 | inline void writeSettings() const; | - | ||||||||||||||||||
232 | - | |||||||||||||||||||
233 | QRgb customRgb[CustomColorCount]; | - | ||||||||||||||||||
234 | QRgb standardRgb[StandardColorCount]; | - | ||||||||||||||||||
235 | bool customSet; | - | ||||||||||||||||||
236 | }; | - | ||||||||||||||||||
237 | - | |||||||||||||||||||
238 | QColorDialogStaticData::QColorDialogStaticData() : customSet(false) | - | ||||||||||||||||||
239 | { | - | ||||||||||||||||||
240 | int i = 0; | - | ||||||||||||||||||
241 | for (int g = 0; g < 4; ++g)
| 0 | ||||||||||||||||||
242 | for (int r = 0; r < 4; ++r)
| 0 | ||||||||||||||||||
243 | for (int b = 0; b < 3; ++b)
| 0 | ||||||||||||||||||
244 | standardRgb[i++] = qRgb(r * 255 / 3, g * 255 / 3, b * 255 / 2); never executed: standardRgb[i++] = qRgb(r * 255 / 3, g * 255 / 3, b * 255 / 2); | 0 | ||||||||||||||||||
245 | std::fill(customRgb, customRgb + CustomColorCount, 0xffffffff); | - | ||||||||||||||||||
246 | readSettings(); | - | ||||||||||||||||||
247 | } never executed: end of block | 0 | ||||||||||||||||||
248 | - | |||||||||||||||||||
249 | void QColorDialogStaticData::readSettings() | - | ||||||||||||||||||
250 | { | - | ||||||||||||||||||
251 | #ifndef QT_NO_SETTINGS | - | ||||||||||||||||||
252 | const QSettings settings(QSettings::UserScope, QStringLiteral("QtProject")); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
253 | for (int i = 0; i < int(CustomColorCount); ++i) {
| 0 | ||||||||||||||||||
254 | const QVariant v = settings.value(QStringLiteral("Qt/customColors/") + QString::number(i)); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
255 | if (v.isValid())
| 0 | ||||||||||||||||||
256 | customRgb[i] = v.toUInt(); never executed: customRgb[i] = v.toUInt(); | 0 | ||||||||||||||||||
257 | } never executed: end of block | 0 | ||||||||||||||||||
258 | #endif | - | ||||||||||||||||||
259 | } never executed: end of block | 0 | ||||||||||||||||||
260 | - | |||||||||||||||||||
261 | void QColorDialogStaticData::writeSettings() const | - | ||||||||||||||||||
262 | { | - | ||||||||||||||||||
263 | #ifndef QT_NO_SETTINGS | - | ||||||||||||||||||
264 | if (!customSet) {
| 0 | ||||||||||||||||||
265 | QSettings settings(QSettings::UserScope, QStringLiteral("QtProject")); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
266 | for (int i = 0; i < int(CustomColorCount); ++i)
| 0 | ||||||||||||||||||
267 | settings.setValue(QStringLiteral("Qt/customColors/") + QString::number(i), customRgb[i]); never executed: settings.setValue(([]() -> QString { enum { Size = sizeof(u"" "Qt/customColors/")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Qt/customColors/" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()) + QString::number(i), customRgb[i]); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
268 | } never executed: end of block | 0 | ||||||||||||||||||
269 | #endif | - | ||||||||||||||||||
270 | } never executed: end of block | 0 | ||||||||||||||||||
271 | - | |||||||||||||||||||
272 | Q_GLOBAL_STATIC(QColorDialogStaticData, qColorDialogStaticData) never executed: end of block never executed: guard.store(QtGlobalStatic::Destroyed); never executed: return &holder.value;
| 0 | ||||||||||||||||||
273 | - | |||||||||||||||||||
274 | class QColorDialogOptionsPrivate : public QSharedData | - | ||||||||||||||||||
275 | { | - | ||||||||||||||||||
276 | public: | - | ||||||||||||||||||
277 | QColorDialogOptionsPrivate() : options(0) {} never executed: end of block | 0 | ||||||||||||||||||
278 | // Write out settings around destruction of dialogs | - | ||||||||||||||||||
279 | ~QColorDialogOptionsPrivate() { qColorDialogStaticData()->writeSettings(); } never executed: end of block | 0 | ||||||||||||||||||
280 | - | |||||||||||||||||||
281 | QColorDialogOptions::ColorDialogOptions options; | - | ||||||||||||||||||
282 | QString windowTitle; | - | ||||||||||||||||||
283 | }; | - | ||||||||||||||||||
284 | - | |||||||||||||||||||
285 | QColorDialogOptions::QColorDialogOptions() : d(new QColorDialogOptionsPrivate) | - | ||||||||||||||||||
286 | { | - | ||||||||||||||||||
287 | } never executed: end of block | 0 | ||||||||||||||||||
288 | - | |||||||||||||||||||
289 | QColorDialogOptions::QColorDialogOptions(const QColorDialogOptions &rhs) : d(rhs.d) | - | ||||||||||||||||||
290 | { | - | ||||||||||||||||||
291 | } never executed: end of block | 0 | ||||||||||||||||||
292 | - | |||||||||||||||||||
293 | QColorDialogOptions &QColorDialogOptions::operator=(const QColorDialogOptions &rhs) | - | ||||||||||||||||||
294 | { | - | ||||||||||||||||||
295 | if (this != &rhs)
| 0 | ||||||||||||||||||
296 | d = rhs.d; never executed: d = rhs.d; | 0 | ||||||||||||||||||
297 | return *this; never executed: return *this; | 0 | ||||||||||||||||||
298 | } | - | ||||||||||||||||||
299 | - | |||||||||||||||||||
300 | QColorDialogOptions::~QColorDialogOptions() | - | ||||||||||||||||||
301 | { | - | ||||||||||||||||||
302 | } | - | ||||||||||||||||||
303 | - | |||||||||||||||||||
304 | QString QColorDialogOptions::windowTitle() const | - | ||||||||||||||||||
305 | { | - | ||||||||||||||||||
306 | return d->windowTitle; never executed: return d->windowTitle; | 0 | ||||||||||||||||||
307 | } | - | ||||||||||||||||||
308 | - | |||||||||||||||||||
309 | void QColorDialogOptions::setWindowTitle(const QString &title) | - | ||||||||||||||||||
310 | { | - | ||||||||||||||||||
311 | d->windowTitle = title; | - | ||||||||||||||||||
312 | } never executed: end of block | 0 | ||||||||||||||||||
313 | - | |||||||||||||||||||
314 | void QColorDialogOptions::setOption(QColorDialogOptions::ColorDialogOption option, bool on) | - | ||||||||||||||||||
315 | { | - | ||||||||||||||||||
316 | if (!(d->options & option) != !on)
| 0 | ||||||||||||||||||
317 | setOptions(d->options ^ option); never executed: setOptions(d->options ^ option); | 0 | ||||||||||||||||||
318 | } never executed: end of block | 0 | ||||||||||||||||||
319 | - | |||||||||||||||||||
320 | bool QColorDialogOptions::testOption(QColorDialogOptions::ColorDialogOption option) const | - | ||||||||||||||||||
321 | { | - | ||||||||||||||||||
322 | return d->options & option; never executed: return d->options & option; | 0 | ||||||||||||||||||
323 | } | - | ||||||||||||||||||
324 | - | |||||||||||||||||||
325 | void QColorDialogOptions::setOptions(ColorDialogOptions options) | - | ||||||||||||||||||
326 | { | - | ||||||||||||||||||
327 | if (options != d->options)
| 0 | ||||||||||||||||||
328 | d->options = options; never executed: d->options = options; | 0 | ||||||||||||||||||
329 | } never executed: end of block | 0 | ||||||||||||||||||
330 | - | |||||||||||||||||||
331 | QColorDialogOptions::ColorDialogOptions QColorDialogOptions::options() const | - | ||||||||||||||||||
332 | { | - | ||||||||||||||||||
333 | return d->options; never executed: return d->options; | 0 | ||||||||||||||||||
334 | } | - | ||||||||||||||||||
335 | - | |||||||||||||||||||
336 | int QColorDialogOptions::customColorCount() | - | ||||||||||||||||||
337 | { | - | ||||||||||||||||||
338 | return QColorDialogStaticData::CustomColorCount; never executed: return QColorDialogStaticData::CustomColorCount; | 0 | ||||||||||||||||||
339 | } | - | ||||||||||||||||||
340 | - | |||||||||||||||||||
341 | QRgb QColorDialogOptions::customColor(int index) | - | ||||||||||||||||||
342 | { | - | ||||||||||||||||||
343 | if (uint(index) >= uint(QColorDialogStaticData::CustomColorCount))
| 0 | ||||||||||||||||||
344 | return qRgb(255, 255, 255); never executed: return qRgb(255, 255, 255); | 0 | ||||||||||||||||||
345 | return qColorDialogStaticData()->customRgb[index]; never executed: return qColorDialogStaticData()->customRgb[index]; | 0 | ||||||||||||||||||
346 | } | - | ||||||||||||||||||
347 | - | |||||||||||||||||||
348 | QRgb *QColorDialogOptions::customColors() | - | ||||||||||||||||||
349 | { | - | ||||||||||||||||||
350 | return qColorDialogStaticData()->customRgb; never executed: return qColorDialogStaticData()->customRgb; | 0 | ||||||||||||||||||
351 | } | - | ||||||||||||||||||
352 | - | |||||||||||||||||||
353 | void QColorDialogOptions::setCustomColor(int index, QRgb color) | - | ||||||||||||||||||
354 | { | - | ||||||||||||||||||
355 | if (uint(index) >= uint(QColorDialogStaticData::CustomColorCount))
| 0 | ||||||||||||||||||
356 | return; never executed: return; | 0 | ||||||||||||||||||
357 | qColorDialogStaticData()->customSet = true; | - | ||||||||||||||||||
358 | qColorDialogStaticData()->customRgb[index] = color; | - | ||||||||||||||||||
359 | } never executed: end of block | 0 | ||||||||||||||||||
360 | - | |||||||||||||||||||
361 | QRgb *QColorDialogOptions::standardColors() | - | ||||||||||||||||||
362 | { | - | ||||||||||||||||||
363 | return qColorDialogStaticData()->standardRgb; never executed: return qColorDialogStaticData()->standardRgb; | 0 | ||||||||||||||||||
364 | } | - | ||||||||||||||||||
365 | - | |||||||||||||||||||
366 | QRgb QColorDialogOptions::standardColor(int index) | - | ||||||||||||||||||
367 | { | - | ||||||||||||||||||
368 | if (uint(index) >= uint(QColorDialogStaticData::StandardColorCount))
| 0 | ||||||||||||||||||
369 | return qRgb(255, 255, 255); never executed: return qRgb(255, 255, 255); | 0 | ||||||||||||||||||
370 | return qColorDialogStaticData()->standardRgb[index]; never executed: return qColorDialogStaticData()->standardRgb[index]; | 0 | ||||||||||||||||||
371 | } | - | ||||||||||||||||||
372 | - | |||||||||||||||||||
373 | void QColorDialogOptions::setStandardColor(int index, QRgb color) | - | ||||||||||||||||||
374 | { | - | ||||||||||||||||||
375 | if (uint(index) >= uint(QColorDialogStaticData::StandardColorCount))
| 0 | ||||||||||||||||||
376 | return; never executed: return; | 0 | ||||||||||||||||||
377 | qColorDialogStaticData()->standardRgb[index] = color; | - | ||||||||||||||||||
378 | } never executed: end of block | 0 | ||||||||||||||||||
379 | - | |||||||||||||||||||
380 | /*! | - | ||||||||||||||||||
381 | \class QPlatformColorDialogHelper | - | ||||||||||||||||||
382 | \since 5.0 | - | ||||||||||||||||||
383 | \internal | - | ||||||||||||||||||
384 | \ingroup qpa | - | ||||||||||||||||||
385 | - | |||||||||||||||||||
386 | \brief The QPlatformColorDialogHelper class allows for platform-specific customization of color dialogs. | - | ||||||||||||||||||
387 | - | |||||||||||||||||||
388 | */ | - | ||||||||||||||||||
389 | const QSharedPointer<QColorDialogOptions> &QPlatformColorDialogHelper::options() const | - | ||||||||||||||||||
390 | { | - | ||||||||||||||||||
391 | return m_options; never executed: return m_options; | 0 | ||||||||||||||||||
392 | } | - | ||||||||||||||||||
393 | - | |||||||||||||||||||
394 | void QPlatformColorDialogHelper::setOptions(const QSharedPointer<QColorDialogOptions> &options) | - | ||||||||||||||||||
395 | { | - | ||||||||||||||||||
396 | m_options = options; | - | ||||||||||||||||||
397 | } never executed: end of block | 0 | ||||||||||||||||||
398 | - | |||||||||||||||||||
399 | // File dialog | - | ||||||||||||||||||
400 | - | |||||||||||||||||||
401 | class QFileDialogOptionsPrivate : public QSharedData | - | ||||||||||||||||||
402 | { | - | ||||||||||||||||||
403 | public: | - | ||||||||||||||||||
404 | QFileDialogOptionsPrivate() : options(0), | - | ||||||||||||||||||
405 | viewMode(QFileDialogOptions::Detail), | - | ||||||||||||||||||
406 | fileMode(QFileDialogOptions::AnyFile), | - | ||||||||||||||||||
407 | acceptMode(QFileDialogOptions::AcceptOpen), | - | ||||||||||||||||||
408 | filters(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::AllDirs) | - | ||||||||||||||||||
409 | {} never executed: end of block | 0 | ||||||||||||||||||
410 | - | |||||||||||||||||||
411 | QFileDialogOptions::FileDialogOptions options; | - | ||||||||||||||||||
412 | QString windowTitle; | - | ||||||||||||||||||
413 | - | |||||||||||||||||||
414 | QFileDialogOptions::ViewMode viewMode; | - | ||||||||||||||||||
415 | QFileDialogOptions::FileMode fileMode; | - | ||||||||||||||||||
416 | QFileDialogOptions::AcceptMode acceptMode; | - | ||||||||||||||||||
417 | QString labels[QFileDialogOptions::DialogLabelCount]; | - | ||||||||||||||||||
418 | QDir::Filters filters; | - | ||||||||||||||||||
419 | QList<QUrl> sidebarUrls; | - | ||||||||||||||||||
420 | QStringList nameFilters; | - | ||||||||||||||||||
421 | QStringList mimeTypeFilters; | - | ||||||||||||||||||
422 | QString defaultSuffix; | - | ||||||||||||||||||
423 | QStringList history; | - | ||||||||||||||||||
424 | QUrl initialDirectory; | - | ||||||||||||||||||
425 | QString initiallySelectedNameFilter; | - | ||||||||||||||||||
426 | QList<QUrl> initiallySelectedFiles; | - | ||||||||||||||||||
427 | QStringList supportedSchemes; | - | ||||||||||||||||||
428 | }; | - | ||||||||||||||||||
429 | - | |||||||||||||||||||
430 | QFileDialogOptions::QFileDialogOptions() : d(new QFileDialogOptionsPrivate) | - | ||||||||||||||||||
431 | { | - | ||||||||||||||||||
432 | } never executed: end of block | 0 | ||||||||||||||||||
433 | - | |||||||||||||||||||
434 | QFileDialogOptions::QFileDialogOptions(const QFileDialogOptions &rhs) : d(rhs.d) | - | ||||||||||||||||||
435 | { | - | ||||||||||||||||||
436 | } never executed: end of block | 0 | ||||||||||||||||||
437 | - | |||||||||||||||||||
438 | QFileDialogOptions &QFileDialogOptions::operator=(const QFileDialogOptions &rhs) | - | ||||||||||||||||||
439 | { | - | ||||||||||||||||||
440 | if (this != &rhs)
| 0 | ||||||||||||||||||
441 | d = rhs.d; never executed: d = rhs.d; | 0 | ||||||||||||||||||
442 | return *this; never executed: return *this; | 0 | ||||||||||||||||||
443 | } | - | ||||||||||||||||||
444 | - | |||||||||||||||||||
445 | QFileDialogOptions::~QFileDialogOptions() | - | ||||||||||||||||||
446 | { | - | ||||||||||||||||||
447 | } | - | ||||||||||||||||||
448 | - | |||||||||||||||||||
449 | QString QFileDialogOptions::windowTitle() const | - | ||||||||||||||||||
450 | { | - | ||||||||||||||||||
451 | return d->windowTitle; never executed: return d->windowTitle; | 0 | ||||||||||||||||||
452 | } | - | ||||||||||||||||||
453 | - | |||||||||||||||||||
454 | void QFileDialogOptions::setWindowTitle(const QString &title) | - | ||||||||||||||||||
455 | { | - | ||||||||||||||||||
456 | d->windowTitle = title; | - | ||||||||||||||||||
457 | } never executed: end of block | 0 | ||||||||||||||||||
458 | - | |||||||||||||||||||
459 | void QFileDialogOptions::setOption(QFileDialogOptions::FileDialogOption option, bool on) | - | ||||||||||||||||||
460 | { | - | ||||||||||||||||||
461 | if (!(d->options & option) != !on)
| 0 | ||||||||||||||||||
462 | setOptions(d->options ^ option); never executed: setOptions(d->options ^ option); | 0 | ||||||||||||||||||
463 | } never executed: end of block | 0 | ||||||||||||||||||
464 | - | |||||||||||||||||||
465 | bool QFileDialogOptions::testOption(QFileDialogOptions::FileDialogOption option) const | - | ||||||||||||||||||
466 | { | - | ||||||||||||||||||
467 | return d->options & option; never executed: return d->options & option; | 0 | ||||||||||||||||||
468 | } | - | ||||||||||||||||||
469 | - | |||||||||||||||||||
470 | void QFileDialogOptions::setOptions(FileDialogOptions options) | - | ||||||||||||||||||
471 | { | - | ||||||||||||||||||
472 | if (options != d->options)
| 0 | ||||||||||||||||||
473 | d->options = options; never executed: d->options = options; | 0 | ||||||||||||||||||
474 | } never executed: end of block | 0 | ||||||||||||||||||
475 | - | |||||||||||||||||||
476 | QFileDialogOptions::FileDialogOptions QFileDialogOptions::options() const | - | ||||||||||||||||||
477 | { | - | ||||||||||||||||||
478 | return d->options; never executed: return d->options; | 0 | ||||||||||||||||||
479 | } | - | ||||||||||||||||||
480 | - | |||||||||||||||||||
481 | QDir::Filters QFileDialogOptions::filter() const | - | ||||||||||||||||||
482 | { | - | ||||||||||||||||||
483 | return d->filters; never executed: return d->filters; | 0 | ||||||||||||||||||
484 | } | - | ||||||||||||||||||
485 | - | |||||||||||||||||||
486 | void QFileDialogOptions::setFilter(QDir::Filters filters) | - | ||||||||||||||||||
487 | { | - | ||||||||||||||||||
488 | d->filters = filters; | - | ||||||||||||||||||
489 | } never executed: end of block | 0 | ||||||||||||||||||
490 | - | |||||||||||||||||||
491 | void QFileDialogOptions::setViewMode(QFileDialogOptions::ViewMode mode) | - | ||||||||||||||||||
492 | { | - | ||||||||||||||||||
493 | d->viewMode = mode; | - | ||||||||||||||||||
494 | } never executed: end of block | 0 | ||||||||||||||||||
495 | - | |||||||||||||||||||
496 | QFileDialogOptions::ViewMode QFileDialogOptions::viewMode() const | - | ||||||||||||||||||
497 | { | - | ||||||||||||||||||
498 | return d->viewMode; never executed: return d->viewMode; | 0 | ||||||||||||||||||
499 | } | - | ||||||||||||||||||
500 | - | |||||||||||||||||||
501 | void QFileDialogOptions::setFileMode(QFileDialogOptions::FileMode mode) | - | ||||||||||||||||||
502 | { | - | ||||||||||||||||||
503 | d->fileMode = mode; | - | ||||||||||||||||||
504 | } never executed: end of block | 0 | ||||||||||||||||||
505 | - | |||||||||||||||||||
506 | QFileDialogOptions::FileMode QFileDialogOptions::fileMode() const | - | ||||||||||||||||||
507 | { | - | ||||||||||||||||||
508 | return d->fileMode; never executed: return d->fileMode; | 0 | ||||||||||||||||||
509 | } | - | ||||||||||||||||||
510 | - | |||||||||||||||||||
511 | void QFileDialogOptions::setAcceptMode(QFileDialogOptions::AcceptMode mode) | - | ||||||||||||||||||
512 | { | - | ||||||||||||||||||
513 | d->acceptMode = mode; | - | ||||||||||||||||||
514 | } never executed: end of block | 0 | ||||||||||||||||||
515 | - | |||||||||||||||||||
516 | QFileDialogOptions::AcceptMode QFileDialogOptions::acceptMode() const | - | ||||||||||||||||||
517 | { | - | ||||||||||||||||||
518 | return d->acceptMode; never executed: return d->acceptMode; | 0 | ||||||||||||||||||
519 | } | - | ||||||||||||||||||
520 | - | |||||||||||||||||||
521 | void QFileDialogOptions::setSidebarUrls(const QList<QUrl> &urls) | - | ||||||||||||||||||
522 | { | - | ||||||||||||||||||
523 | d->sidebarUrls = urls; | - | ||||||||||||||||||
524 | } never executed: end of block | 0 | ||||||||||||||||||
525 | - | |||||||||||||||||||
526 | QList<QUrl> QFileDialogOptions::sidebarUrls() const | - | ||||||||||||||||||
527 | { | - | ||||||||||||||||||
528 | return d->sidebarUrls; never executed: return d->sidebarUrls; | 0 | ||||||||||||||||||
529 | } | - | ||||||||||||||||||
530 | - | |||||||||||||||||||
531 | void QFileDialogOptions::setNameFilters(const QStringList &filters) | - | ||||||||||||||||||
532 | { | - | ||||||||||||||||||
533 | d->nameFilters = filters; | - | ||||||||||||||||||
534 | } never executed: end of block | 0 | ||||||||||||||||||
535 | - | |||||||||||||||||||
536 | QStringList QFileDialogOptions::nameFilters() const | - | ||||||||||||||||||
537 | { | - | ||||||||||||||||||
538 | return d->nameFilters; never executed: return d->nameFilters; | 0 | ||||||||||||||||||
539 | } | - | ||||||||||||||||||
540 | - | |||||||||||||||||||
541 | void QFileDialogOptions::setMimeTypeFilters(const QStringList &filters) | - | ||||||||||||||||||
542 | { | - | ||||||||||||||||||
543 | d->mimeTypeFilters = filters; | - | ||||||||||||||||||
544 | } never executed: end of block | 0 | ||||||||||||||||||
545 | - | |||||||||||||||||||
546 | QStringList QFileDialogOptions::mimeTypeFilters() const | - | ||||||||||||||||||
547 | { | - | ||||||||||||||||||
548 | return d->mimeTypeFilters; never executed: return d->mimeTypeFilters; | 0 | ||||||||||||||||||
549 | } | - | ||||||||||||||||||
550 | - | |||||||||||||||||||
551 | void QFileDialogOptions::setDefaultSuffix(const QString &suffix) | - | ||||||||||||||||||
552 | { | - | ||||||||||||||||||
553 | d->defaultSuffix = suffix; | - | ||||||||||||||||||
554 | if (d->defaultSuffix.size() > 1 && d->defaultSuffix.startsWith(QLatin1Char('.')))
| 0 | ||||||||||||||||||
555 | d->defaultSuffix.remove(0, 1); // Silently change ".txt" -> "txt". never executed: d->defaultSuffix.remove(0, 1); | 0 | ||||||||||||||||||
556 | } never executed: end of block | 0 | ||||||||||||||||||
557 | - | |||||||||||||||||||
558 | QString QFileDialogOptions::defaultSuffix() const | - | ||||||||||||||||||
559 | { | - | ||||||||||||||||||
560 | return d->defaultSuffix; never executed: return d->defaultSuffix; | 0 | ||||||||||||||||||
561 | } | - | ||||||||||||||||||
562 | - | |||||||||||||||||||
563 | void QFileDialogOptions::setHistory(const QStringList &paths) | - | ||||||||||||||||||
564 | { | - | ||||||||||||||||||
565 | d->history = paths; | - | ||||||||||||||||||
566 | } never executed: end of block | 0 | ||||||||||||||||||
567 | - | |||||||||||||||||||
568 | QStringList QFileDialogOptions::history() const | - | ||||||||||||||||||
569 | { | - | ||||||||||||||||||
570 | return d->history; never executed: return d->history; | 0 | ||||||||||||||||||
571 | } | - | ||||||||||||||||||
572 | - | |||||||||||||||||||
573 | void QFileDialogOptions::setLabelText(QFileDialogOptions::DialogLabel label, const QString &text) | - | ||||||||||||||||||
574 | { | - | ||||||||||||||||||
575 | if (label >= 0 && label < DialogLabelCount)
| 0 | ||||||||||||||||||
576 | d->labels[label] = text; never executed: d->labels[label] = text; | 0 | ||||||||||||||||||
577 | } never executed: end of block | 0 | ||||||||||||||||||
578 | - | |||||||||||||||||||
579 | QString QFileDialogOptions::labelText(QFileDialogOptions::DialogLabel label) const | - | ||||||||||||||||||
580 | { | - | ||||||||||||||||||
581 | return (label >= 0 && label < DialogLabelCount) ? d->labels[label] : QString(); never executed: return (label >= 0 && label < DialogLabelCount) ? d->labels[label] : QString();
| 0 | ||||||||||||||||||
582 | } | - | ||||||||||||||||||
583 | - | |||||||||||||||||||
584 | bool QFileDialogOptions::isLabelExplicitlySet(DialogLabel label) | - | ||||||||||||||||||
585 | { | - | ||||||||||||||||||
586 | return label >= 0 && label < DialogLabelCount && !d->labels[label].isEmpty(); never executed: return label >= 0 && label < DialogLabelCount && !d->labels[label].isEmpty();
| 0 | ||||||||||||||||||
587 | } | - | ||||||||||||||||||
588 | - | |||||||||||||||||||
589 | QUrl QFileDialogOptions::initialDirectory() const | - | ||||||||||||||||||
590 | { | - | ||||||||||||||||||
591 | return d->initialDirectory; never executed: return d->initialDirectory; | 0 | ||||||||||||||||||
592 | } | - | ||||||||||||||||||
593 | - | |||||||||||||||||||
594 | void QFileDialogOptions::setInitialDirectory(const QUrl &directory) | - | ||||||||||||||||||
595 | { | - | ||||||||||||||||||
596 | d->initialDirectory = directory; | - | ||||||||||||||||||
597 | } never executed: end of block | 0 | ||||||||||||||||||
598 | - | |||||||||||||||||||
599 | QString QFileDialogOptions::initiallySelectedNameFilter() const | - | ||||||||||||||||||
600 | { | - | ||||||||||||||||||
601 | return d->initiallySelectedNameFilter; never executed: return d->initiallySelectedNameFilter; | 0 | ||||||||||||||||||
602 | } | - | ||||||||||||||||||
603 | - | |||||||||||||||||||
604 | void QFileDialogOptions::setInitiallySelectedNameFilter(const QString &filter) | - | ||||||||||||||||||
605 | { | - | ||||||||||||||||||
606 | d->initiallySelectedNameFilter = filter; | - | ||||||||||||||||||
607 | } never executed: end of block | 0 | ||||||||||||||||||
608 | - | |||||||||||||||||||
609 | QList<QUrl> QFileDialogOptions::initiallySelectedFiles() const | - | ||||||||||||||||||
610 | { | - | ||||||||||||||||||
611 | return d->initiallySelectedFiles; never executed: return d->initiallySelectedFiles; | 0 | ||||||||||||||||||
612 | } | - | ||||||||||||||||||
613 | - | |||||||||||||||||||
614 | void QFileDialogOptions::setInitiallySelectedFiles(const QList<QUrl> &files) | - | ||||||||||||||||||
615 | { | - | ||||||||||||||||||
616 | d->initiallySelectedFiles = files; | - | ||||||||||||||||||
617 | } never executed: end of block | 0 | ||||||||||||||||||
618 | - | |||||||||||||||||||
619 | // Schemes supported by the application | - | ||||||||||||||||||
620 | void QFileDialogOptions::setSupportedSchemes(const QStringList &schemes) | - | ||||||||||||||||||
621 | { | - | ||||||||||||||||||
622 | d->supportedSchemes = schemes; | - | ||||||||||||||||||
623 | } never executed: end of block | 0 | ||||||||||||||||||
624 | - | |||||||||||||||||||
625 | QStringList QFileDialogOptions::supportedSchemes() const | - | ||||||||||||||||||
626 | { | - | ||||||||||||||||||
627 | return d->supportedSchemes; never executed: return d->supportedSchemes; | 0 | ||||||||||||||||||
628 | } | - | ||||||||||||||||||
629 | - | |||||||||||||||||||
630 | // Return true if the URL is supported by the filedialog implementation *and* by the application. | - | ||||||||||||||||||
631 | bool QPlatformFileDialogHelper::isSupportedUrl(const QUrl &url) const | - | ||||||||||||||||||
632 | { | - | ||||||||||||||||||
633 | return url.isLocalFile(); never executed: return url.isLocalFile(); | 0 | ||||||||||||||||||
634 | } | - | ||||||||||||||||||
635 | - | |||||||||||||||||||
636 | /*! | - | ||||||||||||||||||
637 | \class QPlatformFileDialogHelper | - | ||||||||||||||||||
638 | \since 5.0 | - | ||||||||||||||||||
639 | \internal | - | ||||||||||||||||||
640 | \ingroup qpa | - | ||||||||||||||||||
641 | - | |||||||||||||||||||
642 | \brief The QPlatformFileDialogHelper class allows for platform-specific customization of file dialogs. | - | ||||||||||||||||||
643 | - | |||||||||||||||||||
644 | */ | - | ||||||||||||||||||
645 | const QSharedPointer<QFileDialogOptions> &QPlatformFileDialogHelper::options() const | - | ||||||||||||||||||
646 | { | - | ||||||||||||||||||
647 | return m_options; never executed: return m_options; | 0 | ||||||||||||||||||
648 | } | - | ||||||||||||||||||
649 | - | |||||||||||||||||||
650 | void QPlatformFileDialogHelper::setOptions(const QSharedPointer<QFileDialogOptions> &options) | - | ||||||||||||||||||
651 | { | - | ||||||||||||||||||
652 | m_options = options; | - | ||||||||||||||||||
653 | } never executed: end of block | 0 | ||||||||||||||||||
654 | - | |||||||||||||||||||
655 | const char *QPlatformFileDialogHelper::filterRegExp = | - | ||||||||||||||||||
656 | "^(.*)\\(([a-zA-Z0-9_.,*? +;#\\-\\[\\]@\\{\\}/!<>\\$%&=^~:\\|]*)\\)$"; | - | ||||||||||||||||||
657 | - | |||||||||||||||||||
658 | // Makes a list of filters from a normal filter string "Image Files (*.png *.jpg)" | - | ||||||||||||||||||
659 | QStringList QPlatformFileDialogHelper::cleanFilterList(const QString &filter) | - | ||||||||||||||||||
660 | { | - | ||||||||||||||||||
661 | QRegExp regexp(QString::fromLatin1(filterRegExp)); | - | ||||||||||||||||||
662 | Q_ASSERT(regexp.isValid()); | - | ||||||||||||||||||
663 | QString f = filter; | - | ||||||||||||||||||
664 | int i = regexp.indexIn(f); | - | ||||||||||||||||||
665 | if (i >= 0)
| 0 | ||||||||||||||||||
666 | f = regexp.cap(2); never executed: f = regexp.cap(2); | 0 | ||||||||||||||||||
667 | return f.split(QLatin1Char(' '), QString::SkipEmptyParts); never executed: return f.split(QLatin1Char(' '), QString::SkipEmptyParts); | 0 | ||||||||||||||||||
668 | } | - | ||||||||||||||||||
669 | - | |||||||||||||||||||
670 | // Message dialog | - | ||||||||||||||||||
671 | - | |||||||||||||||||||
672 | class QMessageDialogOptionsPrivate : public QSharedData | - | ||||||||||||||||||
673 | { | - | ||||||||||||||||||
674 | public: | - | ||||||||||||||||||
675 | QMessageDialogOptionsPrivate() : | - | ||||||||||||||||||
676 | icon(QMessageDialogOptions::NoIcon), | - | ||||||||||||||||||
677 | buttons(QPlatformDialogHelper::Ok) | - | ||||||||||||||||||
678 | {} never executed: end of block | 0 | ||||||||||||||||||
679 | - | |||||||||||||||||||
680 | QString windowTitle; | - | ||||||||||||||||||
681 | QMessageDialogOptions::Icon icon; | - | ||||||||||||||||||
682 | QString text; | - | ||||||||||||||||||
683 | QString informativeText; | - | ||||||||||||||||||
684 | QString detailedText; | - | ||||||||||||||||||
685 | QPlatformDialogHelper::StandardButtons buttons; | - | ||||||||||||||||||
686 | }; | - | ||||||||||||||||||
687 | - | |||||||||||||||||||
688 | QMessageDialogOptions::QMessageDialogOptions() : d(new QMessageDialogOptionsPrivate) | - | ||||||||||||||||||
689 | { | - | ||||||||||||||||||
690 | } never executed: end of block | 0 | ||||||||||||||||||
691 | - | |||||||||||||||||||
692 | QMessageDialogOptions::QMessageDialogOptions(const QMessageDialogOptions &rhs) : d(rhs.d) | - | ||||||||||||||||||
693 | { | - | ||||||||||||||||||
694 | } never executed: end of block | 0 | ||||||||||||||||||
695 | - | |||||||||||||||||||
696 | QMessageDialogOptions &QMessageDialogOptions::operator=(const QMessageDialogOptions &rhs) | - | ||||||||||||||||||
697 | { | - | ||||||||||||||||||
698 | if (this != &rhs)
| 0 | ||||||||||||||||||
699 | d = rhs.d; never executed: d = rhs.d; | 0 | ||||||||||||||||||
700 | return *this; never executed: return *this; | 0 | ||||||||||||||||||
701 | } | - | ||||||||||||||||||
702 | - | |||||||||||||||||||
703 | QMessageDialogOptions::~QMessageDialogOptions() | - | ||||||||||||||||||
704 | { | - | ||||||||||||||||||
705 | } | - | ||||||||||||||||||
706 | - | |||||||||||||||||||
707 | QString QMessageDialogOptions::windowTitle() const | - | ||||||||||||||||||
708 | { | - | ||||||||||||||||||
709 | return d->windowTitle; never executed: return d->windowTitle; | 0 | ||||||||||||||||||
710 | } | - | ||||||||||||||||||
711 | - | |||||||||||||||||||
712 | void QMessageDialogOptions::setWindowTitle(const QString &title) | - | ||||||||||||||||||
713 | { | - | ||||||||||||||||||
714 | d->windowTitle = title; | - | ||||||||||||||||||
715 | } never executed: end of block | 0 | ||||||||||||||||||
716 | - | |||||||||||||||||||
717 | QMessageDialogOptions::Icon QMessageDialogOptions::icon() const | - | ||||||||||||||||||
718 | { | - | ||||||||||||||||||
719 | return d->icon; never executed: return d->icon; | 0 | ||||||||||||||||||
720 | } | - | ||||||||||||||||||
721 | - | |||||||||||||||||||
722 | void QMessageDialogOptions::setIcon(Icon icon) | - | ||||||||||||||||||
723 | { | - | ||||||||||||||||||
724 | d->icon = icon; | - | ||||||||||||||||||
725 | } never executed: end of block | 0 | ||||||||||||||||||
726 | - | |||||||||||||||||||
727 | QString QMessageDialogOptions::text() const | - | ||||||||||||||||||
728 | { | - | ||||||||||||||||||
729 | return d->text; never executed: return d->text; | 0 | ||||||||||||||||||
730 | } | - | ||||||||||||||||||
731 | - | |||||||||||||||||||
732 | void QMessageDialogOptions::setText(const QString &text) | - | ||||||||||||||||||
733 | { | - | ||||||||||||||||||
734 | d->text = text; | - | ||||||||||||||||||
735 | } never executed: end of block | 0 | ||||||||||||||||||
736 | - | |||||||||||||||||||
737 | QString QMessageDialogOptions::informativeText() const | - | ||||||||||||||||||
738 | { | - | ||||||||||||||||||
739 | return d->informativeText; never executed: return d->informativeText; | 0 | ||||||||||||||||||
740 | } | - | ||||||||||||||||||
741 | - | |||||||||||||||||||
742 | void QMessageDialogOptions::setInformativeText(const QString &informativeText) | - | ||||||||||||||||||
743 | { | - | ||||||||||||||||||
744 | d->informativeText = informativeText; | - | ||||||||||||||||||
745 | } never executed: end of block | 0 | ||||||||||||||||||
746 | - | |||||||||||||||||||
747 | QString QMessageDialogOptions::detailedText() const | - | ||||||||||||||||||
748 | { | - | ||||||||||||||||||
749 | return d->detailedText; never executed: return d->detailedText; | 0 | ||||||||||||||||||
750 | } | - | ||||||||||||||||||
751 | - | |||||||||||||||||||
752 | void QMessageDialogOptions::setDetailedText(const QString &detailedText) | - | ||||||||||||||||||
753 | { | - | ||||||||||||||||||
754 | d->detailedText = detailedText; | - | ||||||||||||||||||
755 | } never executed: end of block | 0 | ||||||||||||||||||
756 | - | |||||||||||||||||||
757 | void QMessageDialogOptions::setStandardButtons(QPlatformDialogHelper::StandardButtons buttons) | - | ||||||||||||||||||
758 | { | - | ||||||||||||||||||
759 | d->buttons = buttons; | - | ||||||||||||||||||
760 | } never executed: end of block | 0 | ||||||||||||||||||
761 | - | |||||||||||||||||||
762 | QPlatformDialogHelper::StandardButtons QMessageDialogOptions::standardButtons() const | - | ||||||||||||||||||
763 | { | - | ||||||||||||||||||
764 | return d->buttons; never executed: return d->buttons; | 0 | ||||||||||||||||||
765 | } | - | ||||||||||||||||||
766 | - | |||||||||||||||||||
767 | QPlatformDialogHelper::ButtonRole QPlatformDialogHelper::buttonRole(QPlatformDialogHelper::StandardButton button) | - | ||||||||||||||||||
768 | { | - | ||||||||||||||||||
769 | switch (button) { | - | ||||||||||||||||||
770 | case Ok: never executed: case Ok: | 0 | ||||||||||||||||||
771 | case Save: never executed: case Save: | 0 | ||||||||||||||||||
772 | case Open: never executed: case Open: | 0 | ||||||||||||||||||
773 | case SaveAll: never executed: case SaveAll: | 0 | ||||||||||||||||||
774 | case Retry: never executed: case Retry: | 0 | ||||||||||||||||||
775 | case Ignore: never executed: case Ignore: | 0 | ||||||||||||||||||
776 | return AcceptRole; never executed: return AcceptRole; | 0 | ||||||||||||||||||
777 | - | |||||||||||||||||||
778 | case Cancel: never executed: case Cancel: | 0 | ||||||||||||||||||
779 | case Close: never executed: case Close: | 0 | ||||||||||||||||||
780 | case Abort: never executed: case Abort: | 0 | ||||||||||||||||||
781 | return RejectRole; never executed: return RejectRole; | 0 | ||||||||||||||||||
782 | - | |||||||||||||||||||
783 | case Discard: never executed: case Discard: | 0 | ||||||||||||||||||
784 | return DestructiveRole; never executed: return DestructiveRole; | 0 | ||||||||||||||||||
785 | - | |||||||||||||||||||
786 | case Help: never executed: case Help: | 0 | ||||||||||||||||||
787 | return HelpRole; never executed: return HelpRole; | 0 | ||||||||||||||||||
788 | - | |||||||||||||||||||
789 | case Apply: never executed: case Apply: | 0 | ||||||||||||||||||
790 | return ApplyRole; never executed: return ApplyRole; | 0 | ||||||||||||||||||
791 | - | |||||||||||||||||||
792 | case Yes: never executed: case Yes: | 0 | ||||||||||||||||||
793 | case YesToAll: never executed: case YesToAll: | 0 | ||||||||||||||||||
794 | return YesRole; never executed: return YesRole; | 0 | ||||||||||||||||||
795 | - | |||||||||||||||||||
796 | case No: never executed: case No: | 0 | ||||||||||||||||||
797 | case NoToAll: never executed: case NoToAll: | 0 | ||||||||||||||||||
798 | return NoRole; never executed: return NoRole; | 0 | ||||||||||||||||||
799 | - | |||||||||||||||||||
800 | case RestoreDefaults: never executed: case RestoreDefaults: | 0 | ||||||||||||||||||
801 | case Reset: never executed: case Reset: | 0 | ||||||||||||||||||
802 | return ResetRole; never executed: return ResetRole; | 0 | ||||||||||||||||||
803 | - | |||||||||||||||||||
804 | default: never executed: default: | 0 | ||||||||||||||||||
805 | break; never executed: break; | 0 | ||||||||||||||||||
806 | } | - | ||||||||||||||||||
807 | return InvalidRole; never executed: return InvalidRole; | 0 | ||||||||||||||||||
808 | } | - | ||||||||||||||||||
809 | - | |||||||||||||||||||
810 | const int *QPlatformDialogHelper::buttonLayout(Qt::Orientation orientation, ButtonLayout policy) | - | ||||||||||||||||||
811 | { | - | ||||||||||||||||||
812 | if (policy == UnknownLayout) {
| 0 | ||||||||||||||||||
813 | #if defined (Q_OS_OSX) | - | ||||||||||||||||||
814 | policy = MacLayout; | - | ||||||||||||||||||
815 | #elif defined (Q_OS_LINUX) || defined (Q_OS_UNIX) | - | ||||||||||||||||||
816 | policy = KdeLayout; | - | ||||||||||||||||||
817 | #else | - | ||||||||||||||||||
818 | policy = WinLayout; | - | ||||||||||||||||||
819 | #endif | - | ||||||||||||||||||
820 | } never executed: end of block | 0 | ||||||||||||||||||
821 | return buttonRoleLayouts[orientation == Qt::Vertical][policy]; never executed: return buttonRoleLayouts[orientation == Qt::Vertical][policy]; | 0 | ||||||||||||||||||
822 | } | - | ||||||||||||||||||
823 | - | |||||||||||||||||||
824 | /*! | - | ||||||||||||||||||
825 | \class QPlatformMessageDialogHelper | - | ||||||||||||||||||
826 | \since 5.0 | - | ||||||||||||||||||
827 | \internal | - | ||||||||||||||||||
828 | \ingroup qpa | - | ||||||||||||||||||
829 | - | |||||||||||||||||||
830 | \brief The QPlatformMessageDialogHelper class allows for platform-specific customization of Message dialogs. | - | ||||||||||||||||||
831 | - | |||||||||||||||||||
832 | */ | - | ||||||||||||||||||
833 | const QSharedPointer<QMessageDialogOptions> &QPlatformMessageDialogHelper::options() const | - | ||||||||||||||||||
834 | { | - | ||||||||||||||||||
835 | return m_options; never executed: return m_options; | 0 | ||||||||||||||||||
836 | } | - | ||||||||||||||||||
837 | - | |||||||||||||||||||
838 | void QPlatformMessageDialogHelper::setOptions(const QSharedPointer<QMessageDialogOptions> &options) | - | ||||||||||||||||||
839 | { | - | ||||||||||||||||||
840 | m_options = options; | - | ||||||||||||||||||
841 | } never executed: end of block | 0 | ||||||||||||||||||
842 | - | |||||||||||||||||||
843 | QT_END_NAMESPACE | - | ||||||||||||||||||
Source code | Switch to Preprocessed file |