qgenericunixthemes.cpp

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

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9