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 | |
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.
-rw-r--r-- | applications/kube/main.cpp | 13 | ||||
-rw-r--r-- | framework/src/frameworkplugin.cpp | 26 |
2 files changed, 26 insertions, 13 deletions
diff --git a/applications/kube/main.cpp b/applications/kube/main.cpp index 411e2d6a..e0d37fc2 100644 --- a/applications/kube/main.cpp +++ b/applications/kube/main.cpp | |||
@@ -169,19 +169,6 @@ int main(int argc, char *argv[]) | |||
169 | app.setApplicationVersion(kube_VERSION_STRING); | 169 | app.setApplicationVersion(kube_VERSION_STRING); |
170 | app.setFont(QFont{"Noto Sans", app.font().pointSize(), QFont::Normal}); | 170 | app.setFont(QFont{"Noto Sans", app.font().pointSize(), QFont::Normal}); |
171 | 171 | ||
172 | QString kubeIcons = QStandardPaths::locate(QStandardPaths::AppDataLocation, QStringLiteral("kube-icons.rcc")); | ||
173 | //For windows | ||
174 | if (kubeIcons.isEmpty()) { | ||
175 | kubeIcons = findFile(QStringLiteral("/kube/kube-icons.rcc"), QStandardPaths::standardLocations(QStandardPaths::AppDataLocation)); | ||
176 | } | ||
177 | if (!QResource::registerResource(kubeIcons, "/icons/kube")) { | ||
178 | qWarning() << "Failed to register icon resource!" << kubeIcons; | ||
179 | qWarning() << "Searched paths: " << QStandardPaths::standardLocations(QStandardPaths::AppDataLocation); | ||
180 | Q_ASSERT(false); | ||
181 | } else { | ||
182 | QIcon::setThemeSearchPaths(QStringList() << QStringLiteral(":/icons")); | ||
183 | QIcon::setThemeName(QStringLiteral("kube")); | ||
184 | } | ||
185 | 172 | ||
186 | QCommandLineParser parser; | 173 | QCommandLineParser parser; |
187 | parser.setApplicationDescription("A communication and collaboration client."); | 174 | parser.setApplicationDescription("A communication and collaboration client."); |
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) |