| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.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 plugins 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 "qgenericunixthemes_p.h" | - | ||||||||||||||||||
| 35 | #include "../../services/genericunix/qgenericunixservices_p.h" | - | ||||||||||||||||||
| 36 | - | |||||||||||||||||||
| 37 | #include "qpa/qplatformtheme_p.h" | - | ||||||||||||||||||
| 38 | - | |||||||||||||||||||
| 39 | #include <QtGui/QPalette> | - | ||||||||||||||||||
| 40 | #include <QtGui/QFont> | - | ||||||||||||||||||
| 41 | #include <QtGui/QGuiApplication> | - | ||||||||||||||||||
| 42 | #include <QtCore/QDir> | - | ||||||||||||||||||
| 43 | #include <QtCore/QFileInfo> | - | ||||||||||||||||||
| 44 | #include <QtCore/QFile> | - | ||||||||||||||||||
| 45 | #include <QtCore/QDebug> | - | ||||||||||||||||||
| 46 | #include <QtCore/QHash> | - | ||||||||||||||||||
| 47 | #include <QtCore/QLoggingCategory> | - | ||||||||||||||||||
| 48 | #include <QtCore/QSettings> | - | ||||||||||||||||||
| 49 | #include <QtCore/QVariant> | - | ||||||||||||||||||
| 50 | #include <QtCore/QStandardPaths> | - | ||||||||||||||||||
| 51 | #include <QtCore/QStringList> | - | ||||||||||||||||||
| 52 | #include <private/qguiapplication_p.h> | - | ||||||||||||||||||
| 53 | #include <qpa/qplatformintegration.h> | - | ||||||||||||||||||
| 54 | #include <qpa/qplatformservices.h> | - | ||||||||||||||||||
| 55 | #include <qpa/qplatformdialoghelper.h> | - | ||||||||||||||||||
| 56 | #if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON) | - | ||||||||||||||||||
| 57 | #include "QtPlatformSupport/private/qdbustrayicon_p.h" | - | ||||||||||||||||||
| 58 | #include "QtPlatformSupport/private/qdbusplatformmenu_p.h" | - | ||||||||||||||||||
| 59 | #endif | - | ||||||||||||||||||
| 60 | - | |||||||||||||||||||
| 61 | #include <algorithm> | - | ||||||||||||||||||
| 62 | - | |||||||||||||||||||
| 63 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
| 64 | - | |||||||||||||||||||
| 65 | Q_DECLARE_LOGGING_CATEGORY(qLcTray) | - | ||||||||||||||||||
| 66 | - | |||||||||||||||||||
| 67 | ResourceHelper::ResourceHelper() | - | ||||||||||||||||||
| 68 | { | - | ||||||||||||||||||
| 69 | std::fill(palettes, palettes + QPlatformTheme::NPalettes, static_cast<QPalette *>(0)); | - | ||||||||||||||||||
| 70 | std::fill(fonts, fonts + QPlatformTheme::NFonts, static_cast<QFont *>(0)); | - | ||||||||||||||||||
| 71 | } never executed: end of block | 0 | ||||||||||||||||||
| 72 | - | |||||||||||||||||||
| 73 | void ResourceHelper::clear() | - | ||||||||||||||||||
| 74 | { | - | ||||||||||||||||||
| 75 | qDeleteAll(palettes, palettes + QPlatformTheme::NPalettes); | - | ||||||||||||||||||
| 76 | qDeleteAll(fonts, fonts + QPlatformTheme::NFonts); | - | ||||||||||||||||||
| 77 | std::fill(palettes, palettes + QPlatformTheme::NPalettes, static_cast<QPalette *>(0)); | - | ||||||||||||||||||
| 78 | std::fill(fonts, fonts + QPlatformTheme::NFonts, static_cast<QFont *>(0)); | - | ||||||||||||||||||
| 79 | } never executed: end of block | 0 | ||||||||||||||||||
| 80 | - | |||||||||||||||||||
| 81 | /*! | - | ||||||||||||||||||
| 82 | \class QGenericX11ThemeQKdeTheme | - | ||||||||||||||||||
| 83 | \brief QGenericX11Theme is a generic theme implementation for X11. | - | ||||||||||||||||||
| 84 | \since 5.0 | - | ||||||||||||||||||
| 85 | \internal | - | ||||||||||||||||||
| 86 | \ingroup qpa | - | ||||||||||||||||||
| 87 | */ | - | ||||||||||||||||||
| 88 | - | |||||||||||||||||||
| 89 | const char *QGenericUnixTheme::name = "generic"; | - | ||||||||||||||||||
| 90 | - | |||||||||||||||||||
| 91 | // Default system font, corresponding to the value returned by 4.8 for | - | ||||||||||||||||||
| 92 | // XRender/FontConfig which we can now assume as default. | - | ||||||||||||||||||
| 93 | static const char defaultSystemFontNameC[] = "Sans Serif"; | - | ||||||||||||||||||
| 94 | enum { defaultSystemFontSize = 9 }; | - | ||||||||||||||||||
| 95 | - | |||||||||||||||||||
| 96 | #if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON) | - | ||||||||||||||||||
| 97 | static bool isDBusTrayAvailable() { | - | ||||||||||||||||||
| 98 | static bool dbusTrayAvailable = false; | - | ||||||||||||||||||
| 99 | static bool dbusTrayAvailableKnown = false; | - | ||||||||||||||||||
| 100 | if (!dbusTrayAvailableKnown) {
| 1-4 | ||||||||||||||||||
| 101 | QDBusMenuConnection conn; | - | ||||||||||||||||||
| 102 | if (conn.isStatusNotifierHostRegistered())
| 0-1 | ||||||||||||||||||
| 103 | dbusTrayAvailable = true; never executed: dbusTrayAvailable = true; | 0 | ||||||||||||||||||
| 104 | dbusTrayAvailableKnown = true; | - | ||||||||||||||||||
| 105 | qCDebug(qLcTray) << "D-Bus tray available:" << dbusTrayAvailable; never executed: QMessageLogger(__FILE__, 105, __PRETTY_FUNCTION__, qLcTray().categoryName()).debug() << "D-Bus tray available:" << dbusTrayAvailable;
| 0-1 | ||||||||||||||||||
| 106 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||
| 107 | return dbusTrayAvailable; executed 5 times by 1 test: return dbusTrayAvailable;Executed by:
| 5 | ||||||||||||||||||
| 108 | } | - | ||||||||||||||||||
| 109 | #endif | - | ||||||||||||||||||
| 110 | - | |||||||||||||||||||
| 111 | class QGenericUnixThemePrivate : public QPlatformThemePrivate | - | ||||||||||||||||||
| 112 | { | - | ||||||||||||||||||
| 113 | public: | - | ||||||||||||||||||
| 114 | QGenericUnixThemePrivate() | - | ||||||||||||||||||
| 115 | : QPlatformThemePrivate() | - | ||||||||||||||||||
| 116 | , systemFont(QLatin1String(defaultSystemFontNameC), defaultSystemFontSize) | - | ||||||||||||||||||
| 117 | , fixedFont(QStringLiteral("monospace"), systemFont.pointSize()) | - | ||||||||||||||||||
| 118 | { | - | ||||||||||||||||||
| 119 | fixedFont.setStyleHint(QFont::TypeWriter); | - | ||||||||||||||||||
| 120 | } executed 129 times by 5 tests: end of blockExecuted by:
| 129 | ||||||||||||||||||
| 121 | - | |||||||||||||||||||
| 122 | const QFont systemFont; | - | ||||||||||||||||||
| 123 | QFont fixedFont; | - | ||||||||||||||||||
| 124 | }; | - | ||||||||||||||||||
| 125 | - | |||||||||||||||||||
| 126 | QGenericUnixTheme::QGenericUnixTheme() | - | ||||||||||||||||||
| 127 | : QPlatformTheme(new QGenericUnixThemePrivate()) | - | ||||||||||||||||||
| 128 | { | - | ||||||||||||||||||
| 129 | } executed 129 times by 5 tests: end of blockExecuted by:
| 129 | ||||||||||||||||||
| 130 | - | |||||||||||||||||||
| 131 | const QFont *QGenericUnixTheme::font(Font type) const | - | ||||||||||||||||||
| 132 | { | - | ||||||||||||||||||
| 133 | Q_D(const QGenericUnixTheme); | - | ||||||||||||||||||
| 134 | switch (type) { | - | ||||||||||||||||||
| 135 | case QPlatformTheme::SystemFont: executed 203 times by 169 tests: case QPlatformTheme::SystemFont:Executed by:
| 203 | ||||||||||||||||||
| 136 | return &d->systemFont; executed 203 times by 169 tests: return &d->systemFont;Executed by:
| 203 | ||||||||||||||||||
| 137 | case QPlatformTheme::FixedFont: executed 275 times by 2 tests: case QPlatformTheme::FixedFont:Executed by:
| 275 | ||||||||||||||||||
| 138 | return &d->fixedFont; executed 275 times by 2 tests: return &d->fixedFont;Executed by:
| 275 | ||||||||||||||||||
| 139 | default: executed 4466 times by 14 tests: default:Executed by:
| 4466 | ||||||||||||||||||
| 140 | return 0; executed 4466 times by 14 tests: return 0;Executed by:
| 4466 | ||||||||||||||||||
| 141 | } | - | ||||||||||||||||||
| 142 | } | - | ||||||||||||||||||
| 143 | - | |||||||||||||||||||
| 144 | // Helper to return the icon theme paths from XDG. | - | ||||||||||||||||||
| 145 | QStringList QGenericUnixTheme::xdgIconThemePaths() | - | ||||||||||||||||||
| 146 | { | - | ||||||||||||||||||
| 147 | QStringList paths; | - | ||||||||||||||||||
| 148 | // Add home directory first in search path | - | ||||||||||||||||||
| 149 | const QFileInfo homeIconDir(QDir::homePath() + QStringLiteral("/.icons")); executed 25 times by 25 tests: return qstring_literal_temp;Executed by:
| 25 | ||||||||||||||||||
| 150 | if (homeIconDir.isDir())
| 0-25 | ||||||||||||||||||
| 151 | paths.prepend(homeIconDir.absoluteFilePath()); never executed: paths.prepend(homeIconDir.absoluteFilePath()); | 0 | ||||||||||||||||||
| 152 | - | |||||||||||||||||||
| 153 | QString xdgDirString = QFile::decodeName(qgetenv("XDG_DATA_DIRS")); | - | ||||||||||||||||||
| 154 | if (xdgDirString.isEmpty())
| 0-25 | ||||||||||||||||||
| 155 | xdgDirString = QLatin1String("/usr/local/share/:/usr/share/"); executed 25 times by 25 tests: xdgDirString = QLatin1String("/usr/local/share/:/usr/share/");Executed by:
| 25 | ||||||||||||||||||
| 156 | foreach (const QString &xdgDir, xdgDirString.split(QLatin1Char(':'))) { | - | ||||||||||||||||||
| 157 | const QFileInfo xdgIconsDir(xdgDir + QStringLiteral("/icons")); executed 50 times by 25 tests: return qstring_literal_temp;Executed by:
| 50 | ||||||||||||||||||
| 158 | if (xdgIconsDir.isDir())
| 25 | ||||||||||||||||||
| 159 | paths.append(xdgIconsDir.absoluteFilePath()); executed 25 times by 25 tests: paths.append(xdgIconsDir.absoluteFilePath());Executed by:
| 25 | ||||||||||||||||||
| 160 | } executed 50 times by 25 tests: end of blockExecuted by:
| 50 | ||||||||||||||||||
| 161 | - | |||||||||||||||||||
| 162 | const QFileInfo pixmapsIconsDir(QStringLiteral("/usr/share/pixmaps")); executed 25 times by 25 tests: return qstring_literal_temp;Executed by:
| 25 | ||||||||||||||||||
| 163 | if (pixmapsIconsDir.isDir())
| 0-25 | ||||||||||||||||||
| 164 | paths.append(pixmapsIconsDir.absoluteFilePath()); executed 25 times by 25 tests: paths.append(pixmapsIconsDir.absoluteFilePath());Executed by:
| 25 | ||||||||||||||||||
| 165 | - | |||||||||||||||||||
| 166 | return paths; executed 25 times by 25 tests: return paths;Executed by:
| 25 | ||||||||||||||||||
| 167 | } | - | ||||||||||||||||||
| 168 | - | |||||||||||||||||||
| 169 | #if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON) | - | ||||||||||||||||||
| 170 | QPlatformSystemTrayIcon *QGenericUnixTheme::createPlatformSystemTrayIcon() const | - | ||||||||||||||||||
| 171 | { | - | ||||||||||||||||||
| 172 | if (isDBusTrayAvailable())
| 0-5 | ||||||||||||||||||
| 173 | return new QDBusTrayIcon(); never executed: return new QDBusTrayIcon(); | 0 | ||||||||||||||||||
| 174 | return Q_NULLPTR; executed 5 times by 1 test: return nullptr;Executed by:
| 5 | ||||||||||||||||||
| 175 | } | - | ||||||||||||||||||
| 176 | #endif | - | ||||||||||||||||||
| 177 | - | |||||||||||||||||||
| 178 | QVariant QGenericUnixTheme::themeHint(ThemeHint hint) const | - | ||||||||||||||||||
| 179 | { | - | ||||||||||||||||||
| 180 | switch (hint) { | - | ||||||||||||||||||
| 181 | case QPlatformTheme::SystemIconFallbackThemeName: executed 76 times by 42 tests: case QPlatformTheme::SystemIconFallbackThemeName:Executed by:
| 76 | ||||||||||||||||||
| 182 | return QVariant(QString(QStringLiteral("hicolor"))); executed 76 times by 42 tests: return QVariant(QString(([]() -> QString { enum { Size = sizeof(u"" "hicolor")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "hicolor" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())));Executed by:
executed 76 times by 42 tests: return qstring_literal_temp;Executed by:
| 76 | ||||||||||||||||||
| 183 | case QPlatformTheme::IconThemeSearchPaths: executed 25 times by 25 tests: case QPlatformTheme::IconThemeSearchPaths:Executed by:
| 25 | ||||||||||||||||||
| 184 | return xdgIconThemePaths(); executed 25 times by 25 tests: return xdgIconThemePaths();Executed by:
| 25 | ||||||||||||||||||
| 185 | case QPlatformTheme::DialogButtonBoxButtonsHaveIcons: executed 2 times by 1 test: case QPlatformTheme::DialogButtonBoxButtonsHaveIcons:Executed by:
| 2 | ||||||||||||||||||
| 186 | return QVariant(true); executed 2 times by 1 test: return QVariant(true);Executed by:
| 2 | ||||||||||||||||||
| 187 | case QPlatformTheme::StyleNames: { executed 198 times by 17 tests: case QPlatformTheme::StyleNames:Executed by:
| 198 | ||||||||||||||||||
| 188 | QStringList styleNames; | - | ||||||||||||||||||
| 189 | styleNames << QStringLiteral("Fusion") << QStringLiteral("Windows"); executed 198 times by 17 tests: return qstring_literal_temp;Executed by:
executed 198 times by 17 tests: return qstring_literal_temp;Executed by:
| 198 | ||||||||||||||||||
| 190 | return QVariant(styleNames); executed 198 times by 17 tests: return QVariant(styleNames);Executed by:
| 198 | ||||||||||||||||||
| 191 | } | - | ||||||||||||||||||
| 192 | case QPlatformTheme::KeyboardScheme: executed 210688 times by 75 tests: case QPlatformTheme::KeyboardScheme:Executed by:
| 210688 | ||||||||||||||||||
| 193 | return QVariant(int(X11KeyboardScheme)); executed 210688 times by 75 tests: return QVariant(int(X11KeyboardScheme));Executed by:
| 210688 | ||||||||||||||||||
| 194 | default: executed 26600 times by 117 tests: default:Executed by:
| 26600 | ||||||||||||||||||
| 195 | break; executed 26600 times by 117 tests: break;Executed by:
| 26600 | ||||||||||||||||||
| 196 | } | - | ||||||||||||||||||
| 197 | return QPlatformTheme::themeHint(hint); executed 26600 times by 117 tests: return QPlatformTheme::themeHint(hint);Executed by:
| 26600 | ||||||||||||||||||
| 198 | } | - | ||||||||||||||||||
| 199 | - | |||||||||||||||||||
| 200 | #ifndef QT_NO_SETTINGS | - | ||||||||||||||||||
| 201 | class QKdeThemePrivate : public QPlatformThemePrivate | - | ||||||||||||||||||
| 202 | { | - | ||||||||||||||||||
| 203 | public: | - | ||||||||||||||||||
| 204 | QKdeThemePrivate(const QStringList &kdeDirs, int kdeVersion) | - | ||||||||||||||||||
| 205 | : kdeDirs(kdeDirs) | - | ||||||||||||||||||
| 206 | , kdeVersion(kdeVersion) | - | ||||||||||||||||||
| 207 | , toolButtonStyle(Qt::ToolButtonTextBesideIcon) | - | ||||||||||||||||||
| 208 | , toolBarIconSize(0) | - | ||||||||||||||||||
| 209 | , singleClick(true) | - | ||||||||||||||||||
| 210 | , wheelScrollLines(3) | - | ||||||||||||||||||
| 211 | { } never executed: end of block | 0 | ||||||||||||||||||
| 212 | - | |||||||||||||||||||
| 213 | static QString kdeGlobals(const QString &kdeDir, int kdeVersion) | - | ||||||||||||||||||
| 214 | { | - | ||||||||||||||||||
| 215 | if (kdeVersion > 4)
| 0 | ||||||||||||||||||
| 216 | return kdeDir + QStringLiteral("/kdeglobals"); never executed: return kdeDir + ([]() -> QString { enum { Size = sizeof(u"" "/kdeglobals")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "/kdeglobals" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 217 | return kdeDir + QStringLiteral("/share/config/kdeglobals"); never executed: return kdeDir + ([]() -> QString { enum { Size = sizeof(u"" "/share/config/kdeglobals")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "/share/config/kdeglobals" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 218 | } | - | ||||||||||||||||||
| 219 | - | |||||||||||||||||||
| 220 | void refresh(); | - | ||||||||||||||||||
| 221 | static QVariant readKdeSetting(const QString &key, const QStringList &kdeDirs, int kdeVersion, QHash<QString, QSettings*> &kdeSettings); | - | ||||||||||||||||||
| 222 | static void readKdeSystemPalette(const QStringList &kdeDirs, int kdeVersion, QHash<QString, QSettings*> &kdeSettings, QPalette *pal); | - | ||||||||||||||||||
| 223 | static QFont *kdeFont(const QVariant &fontValue); | - | ||||||||||||||||||
| 224 | static QStringList kdeIconThemeSearchPaths(const QStringList &kdeDirs); | - | ||||||||||||||||||
| 225 | - | |||||||||||||||||||
| 226 | const QStringList kdeDirs; | - | ||||||||||||||||||
| 227 | const int kdeVersion; | - | ||||||||||||||||||
| 228 | - | |||||||||||||||||||
| 229 | ResourceHelper resources; | - | ||||||||||||||||||
| 230 | QString iconThemeName; | - | ||||||||||||||||||
| 231 | QString iconFallbackThemeName; | - | ||||||||||||||||||
| 232 | QStringList styleNames; | - | ||||||||||||||||||
| 233 | int toolButtonStyle; | - | ||||||||||||||||||
| 234 | int toolBarIconSize; | - | ||||||||||||||||||
| 235 | bool singleClick; | - | ||||||||||||||||||
| 236 | int wheelScrollLines; | - | ||||||||||||||||||
| 237 | }; | - | ||||||||||||||||||
| 238 | - | |||||||||||||||||||
| 239 | void QKdeThemePrivate::refresh() | - | ||||||||||||||||||
| 240 | { | - | ||||||||||||||||||
| 241 | resources.clear(); | - | ||||||||||||||||||
| 242 | - | |||||||||||||||||||
| 243 | toolButtonStyle = Qt::ToolButtonTextBesideIcon; | - | ||||||||||||||||||
| 244 | toolBarIconSize = 0; | - | ||||||||||||||||||
| 245 | styleNames.clear(); | - | ||||||||||||||||||
| 246 | if (kdeVersion >= 5)
| 0 | ||||||||||||||||||
| 247 | styleNames << QStringLiteral("breeze"); never executed: styleNames << ([]() -> QString { enum { Size = sizeof(u"" "breeze")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "breeze" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 248 | styleNames << QStringLiteral("Oxygen") << QStringLiteral("fusion") << QStringLiteral("windows"); never executed: return qstring_literal_temp;never executed: return qstring_literal_temp;never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 249 | if (kdeVersion >= 5)
| 0 | ||||||||||||||||||
| 250 | iconFallbackThemeName = iconThemeName = QStringLiteral("breeze"); never executed: iconFallbackThemeName = iconThemeName = ([]() -> QString { enum { Size = sizeof(u"" "breeze")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "breeze" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 251 | else | - | ||||||||||||||||||
| 252 | iconFallbackThemeName = iconThemeName = QStringLiteral("oxygen"); never executed: iconFallbackThemeName = iconThemeName = ([]() -> QString { enum { Size = sizeof(u"" "oxygen")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "oxygen" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 253 | - | |||||||||||||||||||
| 254 | QHash<QString, QSettings*> kdeSettings; | - | ||||||||||||||||||
| 255 | - | |||||||||||||||||||
| 256 | QPalette systemPalette = QPalette(); | - | ||||||||||||||||||
| 257 | readKdeSystemPalette(kdeDirs, kdeVersion, kdeSettings, &systemPalette); | - | ||||||||||||||||||
| 258 | resources.palettes[QPlatformTheme::SystemPalette] = new QPalette(systemPalette); | - | ||||||||||||||||||
| 259 | //## TODO tooltip color | - | ||||||||||||||||||
| 260 | - | |||||||||||||||||||
| 261 | const QVariant styleValue = readKdeSetting(QStringLiteral("widgetStyle"), kdeDirs, kdeVersion, kdeSettings); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 262 | if (styleValue.isValid()) {
| 0 | ||||||||||||||||||
| 263 | const QString style = styleValue.toString(); | - | ||||||||||||||||||
| 264 | if (style != styleNames.front())
| 0 | ||||||||||||||||||
| 265 | styleNames.push_front(style); never executed: styleNames.push_front(style); | 0 | ||||||||||||||||||
| 266 | } never executed: end of block | 0 | ||||||||||||||||||
| 267 | - | |||||||||||||||||||
| 268 | const QVariant singleClickValue = readKdeSetting(QStringLiteral("KDE/SingleClick"), kdeDirs, kdeVersion, kdeSettings); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 269 | if (singleClickValue.isValid())
| 0 | ||||||||||||||||||
| 270 | singleClick = singleClickValue.toBool(); never executed: singleClick = singleClickValue.toBool(); | 0 | ||||||||||||||||||
| 271 | - | |||||||||||||||||||
| 272 | const QVariant themeValue = readKdeSetting(QStringLiteral("Icons/Theme"), kdeDirs, kdeVersion, kdeSettings); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 273 | if (themeValue.isValid())
| 0 | ||||||||||||||||||
| 274 | iconThemeName = themeValue.toString(); never executed: iconThemeName = themeValue.toString(); | 0 | ||||||||||||||||||
| 275 | - | |||||||||||||||||||
| 276 | const QVariant toolBarIconSizeValue = readKdeSetting(QStringLiteral("ToolbarIcons/Size"), kdeDirs, kdeVersion, kdeSettings); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 277 | if (toolBarIconSizeValue.isValid())
| 0 | ||||||||||||||||||
| 278 | toolBarIconSize = toolBarIconSizeValue.toInt(); never executed: toolBarIconSize = toolBarIconSizeValue.toInt(); | 0 | ||||||||||||||||||
| 279 | - | |||||||||||||||||||
| 280 | const QVariant toolbarStyleValue = readKdeSetting(QStringLiteral("Toolbar style/ToolButtonStyle"), kdeDirs, kdeVersion, kdeSettings); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 281 | if (toolbarStyleValue.isValid()) {
| 0 | ||||||||||||||||||
| 282 | const QString toolBarStyle = toolbarStyleValue.toString(); | - | ||||||||||||||||||
| 283 | if (toolBarStyle == QLatin1String("TextBesideIcon"))
| 0 | ||||||||||||||||||
| 284 | toolButtonStyle = Qt::ToolButtonTextBesideIcon; never executed: toolButtonStyle = Qt::ToolButtonTextBesideIcon; | 0 | ||||||||||||||||||
| 285 | else if (toolBarStyle == QLatin1String("TextOnly"))
| 0 | ||||||||||||||||||
| 286 | toolButtonStyle = Qt::ToolButtonTextOnly; never executed: toolButtonStyle = Qt::ToolButtonTextOnly; | 0 | ||||||||||||||||||
| 287 | else if (toolBarStyle == QLatin1String("TextUnderIcon"))
| 0 | ||||||||||||||||||
| 288 | toolButtonStyle = Qt::ToolButtonTextUnderIcon; never executed: toolButtonStyle = Qt::ToolButtonTextUnderIcon; | 0 | ||||||||||||||||||
| 289 | } never executed: end of block | 0 | ||||||||||||||||||
| 290 | - | |||||||||||||||||||
| 291 | const QVariant wheelScrollLinesValue = readKdeSetting(QStringLiteral("KDE/WheelScrollLines"), kdeDirs, kdeVersion, kdeSettings); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 292 | if (wheelScrollLinesValue.isValid())
| 0 | ||||||||||||||||||
| 293 | wheelScrollLines = wheelScrollLinesValue.toInt(); never executed: wheelScrollLines = wheelScrollLinesValue.toInt(); | 0 | ||||||||||||||||||
| 294 | - | |||||||||||||||||||
| 295 | // Read system font, ignore 'smallestReadableFont' | - | ||||||||||||||||||
| 296 | if (QFont *systemFont = kdeFont(readKdeSetting(QStringLiteral("font"), kdeDirs, kdeVersion, kdeSettings))) never executed: return qstring_literal_temp;
| 0 | ||||||||||||||||||
| 297 | resources.fonts[QPlatformTheme::SystemFont] = systemFont; never executed: resources.fonts[QPlatformTheme::SystemFont] = systemFont; | 0 | ||||||||||||||||||
| 298 | else | - | ||||||||||||||||||
| 299 | resources.fonts[QPlatformTheme::SystemFont] = new QFont(QLatin1String(defaultSystemFontNameC), defaultSystemFontSize); never executed: resources.fonts[QPlatformTheme::SystemFont] = new QFont(QLatin1String(defaultSystemFontNameC), defaultSystemFontSize); | 0 | ||||||||||||||||||
| 300 | - | |||||||||||||||||||
| 301 | if (QFont *fixedFont = kdeFont(readKdeSetting(QStringLiteral("fixed"), kdeDirs, kdeVersion, kdeSettings))) { never executed: return qstring_literal_temp;
| 0 | ||||||||||||||||||
| 302 | resources.fonts[QPlatformTheme::FixedFont] = fixedFont; | - | ||||||||||||||||||
| 303 | } else { never executed: end of block | 0 | ||||||||||||||||||
| 304 | fixedFont = new QFont(QLatin1String(defaultSystemFontNameC), defaultSystemFontSize); | - | ||||||||||||||||||
| 305 | fixedFont->setStyleHint(QFont::TypeWriter); | - | ||||||||||||||||||
| 306 | resources.fonts[QPlatformTheme::FixedFont] = fixedFont; | - | ||||||||||||||||||
| 307 | } never executed: end of block | 0 | ||||||||||||||||||
| 308 | - | |||||||||||||||||||
| 309 | qDeleteAll(kdeSettings); | - | ||||||||||||||||||
| 310 | } never executed: end of block | 0 | ||||||||||||||||||
| 311 | - | |||||||||||||||||||
| 312 | QVariant QKdeThemePrivate::readKdeSetting(const QString &key, const QStringList &kdeDirs, int kdeVersion, QHash<QString, QSettings*> &kdeSettings) | - | ||||||||||||||||||
| 313 | { | - | ||||||||||||||||||
| 314 | foreach (const QString &kdeDir, kdeDirs) { | - | ||||||||||||||||||
| 315 | QSettings *settings = kdeSettings.value(kdeDir); | - | ||||||||||||||||||
| 316 | if (!settings) {
| 0 | ||||||||||||||||||
| 317 | const QString kdeGlobalsPath = kdeGlobals(kdeDir, kdeVersion); | - | ||||||||||||||||||
| 318 | if (QFileInfo(kdeGlobalsPath).isReadable()) {
| 0 | ||||||||||||||||||
| 319 | settings = new QSettings(kdeGlobalsPath, QSettings::IniFormat); | - | ||||||||||||||||||
| 320 | kdeSettings.insert(kdeDir, settings); | - | ||||||||||||||||||
| 321 | } never executed: end of block | 0 | ||||||||||||||||||
| 322 | } never executed: end of block | 0 | ||||||||||||||||||
| 323 | if (settings) {
| 0 | ||||||||||||||||||
| 324 | const QVariant value = settings->value(key); | - | ||||||||||||||||||
| 325 | if (value.isValid())
| 0 | ||||||||||||||||||
| 326 | return value; never executed: return value; | 0 | ||||||||||||||||||
| 327 | } never executed: end of block | 0 | ||||||||||||||||||
| 328 | } never executed: end of block | 0 | ||||||||||||||||||
| 329 | return QVariant(); never executed: return QVariant(); | 0 | ||||||||||||||||||
| 330 | } | - | ||||||||||||||||||
| 331 | - | |||||||||||||||||||
| 332 | // Reads the color from the KDE configuration, and store it in the | - | ||||||||||||||||||
| 333 | // palette with the given color role if found. | - | ||||||||||||||||||
| 334 | static inline bool kdeColor(QPalette *pal, QPalette::ColorRole role, const QVariant &value) | - | ||||||||||||||||||
| 335 | { | - | ||||||||||||||||||
| 336 | if (!value.isValid())
| 0 | ||||||||||||||||||
| 337 | return false; never executed: return false; | 0 | ||||||||||||||||||
| 338 | const QStringList values = value.toStringList(); | - | ||||||||||||||||||
| 339 | if (values.size() != 3)
| 0 | ||||||||||||||||||
| 340 | return false; never executed: return false; | 0 | ||||||||||||||||||
| 341 | pal->setBrush(role, QColor(values.at(0).toInt(), values.at(1).toInt(), values.at(2).toInt())); | - | ||||||||||||||||||
| 342 | return true; never executed: return true; | 0 | ||||||||||||||||||
| 343 | } | - | ||||||||||||||||||
| 344 | - | |||||||||||||||||||
| 345 | void QKdeThemePrivate::readKdeSystemPalette(const QStringList &kdeDirs, int kdeVersion, QHash<QString, QSettings*> &kdeSettings, QPalette *pal) | - | ||||||||||||||||||
| 346 | { | - | ||||||||||||||||||
| 347 | if (!kdeColor(pal, QPalette::Button, readKdeSetting(QStringLiteral("Colors:Button/BackgroundNormal"), kdeDirs, kdeVersion, kdeSettings))) { never executed: return qstring_literal_temp;
| 0 | ||||||||||||||||||
| 348 | // kcolorscheme.cpp: SetDefaultColors | - | ||||||||||||||||||
| 349 | const QColor defaultWindowBackground(214, 210, 208); | - | ||||||||||||||||||
| 350 | const QColor defaultButtonBackground(223, 220, 217); | - | ||||||||||||||||||
| 351 | *pal = QPalette(defaultButtonBackground, defaultWindowBackground); | - | ||||||||||||||||||
| 352 | return; never executed: return; | 0 | ||||||||||||||||||
| 353 | } | - | ||||||||||||||||||
| 354 | - | |||||||||||||||||||
| 355 | kdeColor(pal, QPalette::Window, readKdeSetting(QStringLiteral("Colors:Window/BackgroundNormal"), kdeDirs, kdeVersion, kdeSettings)); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 356 | kdeColor(pal, QPalette::Text, readKdeSetting(QStringLiteral("Colors:View/ForegroundNormal"), kdeDirs, kdeVersion, kdeSettings)); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 357 | kdeColor(pal, QPalette::WindowText, readKdeSetting(QStringLiteral("Colors:Window/ForegroundNormal"), kdeDirs, kdeVersion, kdeSettings)); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 358 | kdeColor(pal, QPalette::Base, readKdeSetting(QStringLiteral("Colors:View/BackgroundNormal"), kdeDirs, kdeVersion, kdeSettings)); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 359 | kdeColor(pal, QPalette::Highlight, readKdeSetting(QStringLiteral("Colors:Selection/BackgroundNormal"), kdeDirs, kdeVersion, kdeSettings)); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 360 | kdeColor(pal, QPalette::HighlightedText, readKdeSetting(QStringLiteral("Colors:Selection/ForegroundNormal"), kdeDirs, kdeVersion, kdeSettings)); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 361 | kdeColor(pal, QPalette::AlternateBase, readKdeSetting(QStringLiteral("Colors:View/BackgroundAlternate"), kdeDirs, kdeVersion, kdeSettings)); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 362 | kdeColor(pal, QPalette::ButtonText, readKdeSetting(QStringLiteral("Colors:Button/ForegroundNormal"), kdeDirs, kdeVersion, kdeSettings)); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 363 | kdeColor(pal, QPalette::Link, readKdeSetting(QStringLiteral("Colors:View/ForegroundLink"), kdeDirs, kdeVersion, kdeSettings)); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 364 | kdeColor(pal, QPalette::LinkVisited, readKdeSetting(QStringLiteral("Colors:View/ForegroundVisited"), kdeDirs, kdeVersion, kdeSettings)); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 365 | kdeColor(pal, QPalette::ToolTipBase, readKdeSetting(QStringLiteral("Colors:Tooltip/BackgroundNormal"), kdeDirs, kdeVersion, kdeSettings)); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 366 | kdeColor(pal, QPalette::ToolTipText, readKdeSetting(QStringLiteral("Colors:Tooltip/ForegroundNormal"), kdeDirs, kdeVersion, kdeSettings)); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 367 | - | |||||||||||||||||||
| 368 | // The above code sets _all_ color roles to "normal" colors. In KDE, the disabled | - | ||||||||||||||||||
| 369 | // color roles are calculated by applying various effects described in kdeglobals. | - | ||||||||||||||||||
| 370 | // We use a bit simpler approach here, similar logic than in qt_palette_from_color(). | - | ||||||||||||||||||
| 371 | const QColor button = pal->color(QPalette::Button); | - | ||||||||||||||||||
| 372 | int h, s, v; | - | ||||||||||||||||||
| 373 | button.getHsv(&h, &s, &v); | - | ||||||||||||||||||
| 374 | - | |||||||||||||||||||
| 375 | const QBrush whiteBrush = QBrush(Qt::white); | - | ||||||||||||||||||
| 376 | const QBrush buttonBrush = QBrush(button); | - | ||||||||||||||||||
| 377 | const QBrush buttonBrushDark = QBrush(button.darker(v > 128 ? 200 : 50)); | - | ||||||||||||||||||
| 378 | const QBrush buttonBrushDark150 = QBrush(button.darker(v > 128 ? 150 : 75)); | - | ||||||||||||||||||
| 379 | const QBrush buttonBrushLight150 = QBrush(button.lighter(v > 128 ? 150 : 75)); | - | ||||||||||||||||||
| 380 | const QBrush buttonBrushLight = QBrush(button.lighter(v > 128 ? 200 : 50)); | - | ||||||||||||||||||
| 381 | - | |||||||||||||||||||
| 382 | pal->setBrush(QPalette::Disabled, QPalette::WindowText, buttonBrushDark); | - | ||||||||||||||||||
| 383 | pal->setBrush(QPalette::Disabled, QPalette::ButtonText, buttonBrushDark); | - | ||||||||||||||||||
| 384 | pal->setBrush(QPalette::Disabled, QPalette::Button, buttonBrush); | - | ||||||||||||||||||
| 385 | pal->setBrush(QPalette::Disabled, QPalette::Text, buttonBrushDark); | - | ||||||||||||||||||
| 386 | pal->setBrush(QPalette::Disabled, QPalette::BrightText, whiteBrush); | - | ||||||||||||||||||
| 387 | pal->setBrush(QPalette::Disabled, QPalette::Base, buttonBrush); | - | ||||||||||||||||||
| 388 | pal->setBrush(QPalette::Disabled, QPalette::Window, buttonBrush); | - | ||||||||||||||||||
| 389 | pal->setBrush(QPalette::Disabled, QPalette::Highlight, buttonBrushDark150); | - | ||||||||||||||||||
| 390 | pal->setBrush(QPalette::Disabled, QPalette::HighlightedText, buttonBrushLight150); | - | ||||||||||||||||||
| 391 | - | |||||||||||||||||||
| 392 | // set calculated colors for all groups | - | ||||||||||||||||||
| 393 | pal->setBrush(QPalette::Light, buttonBrushLight); | - | ||||||||||||||||||
| 394 | pal->setBrush(QPalette::Midlight, buttonBrushLight150); | - | ||||||||||||||||||
| 395 | pal->setBrush(QPalette::Mid, buttonBrushDark150); | - | ||||||||||||||||||
| 396 | pal->setBrush(QPalette::Dark, buttonBrushDark); | - | ||||||||||||||||||
| 397 | } never executed: end of block | 0 | ||||||||||||||||||
| 398 | - | |||||||||||||||||||
| 399 | /*! | - | ||||||||||||||||||
| 400 | \class QKdeTheme | - | ||||||||||||||||||
| 401 | \brief QKdeTheme is a theme implementation for the KDE desktop (version 4 or higher). | - | ||||||||||||||||||
| 402 | \since 5.0 | - | ||||||||||||||||||
| 403 | \internal | - | ||||||||||||||||||
| 404 | \ingroup qpa | - | ||||||||||||||||||
| 405 | */ | - | ||||||||||||||||||
| 406 | - | |||||||||||||||||||
| 407 | const char *QKdeTheme::name = "kde"; | - | ||||||||||||||||||
| 408 | - | |||||||||||||||||||
| 409 | QKdeTheme::QKdeTheme(const QStringList& kdeDirs, int kdeVersion) | - | ||||||||||||||||||
| 410 | : QPlatformTheme(new QKdeThemePrivate(kdeDirs,kdeVersion)) | - | ||||||||||||||||||
| 411 | { | - | ||||||||||||||||||
| 412 | d_func()->refresh(); | - | ||||||||||||||||||
| 413 | } never executed: end of block | 0 | ||||||||||||||||||
| 414 | - | |||||||||||||||||||
| 415 | QFont *QKdeThemePrivate::kdeFont(const QVariant &fontValue) | - | ||||||||||||||||||
| 416 | { | - | ||||||||||||||||||
| 417 | if (fontValue.isValid()) {
| 0 | ||||||||||||||||||
| 418 | // Read font value: Might be a QStringList as KDE stores fonts without quotes. | - | ||||||||||||||||||
| 419 | // Also retrieve the family for the constructor since we cannot use the | - | ||||||||||||||||||
| 420 | // default constructor of QFont, which accesses QGuiApplication::systemFont() | - | ||||||||||||||||||
| 421 | // causing recursion. | - | ||||||||||||||||||
| 422 | QString fontDescription; | - | ||||||||||||||||||
| 423 | QString fontFamily; | - | ||||||||||||||||||
| 424 | if (fontValue.type() == QVariant::StringList) {
| 0 | ||||||||||||||||||
| 425 | const QStringList list = fontValue.toStringList(); | - | ||||||||||||||||||
| 426 | if (!list.isEmpty()) {
| 0 | ||||||||||||||||||
| 427 | fontFamily = list.first(); | - | ||||||||||||||||||
| 428 | fontDescription = list.join(QLatin1Char(',')); | - | ||||||||||||||||||
| 429 | } never executed: end of block | 0 | ||||||||||||||||||
| 430 | } else { never executed: end of block | 0 | ||||||||||||||||||
| 431 | fontDescription = fontFamily = fontValue.toString(); | - | ||||||||||||||||||
| 432 | } never executed: end of block | 0 | ||||||||||||||||||
| 433 | if (!fontDescription.isEmpty()) {
| 0 | ||||||||||||||||||
| 434 | QFont font(fontFamily); | - | ||||||||||||||||||
| 435 | if (font.fromString(fontDescription))
| 0 | ||||||||||||||||||
| 436 | return new QFont(font); never executed: return new QFont(font); | 0 | ||||||||||||||||||
| 437 | } never executed: end of block | 0 | ||||||||||||||||||
| 438 | } never executed: end of block | 0 | ||||||||||||||||||
| 439 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 440 | } | - | ||||||||||||||||||
| 441 | - | |||||||||||||||||||
| 442 | - | |||||||||||||||||||
| 443 | QStringList QKdeThemePrivate::kdeIconThemeSearchPaths(const QStringList &kdeDirs) | - | ||||||||||||||||||
| 444 | { | - | ||||||||||||||||||
| 445 | QStringList paths = QGenericUnixTheme::xdgIconThemePaths(); | - | ||||||||||||||||||
| 446 | const QString iconPath = QStringLiteral("/share/icons"); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 447 | foreach (const QString &candidate, kdeDirs) { | - | ||||||||||||||||||
| 448 | const QFileInfo fi(candidate + iconPath); | - | ||||||||||||||||||
| 449 | if (fi.isDir())
| 0 | ||||||||||||||||||
| 450 | paths.append(fi.absoluteFilePath()); never executed: paths.append(fi.absoluteFilePath()); | 0 | ||||||||||||||||||
| 451 | } never executed: end of block | 0 | ||||||||||||||||||
| 452 | return paths; never executed: return paths; | 0 | ||||||||||||||||||
| 453 | } | - | ||||||||||||||||||
| 454 | - | |||||||||||||||||||
| 455 | QVariant QKdeTheme::themeHint(QPlatformTheme::ThemeHint hint) const | - | ||||||||||||||||||
| 456 | { | - | ||||||||||||||||||
| 457 | Q_D(const QKdeTheme); | - | ||||||||||||||||||
| 458 | switch (hint) { | - | ||||||||||||||||||
| 459 | case QPlatformTheme::UseFullScreenForPopupMenu: never executed: case QPlatformTheme::UseFullScreenForPopupMenu: | 0 | ||||||||||||||||||
| 460 | return QVariant(true); never executed: return QVariant(true); | 0 | ||||||||||||||||||
| 461 | case QPlatformTheme::DialogButtonBoxButtonsHaveIcons: never executed: case QPlatformTheme::DialogButtonBoxButtonsHaveIcons: | 0 | ||||||||||||||||||
| 462 | return QVariant(true); never executed: return QVariant(true); | 0 | ||||||||||||||||||
| 463 | case QPlatformTheme::DialogButtonBoxLayout: never executed: case QPlatformTheme::DialogButtonBoxLayout: | 0 | ||||||||||||||||||
| 464 | return QVariant(QPlatformDialogHelper::KdeLayout); never executed: return QVariant(QPlatformDialogHelper::KdeLayout); | 0 | ||||||||||||||||||
| 465 | case QPlatformTheme::ToolButtonStyle: never executed: case QPlatformTheme::ToolButtonStyle: | 0 | ||||||||||||||||||
| 466 | return QVariant(d->toolButtonStyle); never executed: return QVariant(d->toolButtonStyle); | 0 | ||||||||||||||||||
| 467 | case QPlatformTheme::ToolBarIconSize: never executed: case QPlatformTheme::ToolBarIconSize: | 0 | ||||||||||||||||||
| 468 | return QVariant(d->toolBarIconSize); never executed: return QVariant(d->toolBarIconSize); | 0 | ||||||||||||||||||
| 469 | case QPlatformTheme::SystemIconThemeName: never executed: case QPlatformTheme::SystemIconThemeName: | 0 | ||||||||||||||||||
| 470 | return QVariant(d->iconThemeName); never executed: return QVariant(d->iconThemeName); | 0 | ||||||||||||||||||
| 471 | case QPlatformTheme::SystemIconFallbackThemeName: never executed: case QPlatformTheme::SystemIconFallbackThemeName: | 0 | ||||||||||||||||||
| 472 | return QVariant(d->iconFallbackThemeName); never executed: return QVariant(d->iconFallbackThemeName); | 0 | ||||||||||||||||||
| 473 | case QPlatformTheme::IconThemeSearchPaths: never executed: case QPlatformTheme::IconThemeSearchPaths: | 0 | ||||||||||||||||||
| 474 | return QVariant(d->kdeIconThemeSearchPaths(d->kdeDirs)); never executed: return QVariant(d->kdeIconThemeSearchPaths(d->kdeDirs)); | 0 | ||||||||||||||||||
| 475 | case QPlatformTheme::StyleNames: never executed: case QPlatformTheme::StyleNames: | 0 | ||||||||||||||||||
| 476 | return QVariant(d->styleNames); never executed: return QVariant(d->styleNames); | 0 | ||||||||||||||||||
| 477 | case QPlatformTheme::KeyboardScheme: never executed: case QPlatformTheme::KeyboardScheme: | 0 | ||||||||||||||||||
| 478 | return QVariant(int(KdeKeyboardScheme)); never executed: return QVariant(int(KdeKeyboardScheme)); | 0 | ||||||||||||||||||
| 479 | case QPlatformTheme::ItemViewActivateItemOnSingleClick: never executed: case QPlatformTheme::ItemViewActivateItemOnSingleClick: | 0 | ||||||||||||||||||
| 480 | return QVariant(d->singleClick); never executed: return QVariant(d->singleClick); | 0 | ||||||||||||||||||
| 481 | case QPlatformTheme::WheelScrollLines: never executed: case QPlatformTheme::WheelScrollLines: | 0 | ||||||||||||||||||
| 482 | return QVariant(d->wheelScrollLines); never executed: return QVariant(d->wheelScrollLines); | 0 | ||||||||||||||||||
| 483 | default: never executed: default: | 0 | ||||||||||||||||||
| 484 | break; never executed: break; | 0 | ||||||||||||||||||
| 485 | } | - | ||||||||||||||||||
| 486 | return QPlatformTheme::themeHint(hint); never executed: return QPlatformTheme::themeHint(hint); | 0 | ||||||||||||||||||
| 487 | } | - | ||||||||||||||||||
| 488 | - | |||||||||||||||||||
| 489 | const QPalette *QKdeTheme::palette(Palette type) const | - | ||||||||||||||||||
| 490 | { | - | ||||||||||||||||||
| 491 | Q_D(const QKdeTheme); | - | ||||||||||||||||||
| 492 | return d->resources.palettes[type]; never executed: return d->resources.palettes[type]; | 0 | ||||||||||||||||||
| 493 | } | - | ||||||||||||||||||
| 494 | - | |||||||||||||||||||
| 495 | const QFont *QKdeTheme::font(Font type) const | - | ||||||||||||||||||
| 496 | { | - | ||||||||||||||||||
| 497 | Q_D(const QKdeTheme); | - | ||||||||||||||||||
| 498 | return d->resources.fonts[type]; never executed: return d->resources.fonts[type]; | 0 | ||||||||||||||||||
| 499 | } | - | ||||||||||||||||||
| 500 | - | |||||||||||||||||||
| 501 | QPlatformTheme *QKdeTheme::createKdeTheme() | - | ||||||||||||||||||
| 502 | { | - | ||||||||||||||||||
| 503 | const QByteArray kdeVersionBA = qgetenv("KDE_SESSION_VERSION"); | - | ||||||||||||||||||
| 504 | const int kdeVersion = kdeVersionBA.toInt(); | - | ||||||||||||||||||
| 505 | if (kdeVersion < 4)
| 0 | ||||||||||||||||||
| 506 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 507 | - | |||||||||||||||||||
| 508 | if (kdeVersion > 4)
| 0 | ||||||||||||||||||
| 509 | // Plasma 5 follows XDG spec | - | ||||||||||||||||||
| 510 | // but uses the same config file format: | - | ||||||||||||||||||
| 511 | return new QKdeTheme(QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation), kdeVersion); never executed: return new QKdeTheme(QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation), kdeVersion); | 0 | ||||||||||||||||||
| 512 | - | |||||||||||||||||||
| 513 | // Determine KDE prefixes in the following priority order: | - | ||||||||||||||||||
| 514 | // - KDEHOME and KDEDIRS environment variables | - | ||||||||||||||||||
| 515 | // - ~/.kde(<version>) | - | ||||||||||||||||||
| 516 | // - read prefixes from /etc/kde<version>rc | - | ||||||||||||||||||
| 517 | // - fallback to /etc/kde<version> | - | ||||||||||||||||||
| 518 | - | |||||||||||||||||||
| 519 | QStringList kdeDirs; | - | ||||||||||||||||||
| 520 | const QString kdeHomePathVar = QFile::decodeName(qgetenv("KDEHOME")); | - | ||||||||||||||||||
| 521 | if (!kdeHomePathVar.isEmpty())
| 0 | ||||||||||||||||||
| 522 | kdeDirs += kdeHomePathVar; never executed: kdeDirs += kdeHomePathVar; | 0 | ||||||||||||||||||
| 523 | - | |||||||||||||||||||
| 524 | const QString kdeDirsVar = QFile::decodeName(qgetenv("KDEDIRS")); | - | ||||||||||||||||||
| 525 | if (!kdeDirsVar.isEmpty())
| 0 | ||||||||||||||||||
| 526 | kdeDirs += kdeDirsVar.split(QLatin1Char(':'), QString::SkipEmptyParts); never executed: kdeDirs += kdeDirsVar.split(QLatin1Char(':'), QString::SkipEmptyParts); | 0 | ||||||||||||||||||
| 527 | - | |||||||||||||||||||
| 528 | const QString kdeVersionHomePath = QDir::homePath() + QStringLiteral("/.kde") + QLatin1String(kdeVersionBA); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 529 | if (QFileInfo(kdeVersionHomePath).isDir())
| 0 | ||||||||||||||||||
| 530 | kdeDirs += kdeVersionHomePath; never executed: kdeDirs += kdeVersionHomePath; | 0 | ||||||||||||||||||
| 531 | - | |||||||||||||||||||
| 532 | const QString kdeHomePath = QDir::homePath() + QStringLiteral("/.kde"); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 533 | if (QFileInfo(kdeHomePath).isDir())
| 0 | ||||||||||||||||||
| 534 | kdeDirs += kdeHomePath; never executed: kdeDirs += kdeHomePath; | 0 | ||||||||||||||||||
| 535 | - | |||||||||||||||||||
| 536 | const QString kdeRcPath = QStringLiteral("/etc/kde") + QLatin1String(kdeVersionBA) + QStringLiteral("rc"); never executed: return qstring_literal_temp;never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 537 | if (QFileInfo(kdeRcPath).isReadable()) {
| 0 | ||||||||||||||||||
| 538 | QSettings kdeSettings(kdeRcPath, QSettings::IniFormat); | - | ||||||||||||||||||
| 539 | kdeSettings.beginGroup(QStringLiteral("Directories-default")); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 540 | kdeDirs += kdeSettings.value(QStringLiteral("prefixes")).toStringList(); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 541 | } never executed: end of block | 0 | ||||||||||||||||||
| 542 | - | |||||||||||||||||||
| 543 | const QString kdeVersionPrefix = QStringLiteral("/etc/kde") + QLatin1String(kdeVersionBA); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 544 | if (QFileInfo(kdeVersionPrefix).isDir())
| 0 | ||||||||||||||||||
| 545 | kdeDirs += kdeVersionPrefix; never executed: kdeDirs += kdeVersionPrefix; | 0 | ||||||||||||||||||
| 546 | - | |||||||||||||||||||
| 547 | kdeDirs.removeDuplicates(); | - | ||||||||||||||||||
| 548 | if (kdeDirs.isEmpty()) {
| 0 | ||||||||||||||||||
| 549 | qWarning("Unable to determine KDE dirs"); | - | ||||||||||||||||||
| 550 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 551 | } | - | ||||||||||||||||||
| 552 | - | |||||||||||||||||||
| 553 | return new QKdeTheme(kdeDirs, kdeVersion); never executed: return new QKdeTheme(kdeDirs, kdeVersion); | 0 | ||||||||||||||||||
| 554 | } | - | ||||||||||||||||||
| 555 | - | |||||||||||||||||||
| 556 | #if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON) | - | ||||||||||||||||||
| 557 | QPlatformSystemTrayIcon *QKdeTheme::createPlatformSystemTrayIcon() const | - | ||||||||||||||||||
| 558 | { | - | ||||||||||||||||||
| 559 | if (isDBusTrayAvailable())
| 0 | ||||||||||||||||||
| 560 | return new QDBusTrayIcon(); never executed: return new QDBusTrayIcon(); | 0 | ||||||||||||||||||
| 561 | return Q_NULLPTR; never executed: return nullptr; | 0 | ||||||||||||||||||
| 562 | } | - | ||||||||||||||||||
| 563 | #endif | - | ||||||||||||||||||
| 564 | - | |||||||||||||||||||
| 565 | #endif // QT_NO_SETTINGS | - | ||||||||||||||||||
| 566 | - | |||||||||||||||||||
| 567 | /*! | - | ||||||||||||||||||
| 568 | \class QGnomeTheme | - | ||||||||||||||||||
| 569 | \brief QGnomeTheme is a theme implementation for the Gnome desktop. | - | ||||||||||||||||||
| 570 | \since 5.0 | - | ||||||||||||||||||
| 571 | \internal | - | ||||||||||||||||||
| 572 | \ingroup qpa | - | ||||||||||||||||||
| 573 | */ | - | ||||||||||||||||||
| 574 | - | |||||||||||||||||||
| 575 | const char *QGnomeTheme::name = "gnome"; | - | ||||||||||||||||||
| 576 | - | |||||||||||||||||||
| 577 | class QGnomeThemePrivate : public QPlatformThemePrivate | - | ||||||||||||||||||
| 578 | { | - | ||||||||||||||||||
| 579 | public: | - | ||||||||||||||||||
| 580 | QGnomeThemePrivate() : systemFont(Q_NULLPTR), fixedFont(Q_NULLPTR) {} never executed: end of block | 0 | ||||||||||||||||||
| 581 | ~QGnomeThemePrivate() { delete systemFont; delete fixedFont; } never executed: end of block | 0 | ||||||||||||||||||
| 582 | - | |||||||||||||||||||
| 583 | void configureFonts(const QString >kFontName) const | - | ||||||||||||||||||
| 584 | { | - | ||||||||||||||||||
| 585 | Q_ASSERT(!systemFont); | - | ||||||||||||||||||
| 586 | const int split = gtkFontName.lastIndexOf(QChar::Space); | - | ||||||||||||||||||
| 587 | float size = gtkFontName.mid(split+1).toFloat(); | - | ||||||||||||||||||
| 588 | QString fontName = gtkFontName.left(split); | - | ||||||||||||||||||
| 589 | - | |||||||||||||||||||
| 590 | systemFont = new QFont(fontName, size); | - | ||||||||||||||||||
| 591 | fixedFont = new QFont(QLatin1String("monospace"), systemFont->pointSize()); | - | ||||||||||||||||||
| 592 | fixedFont->setStyleHint(QFont::TypeWriter); | - | ||||||||||||||||||
| 593 | } never executed: end of block | 0 | ||||||||||||||||||
| 594 | - | |||||||||||||||||||
| 595 | mutable QFont *systemFont; | - | ||||||||||||||||||
| 596 | mutable QFont *fixedFont; | - | ||||||||||||||||||
| 597 | }; | - | ||||||||||||||||||
| 598 | - | |||||||||||||||||||
| 599 | QGnomeTheme::QGnomeTheme() | - | ||||||||||||||||||
| 600 | : QPlatformTheme(new QGnomeThemePrivate()) | - | ||||||||||||||||||
| 601 | { | - | ||||||||||||||||||
| 602 | } never executed: end of block | 0 | ||||||||||||||||||
| 603 | - | |||||||||||||||||||
| 604 | QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const | - | ||||||||||||||||||
| 605 | { | - | ||||||||||||||||||
| 606 | switch (hint) { | - | ||||||||||||||||||
| 607 | case QPlatformTheme::DialogButtonBoxButtonsHaveIcons: never executed: case QPlatformTheme::DialogButtonBoxButtonsHaveIcons: | 0 | ||||||||||||||||||
| 608 | return QVariant(true); never executed: return QVariant(true); | 0 | ||||||||||||||||||
| 609 | case QPlatformTheme::DialogButtonBoxLayout: never executed: case QPlatformTheme::DialogButtonBoxLayout: | 0 | ||||||||||||||||||
| 610 | return QVariant(QPlatformDialogHelper::GnomeLayout); never executed: return QVariant(QPlatformDialogHelper::GnomeLayout); | 0 | ||||||||||||||||||
| 611 | case QPlatformTheme::SystemIconThemeName: never executed: case QPlatformTheme::SystemIconThemeName: | 0 | ||||||||||||||||||
| 612 | return QVariant(QStringLiteral("Adwaita")); never executed: return QVariant(([]() -> QString { enum { Size = sizeof(u"" "Adwaita")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Adwaita" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()));never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 613 | case QPlatformTheme::SystemIconFallbackThemeName: never executed: case QPlatformTheme::SystemIconFallbackThemeName: | 0 | ||||||||||||||||||
| 614 | return QVariant(QStringLiteral("gnome")); never executed: return QVariant(([]() -> QString { enum { Size = sizeof(u"" "gnome")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "gnome" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()));never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 615 | case QPlatformTheme::IconThemeSearchPaths: never executed: case QPlatformTheme::IconThemeSearchPaths: | 0 | ||||||||||||||||||
| 616 | return QVariant(QGenericUnixTheme::xdgIconThemePaths()); never executed: return QVariant(QGenericUnixTheme::xdgIconThemePaths()); | 0 | ||||||||||||||||||
| 617 | case QPlatformTheme::StyleNames: { never executed: case QPlatformTheme::StyleNames: | 0 | ||||||||||||||||||
| 618 | QStringList styleNames; | - | ||||||||||||||||||
| 619 | styleNames << QStringLiteral("GTK+") << QStringLiteral("fusion") << QStringLiteral("windows"); never executed: return qstring_literal_temp;never executed: return qstring_literal_temp;never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 620 | return QVariant(styleNames); never executed: return QVariant(styleNames); | 0 | ||||||||||||||||||
| 621 | } | - | ||||||||||||||||||
| 622 | case QPlatformTheme::KeyboardScheme: never executed: case QPlatformTheme::KeyboardScheme: | 0 | ||||||||||||||||||
| 623 | return QVariant(int(GnomeKeyboardScheme)); never executed: return QVariant(int(GnomeKeyboardScheme)); | 0 | ||||||||||||||||||
| 624 | case QPlatformTheme::PasswordMaskCharacter: never executed: case QPlatformTheme::PasswordMaskCharacter: | 0 | ||||||||||||||||||
| 625 | return QVariant(QChar(0x2022)); never executed: return QVariant(QChar(0x2022)); | 0 | ||||||||||||||||||
| 626 | default: never executed: default: | 0 | ||||||||||||||||||
| 627 | break; never executed: break; | 0 | ||||||||||||||||||
| 628 | } | - | ||||||||||||||||||
| 629 | return QPlatformTheme::themeHint(hint); never executed: return QPlatformTheme::themeHint(hint); | 0 | ||||||||||||||||||
| 630 | } | - | ||||||||||||||||||
| 631 | - | |||||||||||||||||||
| 632 | const QFont *QGnomeTheme::font(Font type) const | - | ||||||||||||||||||
| 633 | { | - | ||||||||||||||||||
| 634 | Q_D(const QGnomeTheme); | - | ||||||||||||||||||
| 635 | if (!d->systemFont)
| 0 | ||||||||||||||||||
| 636 | d->configureFonts(gtkFontName()); never executed: d->configureFonts(gtkFontName()); | 0 | ||||||||||||||||||
| 637 | switch (type) { | - | ||||||||||||||||||
| 638 | case QPlatformTheme::SystemFont: never executed: case QPlatformTheme::SystemFont: | 0 | ||||||||||||||||||
| 639 | return d->systemFont; never executed: return d->systemFont; | 0 | ||||||||||||||||||
| 640 | case QPlatformTheme::FixedFont: never executed: case QPlatformTheme::FixedFont: | 0 | ||||||||||||||||||
| 641 | return d->fixedFont; never executed: return d->fixedFont; | 0 | ||||||||||||||||||
| 642 | default: never executed: default: | 0 | ||||||||||||||||||
| 643 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 644 | } | - | ||||||||||||||||||
| 645 | } | - | ||||||||||||||||||
| 646 | - | |||||||||||||||||||
| 647 | QString QGnomeTheme::gtkFontName() const | - | ||||||||||||||||||
| 648 | { | - | ||||||||||||||||||
| 649 | return QStringLiteral("%1 %2").arg(QLatin1String(defaultSystemFontNameC)).arg(defaultSystemFontSize); never executed: return ([]() -> QString { enum { Size = sizeof(u"" "%1 %2")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "%1 %2" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()).arg(QLatin1String(defaultSystemFontNameC)).arg(defaultSystemFontSize);never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 650 | } | - | ||||||||||||||||||
| 651 | - | |||||||||||||||||||
| 652 | #if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON) | - | ||||||||||||||||||
| 653 | QPlatformSystemTrayIcon *QGnomeTheme::createPlatformSystemTrayIcon() const | - | ||||||||||||||||||
| 654 | { | - | ||||||||||||||||||
| 655 | if (isDBusTrayAvailable())
| 0 | ||||||||||||||||||
| 656 | return new QDBusTrayIcon(); never executed: return new QDBusTrayIcon(); | 0 | ||||||||||||||||||
| 657 | return Q_NULLPTR; never executed: return nullptr; | 0 | ||||||||||||||||||
| 658 | } | - | ||||||||||||||||||
| 659 | #endif | - | ||||||||||||||||||
| 660 | - | |||||||||||||||||||
| 661 | QString QGnomeTheme::standardButtonText(int button) const | - | ||||||||||||||||||
| 662 | { | - | ||||||||||||||||||
| 663 | switch (button) { | - | ||||||||||||||||||
| 664 | case QPlatformDialogHelper::Ok: never executed: case QPlatformDialogHelper::Ok: | 0 | ||||||||||||||||||
| 665 | return QCoreApplication::translate("QGnomeTheme", "&OK"); never executed: return QCoreApplication::translate("QGnomeTheme", "&OK"); | 0 | ||||||||||||||||||
| 666 | case QPlatformDialogHelper::Save: never executed: case QPlatformDialogHelper::Save: | 0 | ||||||||||||||||||
| 667 | return QCoreApplication::translate("QGnomeTheme", "&Save"); never executed: return QCoreApplication::translate("QGnomeTheme", "&Save"); | 0 | ||||||||||||||||||
| 668 | case QPlatformDialogHelper::Cancel: never executed: case QPlatformDialogHelper::Cancel: | 0 | ||||||||||||||||||
| 669 | return QCoreApplication::translate("QGnomeTheme", "&Cancel"); never executed: return QCoreApplication::translate("QGnomeTheme", "&Cancel"); | 0 | ||||||||||||||||||
| 670 | case QPlatformDialogHelper::Close: never executed: case QPlatformDialogHelper::Close: | 0 | ||||||||||||||||||
| 671 | return QCoreApplication::translate("QGnomeTheme", "&Close"); never executed: return QCoreApplication::translate("QGnomeTheme", "&Close"); | 0 | ||||||||||||||||||
| 672 | case QPlatformDialogHelper::Discard: never executed: case QPlatformDialogHelper::Discard: | 0 | ||||||||||||||||||
| 673 | return QCoreApplication::translate("QGnomeTheme", "Close without Saving"); never executed: return QCoreApplication::translate("QGnomeTheme", "Close without Saving"); | 0 | ||||||||||||||||||
| 674 | default: never executed: default: | 0 | ||||||||||||||||||
| 675 | break; never executed: break; | 0 | ||||||||||||||||||
| 676 | } | - | ||||||||||||||||||
| 677 | return QPlatformTheme::standardButtonText(button); never executed: return QPlatformTheme::standardButtonText(button); | 0 | ||||||||||||||||||
| 678 | } | - | ||||||||||||||||||
| 679 | - | |||||||||||||||||||
| 680 | /*! | - | ||||||||||||||||||
| 681 | \brief Creates a UNIX theme according to the detected desktop environment. | - | ||||||||||||||||||
| 682 | */ | - | ||||||||||||||||||
| 683 | - | |||||||||||||||||||
| 684 | QPlatformTheme *QGenericUnixTheme::createUnixTheme(const QString &name) | - | ||||||||||||||||||
| 685 | { | - | ||||||||||||||||||
| 686 | if (name == QLatin1String(QGenericUnixTheme::name))
| 0-129 | ||||||||||||||||||
| 687 | return new QGenericUnixTheme; executed 129 times by 5 tests: return new QGenericUnixTheme;Executed by:
| 129 | ||||||||||||||||||
| 688 | #ifndef QT_NO_SETTINGS | - | ||||||||||||||||||
| 689 | if (name == QLatin1String(QKdeTheme::name))
| 0 | ||||||||||||||||||
| 690 | if (QPlatformTheme *kdeTheme = QKdeTheme::createKdeTheme())
| 0 | ||||||||||||||||||
| 691 | return kdeTheme; never executed: return kdeTheme; | 0 | ||||||||||||||||||
| 692 | #endif | - | ||||||||||||||||||
| 693 | if (name == QLatin1String(QGnomeTheme::name))
| 0 | ||||||||||||||||||
| 694 | return new QGnomeTheme; never executed: return new QGnomeTheme; | 0 | ||||||||||||||||||
| 695 | return Q_NULLPTR; never executed: return nullptr; | 0 | ||||||||||||||||||
| 696 | } | - | ||||||||||||||||||
| 697 | - | |||||||||||||||||||
| 698 | QStringList QGenericUnixTheme::themeNames() | - | ||||||||||||||||||
| 699 | { | - | ||||||||||||||||||
| 700 | QStringList result; | - | ||||||||||||||||||
| 701 | if (QGuiApplication::desktopSettingsAware()) {
| 1-128 | ||||||||||||||||||
| 702 | const QByteArray desktopEnvironment = QGuiApplicationPrivate::platformIntegration()->services()->desktopEnvironment(); | - | ||||||||||||||||||
| 703 | QList<QByteArray> gtkBasedEnvironments; | - | ||||||||||||||||||
| 704 | gtkBasedEnvironments << "GNOME" | - | ||||||||||||||||||
| 705 | << "X-CINNAMON" | - | ||||||||||||||||||
| 706 | << "UNITY" | - | ||||||||||||||||||
| 707 | << "MATE" | - | ||||||||||||||||||
| 708 | << "XFCE" | - | ||||||||||||||||||
| 709 | << "LXDE"; | - | ||||||||||||||||||
| 710 | QList<QByteArray> desktopNames = desktopEnvironment.split(':'); | - | ||||||||||||||||||
| 711 | Q_FOREACH (const QByteArray &desktopName, desktopNames) { | - | ||||||||||||||||||
| 712 | if (desktopEnvironment == "KDE") {
| 0-128 | ||||||||||||||||||
| 713 | #ifndef QT_NO_SETTINGS | - | ||||||||||||||||||
| 714 | result.push_back(QLatin1String(QKdeTheme::name)); | - | ||||||||||||||||||
| 715 | #endif | - | ||||||||||||||||||
| 716 | } else if (gtkBasedEnvironments.contains(desktopName)) { never executed: end of block
| 0-128 | ||||||||||||||||||
| 717 | // prefer the GTK2 theme implementation with native dialogs etc. | - | ||||||||||||||||||
| 718 | result.push_back(QStringLiteral("gtk2")); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 719 | // fallback to the generic Gnome theme if loading the GTK2 theme fails | - | ||||||||||||||||||
| 720 | result.push_back(QLatin1String(QGnomeTheme::name)); | - | ||||||||||||||||||
| 721 | } never executed: end of block | 0 | ||||||||||||||||||
| 722 | } executed 128 times by 5 tests: end of blockExecuted by:
| 128 | ||||||||||||||||||
| 723 | const QString session = QString::fromLocal8Bit(qgetenv("DESKTOP_SESSION")); | - | ||||||||||||||||||
| 724 | if (!session.isEmpty() && session != QLatin1String("default") && !result.contains(session))
| 0-128 | ||||||||||||||||||
| 725 | result.push_back(session); never executed: result.push_back(session); | 0 | ||||||||||||||||||
| 726 | } // desktopSettingsAware executed 128 times by 5 tests: end of blockExecuted by:
| 128 | ||||||||||||||||||
| 727 | result.append(QLatin1String(QGenericUnixTheme::name)); | - | ||||||||||||||||||
| 728 | return result; executed 129 times by 5 tests: return result;Executed by:
| 129 | ||||||||||||||||||
| 729 | } | - | ||||||||||||||||||
| 730 | - | |||||||||||||||||||
| 731 | QT_END_NAMESPACE | - | ||||||||||||||||||
| Source code | Switch to Preprocessed file |