From 1a737083f1db32da9f5af45256a3e26b6029d2e3 Mon Sep 17 00:00:00 2001 From: Wladimir Leuschner Date: Mon, 9 Dec 2024 11:50:36 +0100 Subject: [PATCH] QWindows11Style: Override alternate base color in darkmode The alternate base color in darkmode was wrongly set to the accent color instead of a lighter color. This patch overrides the alternate base color for the QWindows11Style. Fixes: QTBUG-131976 Pick-to: 6.8 Change-Id: Ie8f50b0042ca7bf746224275abc0cd255df7a4ad Reviewed-by: Oliver Wolff (cherry picked from commit 79aa4269bcbbedef8206d79318c199df7c8a3c9f) Reviewed-by: Qt Cherry-pick Bot --- .../styles/modernwindows/qwindows11style.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/plugins/styles/modernwindows/qwindows11style.cpp b/src/plugins/styles/modernwindows/qwindows11style.cpp index b40676cd3d7..07fc62f80db 100644 --- a/src/plugins/styles/modernwindows/qwindows11style.cpp +++ b/src/plugins/styles/modernwindows/qwindows11style.cpp @@ -2278,6 +2278,20 @@ static void populateLightSystemBasePalette(QPalette &result) oldStyleSheet = qApp->styleSheet(); } +static void populateDarkSystemBasePalette(QPalette &result) +{ + static QString oldStyleSheet; + const bool styleSheetChanged = oldStyleSheet != qApp->styleSheet(); + + const QColor alternateBase = QColor(0xFF,0xFF,0xFF,0x0F); + + SET_IF_UNRESOLVED(QPalette::Active, QPalette::AlternateBase, alternateBase); + + SET_IF_UNRESOLVED(QPalette::Inactive, QPalette::AlternateBase, alternateBase); + + oldStyleSheet = qApp->styleSheet(); +} + /*! \internal */ @@ -2288,6 +2302,8 @@ void QWindows11Style::polish(QPalette& result) if (!highContrastTheme && colorSchemeIndex == 0) populateLightSystemBasePalette(result); + else if (!highContrastTheme && colorSchemeIndex == 1) + populateDarkSystemBasePalette(result); const bool styleSheetChanged = false; // so the macro works