mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-08-01 09:04:13 +02:00
Clear the application stylesheet when using system colors
QETApp::useSystemPalette(true) installed a one-rule application stylesheet
whose only declaration was invalid CSS:
QAbstractScrollArea#mdiarea {
background-color -> setPalette(initial_palette_);
}
That is not a CSS declaration but a note-to-self, committed in e6c32bc0
("Background set to use System Palette", 2014) when a hardcoded
background-color:#D5D2D1;
was replaced with a reminder to derive the color from the palette instead.
Qt's CSS parser silently skips invalid declarations, and at the time the
same rule still carried valid background-image/-repeat/-position
properties, so the block kept working and nothing looked wrong. Those
properties were dropped later, leaving a rule with no valid declarations
at all.
The rule has therefore styled nothing for some time. It is not harmless
though: a non-empty application stylesheet wraps every widget in
QStyleSheetStyle, which overrides per-widget QWidget::setStyle(). QET
does not currently call QWidget::setStyle() anywhere, so nothing is
visibly broken today, but it blocks that API for future work — it was
found while prototyping a palette-based dark mode (see #553).
Replace it with an explicit setStyleSheet(QString()). The behavior of the
"use system colors" branch is unchanged: it already dropped whatever
style.css had loaded (by overwriting it with the inert rule), and the
qApp->setPalette(initial_palette_) call on the line above is what actually
supplies the system colors — which is what the 2014 note was asking for.
The style.css path (use == false) is untouched.
Reported by DieterMayerOSS in #553.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+9
-5
@@ -1690,11 +1690,15 @@ void QETApp::invertMainWindowVisibility(QWidget *window) {
|
|||||||
void QETApp::useSystemPalette(bool use) {
|
void QETApp::useSystemPalette(bool use) {
|
||||||
if (use) {
|
if (use) {
|
||||||
qApp->setPalette(initial_palette_);
|
qApp->setPalette(initial_palette_);
|
||||||
qApp->setStyleSheet(
|
// Drop any stylesheet previously loaded from style.css: with system
|
||||||
"QAbstractScrollArea#mdiarea {"
|
// colors requested, the palette set just above is what provides them.
|
||||||
"background-color -> setPalette(initial_palette_);"
|
//
|
||||||
"}"
|
// This used to install a one-rule stylesheet whose only declaration
|
||||||
);
|
// was invalid CSS ("background-color -> setPalette(initial_palette_);",
|
||||||
|
// a note-to-self committed in e6c32bc0, 2014). It styled nothing, but
|
||||||
|
// a non-empty application stylesheet still wraps every widget in
|
||||||
|
// QStyleSheetStyle, which overrides per-widget QWidget::setStyle().
|
||||||
|
qApp->setStyleSheet(QString());
|
||||||
} else {
|
} else {
|
||||||
QFile file(configDir() + "/style.css");
|
QFile file(configDir() + "/style.css");
|
||||||
if (file.open(QFile::ReadOnly)) {
|
if (file.open(QFile::ReadOnly)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user