From ea8277dbf3ad833e3e7b5441228162b483f5a41f Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 11 Jun 2024 15:39:10 +0200 Subject: [PATCH] macOS: use QStyleHint to get color scheme in the style MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit That way, an override through QStyleHints::setColorScheme is immediately respected by the style. As a drive-by, make the helper static and inline. Change-Id: Ia6cde1f5099d9194b25fac812c3184f5a61bf1dc Reviewed-by: Tor Arne Vestbø Reviewed-by: Timur Pocheptsov (cherry picked from commit 4245987f6875d01853053c50d13ecf42b61fc0ad) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/styles/mac/qmacstyle_mac.mm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 3f57f284e6..226da495f4 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -160,7 +161,10 @@ const int pushButtonBevelRectOffsets[3] = { QVector > QMacStylePrivate::scrollBars; -bool isDarkMode() { return QGuiApplicationPrivate::platformTheme()->colorScheme() == Qt::ColorScheme::Dark; } +static inline bool isDarkMode() +{ + return QGuiApplication::styleHints()->colorScheme() == Qt::ColorScheme::Dark; +} #if QT_CONFIG(tabwidget) /*