diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-05-23 22:27:56 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-05-23 22:27:56 +0200 |
commit | acdc7613659181ddb5bd24484b180567dacf0108 (patch) | |
tree | 677d60c869d7f3ac598adedfbbde87993931c5e0 /framework/src/frameworkplugin.cpp | |
parent | 9782eba7c164eba5625bc4224ad0f49ec2fc76a7 (diff) | |
download | kube-acdc7613659181ddb5bd24484b180567dacf0108.tar.gz kube-acdc7613659181ddb5bd24484b180567dacf0108.zip |
Register the icons resource from the frameworks plugin
So we have the icons also available from the test views.
Diffstat (limited to 'framework/src/frameworkplugin.cpp')
-rw-r--r-- | framework/src/frameworkplugin.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/framework/src/frameworkplugin.cpp b/framework/src/frameworkplugin.cpp index 91d7a5dd..92c6df3a 100644 --- a/framework/src/frameworkplugin.cpp +++ b/framework/src/frameworkplugin.cpp | |||
@@ -112,10 +112,36 @@ static QObject *keyring_singletontype_provider(QQmlEngine *engine, QJSEngine *sc | |||
112 | return instance; | 112 | return instance; |
113 | } | 113 | } |
114 | 114 | ||
115 | static QString findFile(const QString file, const QStringList importPathList) | ||
116 | { | ||
117 | for (const auto &path : importPathList) { | ||
118 | const QString f = path + file; | ||
119 | if (QFileInfo::exists(f)) { | ||
120 | return f; | ||
121 | } | ||
122 | } | ||
123 | return {}; | ||
124 | } | ||
125 | |||
115 | void FrameworkPlugin::initializeEngine(QQmlEngine *engine, const char *uri) | 126 | void FrameworkPlugin::initializeEngine(QQmlEngine *engine, const char *uri) |
116 | { | 127 | { |
117 | Q_UNUSED(uri); | 128 | Q_UNUSED(uri); |
118 | engine->addImageProvider(QLatin1String("kube"), new KubeImageProvider); | 129 | engine->addImageProvider(QLatin1String("kube"), new KubeImageProvider); |
130 | |||
131 | QString kubeIcons = QStandardPaths::locate(QStandardPaths::AppDataLocation, QStringLiteral("kube-icons.rcc")); | ||
132 | //For windows | ||
133 | if (kubeIcons.isEmpty()) { | ||
134 | const auto locations = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation) + QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation); | ||
135 | kubeIcons = findFile(QStringLiteral("/kube/kube-icons.rcc"), locations); | ||
136 | } | ||
137 | if (!QResource::registerResource(kubeIcons, "/icons/kube")) { | ||
138 | qWarning() << "Failed to register icon resource!" << kubeIcons; | ||
139 | qWarning() << "Searched paths: " << QStandardPaths::standardLocations(QStandardPaths::AppDataLocation) + QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation); | ||
140 | Q_ASSERT(false); | ||
141 | } else { | ||
142 | QIcon::setThemeSearchPaths(QStringList() << QStringLiteral(":/icons")); | ||
143 | QIcon::setThemeName(QStringLiteral("kube")); | ||
144 | } | ||
119 | } | 145 | } |
120 | 146 | ||
121 | void FrameworkPlugin::registerTypes (const char *uri) | 147 | void FrameworkPlugin::registerTypes (const char *uri) |