Skip to content

Commit e875d49

Browse files
UdjinM6codablock
authored andcommitted
Define defaultTheme and darkThemePrefix as constants and use them instead of plain strings (#3288)
1 parent 1d203b4 commit e875d49

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/qt/guiutil.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ extern double NSAppKitVersionNumber;
7878

7979
namespace GUIUtil {
8080

81+
// The theme to set by default if settings are missing or incorrect
82+
static const QString defaultTheme = "Light";
83+
// The prefix a theme name should have if we want to apply dark colors and styles to it
84+
static const QString darkThemePrefix = "Dark";
85+
8186
static const std::map<ThemedColor, QColor> themedColors = {
8287
{ ThemedColor::DEFAULT, QColor(0, 0, 0) },
8388
{ ThemedColor::UNCONFIRMED, QColor(128, 128, 128) },
@@ -121,13 +126,13 @@ static const std::map<ThemedStyle, QString> themedDarkStyles = {
121126
QColor getThemedQColor(ThemedColor color)
122127
{
123128
QString theme = QSettings().value("theme", "").toString();
124-
return theme.startsWith("dark") ? themedDarkColors.at(color) : themedColors.at(color);
129+
return theme.startsWith(darkThemePrefix) ? themedDarkColors.at(color) : themedColors.at(color);
125130
}
126131

127132
QString getThemedStyleQString(ThemedStyle style)
128133
{
129134
QString theme = QSettings().value("theme", "").toString();
130-
return theme.startsWith("dark") ? themedDarkStyles.at(style) : themedStyles.at(style);
135+
return theme.startsWith(darkThemePrefix) ? themedDarkStyles.at(style) : themedStyles.at(style);
131136
}
132137

133138
QString dateTimeStr(const QDateTime &date)
@@ -927,9 +932,8 @@ QString loadStyleSheet()
927932

928933
QDir themes(":themes");
929934
// Make sure settings are pointing to an existent theme
930-
// Set "Light" theme by default if settings are missing or incorrect
931935
if (theme.isEmpty() || !themes.exists(theme)) {
932-
theme = "Light";
936+
theme = defaultTheme;
933937
settings.setValue("theme", theme);
934938
}
935939

0 commit comments

Comments
 (0)