Commit 06314a77 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix AppImage icons.

Related to #1447
CCBUG: 451406
parent 6e90d733
......@@ -102,11 +102,28 @@ int main(int argc, char *argv[])
splash.show();
qApp->processEvents(QEventLoop::AllEvents);
QString packageType;
if (qEnvironmentVariableIsSet("PACKAGE_TYPE")) {
packageType = qgetenv("PACKAGE_TYPE").toLower();
} else {
// no package type defined, try to detected it
QString appPath = qApp->applicationDirPath();
if (appPath.contains(QStringLiteral("/tmp/.mount_"))) {
packageType = QStringLiteral("appimage");
}
if (appPath.contains(QStringLiteral("/snap"))) {
packageType = QStringLiteral("snap");
} else {
qDebug() << "Could not detect package type, probably default? App dir is" << qApp->applicationDirPath();
}
}
#ifdef Q_OS_WIN
qputenv("KDE_FORK_SLAVES", "1");
QString path = qApp->applicationDirPath() + QLatin1Char(';') + qgetenv("PATH");
qputenv("PATH", path.toUtf8().constData());
#endif
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS)
const QStringList themes{"/icons/breeze/breeze-icons.rcc", "/icons/breeze-dark/breeze-icons-dark.rcc"};
for (const QString &theme : themes) {
......@@ -125,22 +142,33 @@ int main(int argc, char *argv[])
}
}
}
#endif
QString packageType;
if (qEnvironmentVariableIsSet("PACKAGE_TYPE")) {
packageType = qgetenv("PACKAGE_TYPE").toLower();
} else {
// no package type defined, try to detected it
QString appPath = qApp->applicationDirPath();
if (appPath.contains(QStringLiteral("/tmp/.mount_"))) {
packageType = QStringLiteral("appimage");
}
if (appPath.contains(QStringLiteral("/snap"))) {
packageType = QStringLiteral("snap");
} else {
qDebug() << "Could not detect package type, probably default? App dir is" << qApp->applicationDirPath();
#else
// AppImage
if (packageType == QStringLiteral("appimage")) {
QMap<QString, QString> themeMap;
themeMap.insert("breeze", "/../icons/breeze/breeze-icons.rcc");
themeMap.insert("breeze-dark", "/../icons/breeze-dark/breeze-icons-dark.rcc");
QMapIterator<QString, QString> i(themeMap);
while (i.hasNext()) {
i.next();
QString themePath = QStandardPaths::locate(QStandardPaths::AppDataLocation, i.value());
if (!themePath.isEmpty()) {
const QString iconSubdir = "/icons/" + i.key();
if (QResource::registerResource(themePath, iconSubdir)) {
if (QFileInfo::exists(QLatin1Char(':') + iconSubdir + QStringLiteral("/index.theme"))) {
qDebug() << "Loaded icon theme:" << i.key();
} else {
qWarning() << "No index.theme found for" << i.key();
QResource::unregisterResource(themePath, iconSubdir);
}
} else {
qWarning() << "Invalid rcc file" << i.key();
}
}
}
}
#endif
bool inSandbox = false;
if (packageType == QStringLiteral("appimage") || packageType == QStringLiteral("flatpak") || packageType == QStringLiteral("snap")) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment