Commit 0e6c585 1 parent 86a8c33 commit 0e6c585 Copy full SHA for 0e6c585
File tree 3 files changed +22
-25
lines changed
3 files changed +22
-25
lines changed Original file line number Diff line number Diff line change @@ -168,22 +168,7 @@ void CodeEditor::setDarkMode(bool enable)
168
168
// palette.setColor(QPalette::HighlightedText, Themes::currentTheme.textColor.get(darkMode));
169
169
// this->setPalette(palette);
170
170
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));
187
172
cursorChange (); // Ensure extra selections are the correct colours
188
173
}
189
174
Original file line number Diff line number Diff line change @@ -113,6 +113,26 @@ struct Theme
113
113
foregroundActiveColor = textColor;
114
114
foregroundInactiveColor = ThemeColor (textColor.light .lighter (), textColor.dark .darker ());
115
115
}
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
+ }
116
136
};
117
137
118
138
namespace Themes {
Original file line number Diff line number Diff line change @@ -2395,15 +2395,7 @@ void MainWindow::on_actionDark_mode_toggled(bool enable)
2395
2395
#endif
2396
2396
}
2397
2397
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));
2407
2399
// auto palette = ui->outputConsole->palette();
2408
2400
// palette.setColor(QPalette::Text, Themes::currentTheme.textColor.get(darkMode));
2409
2401
// palette.setColor(QPalette::Base, Themes::currentTheme.backgroundColor.get(darkMode));
You can’t perform that action at this time.
0 commit comments