Changeset View
Changeset View
Standalone View
Standalone View
src/kicontheme.cpp
Show All 19 Lines | |||||
20 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 20 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
21 | * Boston, MA 02110-1301, USA. | 21 | * Boston, MA 02110-1301, USA. | ||
22 | */ | 22 | */ | ||
23 | 23 | | |||
24 | #include "kicontheme.h" | 24 | #include "kicontheme.h" | ||
25 | 25 | | |||
26 | #include <qplatformdefs.h> | 26 | #include <qplatformdefs.h> | ||
27 | 27 | | |||
28 | #include <QCoreApplication> | ||||
28 | #include <QAction> | 29 | #include <QAction> | ||
29 | #include <QtCore/QMap> | 30 | #include <QtCore/QMap> | ||
30 | #include <QtCore/QSet> | 31 | #include <QtCore/QSet> | ||
31 | #include <QtCore/QFileInfo> | 32 | #include <QtCore/QFileInfo> | ||
32 | #include <QtCore/QDir> | 33 | #include <QtCore/QDir> | ||
33 | #include <QDebug> | 34 | #include <QDebug> | ||
35 | #include <QResource> | ||||
34 | 36 | | |||
35 | #include <klocalizedstring.h> // KLocalizedString::localizedFilePath. Need such functionality in, hmm, QLocale? QStandardPaths? | 37 | #include <klocalizedstring.h> // KLocalizedString::localizedFilePath. Need such functionality in, hmm, QLocale? QStandardPaths? | ||
36 | 38 | | |||
37 | #include <ksharedconfig.h> | 39 | #include <ksharedconfig.h> | ||
38 | 40 | | |||
39 | #include <kconfiggroup.h> | 41 | #include <kconfiggroup.h> | ||
40 | 42 | | |||
43 | Q_GLOBAL_STATIC(QString, _themeOverride) | ||||
44 | | ||||
45 | // Support for icon themes in RCC files. | ||||
46 | // The intended use case is standalone apps on Windows / MacOS / etc. | ||||
47 | // For this reason we use AppDataLocation: BINDIR/data on Windows, Resources on OS X | ||||
48 | void initRCCIconTheme() | ||||
49 | { | ||||
50 | const QString iconThemeRcc = QStandardPaths::locate(QStandardPaths::AppDataLocation, QStringLiteral("icontheme.rcc")); | ||||
51 | if (!iconThemeRcc.isEmpty()) { | ||||
52 | const QString iconThemeName = QStringLiteral("kf5_rcc_theme"); | ||||
53 | const QString iconSubdir = QStringLiteral("/icons/") + iconThemeName; | ||||
54 | if (QResource::registerResource(iconThemeRcc, iconSubdir)) { | ||||
55 | if (QFileInfo::exists(QLatin1Char(':') + iconSubdir + QStringLiteral("/index.theme"))) { | ||||
56 | // Tell Qt about the theme | ||||
57 | // Note that since qtbase commit a8621a3f8, this means the QPA (i.e. KIconLoader) will NOT be used. | ||||
58 | QIcon::setThemeName(iconThemeName); // Qt looks under :/icons automatically | ||||
59 | // Tell KIconTheme about the theme, in case KIconLoader is used directly | ||||
60 | *_themeOverride() = iconThemeName; | ||||
61 | } else { | ||||
62 | qWarning() << "No index.theme found in" << iconThemeRcc; | ||||
63 | QResource::unregisterResource(iconThemeRcc, iconSubdir); | ||||
64 | } | ||||
65 | } else { | ||||
66 | qWarning() << "Invalid rcc file" << iconThemeRcc; | ||||
67 | } | ||||
68 | } | ||||
69 | } | ||||
70 | Q_COREAPP_STARTUP_FUNCTION(initRCCIconTheme) | ||||
71 | | ||||
72 | | ||||
41 | class KIconTheme::KIconThemePrivate | 73 | class KIconTheme::KIconThemePrivate | ||
42 | { | 74 | { | ||
43 | public: | 75 | public: | ||
44 | QString example, screenshot; | 76 | QString example, screenshot; | ||
45 | QString linkOverlay, lockOverlay, zipOverlay, shareOverlay; | 77 | QString linkOverlay, lockOverlay, zipOverlay, shareOverlay; | ||
46 | bool hidden; | 78 | bool hidden; | ||
47 | KSharedConfig::Ptr sharedConfig; | 79 | KSharedConfig::Ptr sharedConfig; | ||
48 | 80 | | |||
49 | int mDefSize[6]; | 81 | int mDefSize[6]; | ||
50 | QList<int> mSizes[6]; | 82 | QList<int> mSizes[6]; | ||
51 | 83 | | |||
52 | int mDepth; | 84 | int mDepth; | ||
53 | QString mDir, mName, mInternalName, mDesc; | 85 | QString mDir, mName, mInternalName, mDesc; | ||
54 | QStringList mInherits; | 86 | QStringList mInherits; | ||
55 | QStringList mExtensions; | 87 | QStringList mExtensions; | ||
56 | QVector<KIconThemeDir *> mDirs; | 88 | QVector<KIconThemeDir *> mDirs; | ||
57 | bool followsColorScheme : 1; | 89 | bool followsColorScheme : 1; | ||
58 | }; | 90 | }; | ||
59 | Q_GLOBAL_STATIC(QString, _themeOverride) | | |||
60 | Q_GLOBAL_STATIC(QString, _theme) | 91 | Q_GLOBAL_STATIC(QString, _theme) | ||
61 | Q_GLOBAL_STATIC(QStringList, _theme_list) | 92 | Q_GLOBAL_STATIC(QStringList, _theme_list) | ||
62 | 93 | | |||
63 | /** | 94 | /** | ||
64 | * A subdirectory in an icon theme. | 95 | * A subdirectory in an icon theme. | ||
65 | */ | 96 | */ | ||
66 | class KIconThemeDir | 97 | class KIconThemeDir | ||
67 | { | 98 | { | ||
▲ Show 20 Lines • Show All 656 Lines • Show Last 20 Lines |