From acdc7613659181ddb5bd24484b180567dacf0108 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 23 May 2018 22:27:56 +0200 Subject: Register the icons resource from the frameworks plugin So we have the icons also available from the test views. --- framework/src/frameworkplugin.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'framework') 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 return instance; } +static QString findFile(const QString file, const QStringList importPathList) +{ + for (const auto &path : importPathList) { + const QString f = path + file; + if (QFileInfo::exists(f)) { + return f; + } + } + return {}; +} + void FrameworkPlugin::initializeEngine(QQmlEngine *engine, const char *uri) { Q_UNUSED(uri); engine->addImageProvider(QLatin1String("kube"), new KubeImageProvider); + + QString kubeIcons = QStandardPaths::locate(QStandardPaths::AppDataLocation, QStringLiteral("kube-icons.rcc")); + //For windows + if (kubeIcons.isEmpty()) { + const auto locations = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation) + QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation); + kubeIcons = findFile(QStringLiteral("/kube/kube-icons.rcc"), locations); + } + if (!QResource::registerResource(kubeIcons, "/icons/kube")) { + qWarning() << "Failed to register icon resource!" << kubeIcons; + qWarning() << "Searched paths: " << QStandardPaths::standardLocations(QStandardPaths::AppDataLocation) + QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation); + Q_ASSERT(false); + } else { + QIcon::setThemeSearchPaths(QStringList() << QStringLiteral(":/icons")); + QIcon::setThemeName(QStringLiteral("kube")); + } } void FrameworkPlugin::registerTypes (const char *uri) -- cgit v1.2.3