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