refactor: move icon theme settings to styleUtils::updateIconTheme
This commit is contained in:
committed by
Chris Rizzitello
parent
91b836a486
commit
88e385d050
@ -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);
|
||||
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user