Skip to content

Commit 0e6c585

Browse files
committed
Don't use custom highlight colour for output window in default theme
Also refactors the basic stylesheet into the theme
1 parent 86a8c33 commit 0e6c585

File tree

3 files changed

+22
-25
lines changed

3 files changed

+22
-25
lines changed

MiniZincIDE/codeeditor.cpp

+1-16
Original file line numberDiff line numberDiff line change
@@ -168,22 +168,7 @@ void CodeEditor::setDarkMode(bool enable)
168168
// palette.setColor(QPalette::HighlightedText, Themes::currentTheme.textColor.get(darkMode));
169169
// this->setPalette(palette);
170170

171-
auto style_sheet = QString("background-color: %1;"
172-
"color: %2;")
173-
.arg(Themes::currentTheme.backgroundColor.get(darkMode).name(QColor::HexArgb))
174-
.arg(Themes::currentTheme.textColor.get(darkMode).name(QColor::HexArgb));
175-
176-
if (!Themes::currentTheme.isSystemTheme) {
177-
// Only change highlight colour for non-system themes
178-
// Many platforms have settings/accessibility options for this, so we should probably follow it by default
179-
style_sheet += QString(
180-
"selection-background-color: %1;"
181-
"selection-color: %2;"
182-
)
183-
.arg(Themes::currentTheme.textHighlightColor.get(darkMode).name(QColor::HexArgb))
184-
.arg(Themes::currentTheme.textColor.get(darkMode).name(QColor::HexArgb));
185-
}
186-
setStyleSheet(style_sheet);
171+
setStyleSheet(Themes::currentTheme.styleSheet(darkMode));
187172
cursorChange(); // Ensure extra selections are the correct colours
188173
}
189174

MiniZincIDE/highlighter.h

+20
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,26 @@ struct Theme
113113
foregroundActiveColor = textColor;
114114
foregroundInactiveColor = ThemeColor(textColor.light.lighter(), textColor.dark.darker());
115115
}
116+
117+
QString styleSheet(bool darkMode) {
118+
auto style_sheet = QString("background-color: %1;"
119+
"color: %2;")
120+
.arg(backgroundColor.get(darkMode).name(QColor::HexArgb))
121+
.arg(textColor.get(darkMode).name(QColor::HexArgb));
122+
123+
if (!isSystemTheme) {
124+
// Only change highlight colour for non-system themes
125+
// Many platforms have settings/accessibility options for this, so we should probably follow it by default
126+
style_sheet += QString(
127+
"selection-background-color: %1;"
128+
"selection-color: %2;"
129+
)
130+
.arg(textHighlightColor.get(darkMode).name(QColor::HexArgb))
131+
.arg(textColor.get(darkMode).name(QColor::HexArgb));
132+
}
133+
134+
return style_sheet;
135+
}
116136
};
117137

118138
namespace Themes{

MiniZincIDE/mainwindow.cpp

+1-9
Original file line numberDiff line numberDiff line change
@@ -2395,15 +2395,7 @@ void MainWindow::on_actionDark_mode_toggled(bool enable)
23952395
#endif
23962396
}
23972397
ui->outputConsole->document()->setDefaultStyleSheet(".mznnotice { color : "+Themes::currentTheme.functionColor.get(darkMode).name()+" }");
2398-
auto style_sheet = QString("background-color: #%1;"
2399-
"color: #%2;"
2400-
"selection-background-color: #%3;"
2401-
"selection-color: #%4;")
2402-
.arg(Themes::currentTheme.backgroundColor.get(darkMode).rgba(), 0, 16)
2403-
.arg(Themes::currentTheme.textColor.get(darkMode).rgba(), 0, 16)
2404-
.arg(Themes::currentTheme.textHighlightColor.get(darkMode).rgba(), 0, 16)
2405-
.arg(Themes::currentTheme.textColor.get(darkMode).rgba(), 0, 16);
2406-
ui->outputConsole->setStyleSheet(style_sheet);
2398+
ui->outputConsole->setStyleSheet(Themes::currentTheme.styleSheet(darkMode));
24072399
// auto palette = ui->outputConsole->palette();
24082400
// palette.setColor(QPalette::Text, Themes::currentTheme.textColor.get(darkMode));
24092401
// palette.setColor(QPalette::Base, Themes::currentTheme.backgroundColor.get(darkMode));

0 commit comments

Comments
 (0)