diff --git a/src/kicontheme.cpp b/src/kicontheme.cpp --- a/src/kicontheme.cpp +++ b/src/kicontheme.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -48,6 +49,8 @@ // For this reason we use AppDataLocation: BINDIR/data on Windows, Resources on OS X void initRCCIconTheme() { + // old variant: one RCC file that will be enforced as icon theme + // to be compatible: if this succeeds, we don't try the new variant of looking up multiple rcc files! const QString iconThemeRcc = QStandardPaths::locate(QStandardPaths::AppDataLocation, QStringLiteral("icontheme.rcc")); if (!iconThemeRcc.isEmpty()) { const QString iconThemeName = QStringLiteral("kf5_rcc_theme"); @@ -59,14 +62,28 @@ QIcon::setThemeName(iconThemeName); // Qt looks under :/icons automatically // Tell KIconTheme about the theme, in case KIconLoader is used directly *_themeOverride() = iconThemeName; + // stop here, we have found a valid rcc that shall be used! + return; } else { qWarning() << "No index.theme found in" << iconThemeRcc; QResource::unregisterResource(iconThemeRcc, iconSubdir); } } else { qWarning() << "Invalid rcc file" << iconThemeRcc; } } + + // new variant: load all rcc files we find, assume the have internally proper :/icons//... naming + // TODO: we might want to use QLibrary and load the stuff as shared libraries to have mmap on all platforms for the data! + for (const auto &iconDir : QStandardPaths::locateAll(QStandardPaths::AppDataLocation, QStringLiteral("icons"), QStandardPaths::LocateDirectory)) { + QDirIterator it(iconDir, QStringList() << QLatin1String("*.rcc"), QDir::Files); + while (it.hasNext()) { + const auto iconFile = it.next(); + if (!QResource::registerResource(iconFile)) { + qWarning() << "Invalid rcc file" << iconFile; + } + } + } } Q_COREAPP_STARTUP_FUNCTION(initRCCIconTheme)