refactor: move icon theme settings to styleUtils::updateIconTheme
This commit is contained in:
parent
91b836a486
commit
88e385d050
2 changed files with 13 additions and 6 deletions
|
|
@ -122,12 +122,7 @@ int main(int argc, char *argv[])
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Sets the fallback icon path and fallback theme
|
// Sets the fallback icon path and fallback theme
|
||||||
const auto themeName = QStringLiteral("deskflow-%1").arg(iconMode());
|
updateIconTheme();
|
||||||
if (QIcon::themeName().isEmpty())
|
|
||||||
QIcon::setThemeName(themeName);
|
|
||||||
else
|
|
||||||
QIcon::setFallbackThemeName(themeName);
|
|
||||||
QIcon::setFallbackSearchPaths({QStringLiteral(":/icons/%1").arg(themeName)});
|
|
||||||
|
|
||||||
qInstallMessageHandler(deskflow::gui::messages::messageHandler);
|
qInstallMessageHandler(deskflow::gui::messages::messageHandler);
|
||||||
qInfo("%s v%s", kAppName, kDisplayVersion);
|
qInfo("%s v%s", kAppName, kDisplayVersion);
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@
|
||||||
#include <QPalette>
|
#include <QPalette>
|
||||||
#include <QStyleHints>
|
#include <QStyleHints>
|
||||||
|
|
||||||
|
#include "common/Constants.h"
|
||||||
|
|
||||||
namespace deskflow::gui {
|
namespace deskflow::gui {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -35,4 +37,14 @@ inline QString iconMode()
|
||||||
return isDarkMode() ? QStringLiteral("dark") : QStringLiteral("light");
|
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
|
} // namespace deskflow::gui
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue