From ce5ddbf8ba3ca8a0f2edc06c2923ed8346604dfa Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Fri, 14 Jun 2024 19:18:43 -0700 Subject: [PATCH] core: add $XDG_DATA_DIRS/pixmaps to QIcon fallback path Picks up some missing app icons. --- src/core/main.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/core/main.cpp b/src/core/main.cpp index 220bde3..3daf09a 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -333,6 +334,32 @@ int qs_main(int argc, char** argv) { qputenv("QSG_USE_SIMPLE_ANIMATION_DRIVER", "1"); } + // Some programs place icons in the pixmaps folder instead of the icons folder. + // This seems to be controlled by the QPA and qt6ct does not provide it. + { + QList dataPaths; + + if (qEnvironmentVariableIsSet("XDG_DATA_DIRS")) { + auto var = qEnvironmentVariable("XDG_DATA_DIRS"); + dataPaths = var.split(u':', Qt::SkipEmptyParts); + } else { + dataPaths.push_back("/usr/local/share"); + dataPaths.push_back("/usr/share"); + } + + auto fallbackPaths = QIcon::fallbackSearchPaths(); + + for (auto& path: dataPaths) { + auto newPath = QDir(path).filePath("pixmaps"); + + if (!fallbackPaths.contains(newPath)) { + fallbackPaths.push_back(newPath); + } + } + + QIcon::setFallbackSearchPaths(fallbackPaths); + } + QGuiApplication::setDesktopSettingsAware(desktopSettingsAware); QGuiApplication* app = nullptr;