macOS: Always override NSApp.appearance on requestColorScheme

We can't compare to the effective appearance, as we'll then fail to
set an explicit appearance if the requested appearance matches the
current appearance, which results in the requested appearance not
sticking when the system appearance changes.

Pick-to: 6.9 6.8 6.5
Change-Id: Ibd8f7825051f1a67bed25a0abb2f1a13356f32d8
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
Tor Arne Vestbø 2025-04-15 23:58:16 +02:00
parent fb555ff7df
commit 05e59e37c8

View File

@ -489,8 +489,11 @@ void QCocoaTheme::requestColorScheme(Qt::ColorScheme scheme)
case Qt::ColorScheme::Unknown:
break;
}
if (appearance != NSApp.effectiveAppearance)
NSApplication.sharedApplication.appearance = appearance;
// Always override the appearance, even if it's the same
// as the current effective appearance, as otherwise the
// requested appearance won't stick on system theme changes.
NSApp.appearance = appearance;
}
/*