From 88e385d05099a2fa701d95fe352143c57c397609 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Sun, 19 Oct 2025 09:16:29 -0400 Subject: [PATCH] refactor: move icon theme settings to styleUtils::updateIconTheme --- src/apps/deskflow-gui/deskflow-gui.cpp | 7 +------ src/lib/gui/StyleUtils.h | 12 ++++++++++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/apps/deskflow-gui/deskflow-gui.cpp b/src/apps/deskflow-gui/deskflow-gui.cpp index b574ffdb6..d9751687e 100644 --- a/src/apps/deskflow-gui/deskflow-gui.cpp +++ b/src/apps/deskflow-gui/deskflow-gui.cpp @@ -122,12 +122,7 @@ int main(int argc, char *argv[]) #endif // Sets the fallback icon path and fallback theme - const auto themeName = QStringLiteral("deskflow-%1").arg(iconMode()); - if (QIcon::themeName().isEmpty()) - QIcon::setThemeName(themeName); - else - QIcon::setFallbackThemeName(themeName); - QIcon::setFallbackSearchPaths({QStringLiteral(":/icons/%1").arg(themeName)}); + updateIconTheme(); qInstallMessageHandler(deskflow::gui::messages::messageHandler); qInfo("%s v%s", kAppName, kDisplayVersion); diff --git a/src/lib/gui/StyleUtils.h b/src/lib/gui/StyleUtils.h index 1ef899387..b86d8d1e6 100644 --- a/src/lib/gui/StyleUtils.h +++ b/src/lib/gui/StyleUtils.h @@ -11,6 +11,8 @@ #include #include +#include "common/Constants.h" + namespace deskflow::gui { /** @@ -35,4 +37,14 @@ inline QString iconMode() return isDarkMode() ? QStringLiteral("dark") : QStringLiteral("light"); } +inline void updateIconTheme() +{ + // Sets the fallback icon path and fallback theme + const auto themeName = QStringLiteral("%1-%2").arg(kAppId, iconMode()); + if (QIcon::themeName().isEmpty() || QIcon::themeName().startsWith(kAppId)) + QIcon::setThemeName(themeName); + else + QIcon::setFallbackThemeName(themeName); + QIcon::setFallbackSearchPaths({QStringLiteral(":/icons/%1").arg(themeName)}); +} } // namespace deskflow::gui