diff --git a/src/core/main.cpp b/src/core/main.cpp index b6a2f683..57bdfb85 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -822,6 +822,7 @@ int launch(const LaunchArgs& args, char** argv, QCoreApplication* coreApplicatio bool useQApplication = false; bool nativeTextRendering = false; bool desktopSettingsAware = true; + QString iconTheme = qEnvironmentVariable("QS_ICON_THEME"); QHash envOverrides; } pragmas; @@ -834,6 +835,7 @@ int launch(const LaunchArgs& args, char** argv, QCoreApplication* coreApplicatio if (pragma == "UseQApplication") pragmas.useQApplication = true; else if (pragma == "NativeTextRendering") pragmas.nativeTextRendering = true; else if (pragma == "IgnoreSystemSettings") pragmas.desktopSettingsAware = false; + else if (pragma.startsWith("IconTheme ")) pragmas.iconTheme = pragma.sliced(10); else if (pragma.startsWith("Env ")) { auto envPragma = pragma.sliced(4); auto splitIdx = envPragma.indexOf('='); @@ -857,6 +859,10 @@ int launch(const LaunchArgs& args, char** argv, QCoreApplication* coreApplicatio file.close(); + if (!pragmas.iconTheme.isEmpty()) { + QIcon::setThemeName(pragmas.iconTheme); + } + qInfo() << "Shell ID:" << shellId << "Path ID" << pathId; auto launchTime = qs::Common::LAUNCH_TIME.toSecsSinceEpoch(); diff --git a/src/core/qmlglobal.hpp b/src/core/qmlglobal.hpp index ae797d62..fb1853fb 100644 --- a/src/core/qmlglobal.hpp +++ b/src/core/qmlglobal.hpp @@ -124,6 +124,13 @@ public: Q_INVOKABLE QVariant env(const QString& variable); /// Returns a string usable for a @@QtQuick.Image.source for a given system icon. + /// + /// > [!INFO] By default, icons are loaded from the theme selected by the qt platform theme, + /// > which means they should match with all other qt applications on your system. + /// > + /// > If you want to use a different icon theme, you can put `//@ pragma IconTheme ` + /// > at the top of your root config file or set the `QS_ICON_THEME` variable to the name + /// > of your icon theme. Q_INVOKABLE static QString iconPath(const QString& icon); [[nodiscard]] QString workingDirectory() const;