From b688baf3b66df42900a5912018253f7d9834fd05 Mon Sep 17 00:00:00 2001 From: ispyisail Date: Sun, 26 Jul 2026 22:28:32 +1200 Subject: [PATCH] Clear the application stylesheet when using system colors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- sources/qetapp.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sources/qetapp.cpp b/sources/qetapp.cpp index adac51c54..3a8d4231b 100644 --- a/sources/qetapp.cpp +++ b/sources/qetapp.cpp @@ -1690,11 +1690,15 @@ void QETApp::invertMainWindowVisibility(QWidget *window) { void QETApp::useSystemPalette(bool use) { if (use) { qApp->setPalette(initial_palette_); - qApp->setStyleSheet( - "QAbstractScrollArea#mdiarea {" - "background-color -> setPalette(initial_palette_);" - "}" - ); + // Drop any stylesheet previously loaded from style.css: with system + // colors requested, the palette set just above is what provides them. + // + // 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 { QFile file(configDir() + "/style.css"); if (file.open(QFile::ReadOnly)) {