qiostheme: Don't determine the appearance mode from the keyWindow

We were querying the traitCollection property of the application's
keyWindow in order to determine the appearance mode (light/dark) of
the app.
However, the application may not have a keyWindow (visible window)
by the time the we set up the appearance mode, so get that information
from the last window in the application's windows array instead.

Change-Id: If7435d9f565b5c594a26027c971c16a1e3a9af26
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
Doris Verria 2022-06-02 10:01:21 +02:00
parent 474792a751
commit 259df3ca0b

View File

@ -140,7 +140,7 @@ QVariant QIOSTheme::themeHint(ThemeHint hint) const
QPlatformTheme::Appearance QIOSTheme::appearance() const
{
if (@available(ios 12, *)) {
if (UIWindow *window = qt_apple_sharedApplication().keyWindow) {
if (UIWindow *window = qt_apple_sharedApplication().windows.lastObject) {
return window.rootViewController.traitCollection.userInterfaceStyle
== UIUserInterfaceStyleDark
? QPlatformTheme::Appearance::Dark