refactor: move icon theme settings to styleUtils::updateIconTheme

This commit is contained in:
sithlord48
2025-10-19 09:16:29 -04:00
committed by Chris Rizzitello
parent 91b836a486
commit 88e385d050
2 changed files with 13 additions and 6 deletions

View File

@ -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);

View File

@ -11,6 +11,8 @@
#include <QPalette>
#include <QStyleHints>
#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