core: add $XDG_DATA_DIRS/pixmaps to QIcon fallback path

Picks up some missing app icons.
This commit is contained in:
outfoxxed 2024-06-14 19:18:43 -07:00
parent d8b72b4c31
commit ce5ddbf8ba
Signed by: outfoxxed
GPG Key ID: 4C88A185FB89301E
1 changed files with 27 additions and 0 deletions

View File

@ -9,6 +9,7 @@
#include <qfileinfo.h>
#include <qguiapplication.h>
#include <qhash.h>
#include <qicon.h>
#include <qlogging.h>
#include <qqmldebug.h>
#include <qquickwindow.h>
@ -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<QString> 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;