From 26b3a466d7d189cc09f171f2066512feee3737c8 Mon Sep 17 00:00:00 2001 From: Doris Verria Date: Thu, 29 Sep 2022 12:38:33 +0200 Subject: [PATCH] QIOSTheme: Get the appearance mode from the UIWindow's traitCollection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We were getting the appearance (light/dark) through the traitCollection of the UIWindow's rootViewController. It looks like this does not report the correct value when the appearance changes through System Settings. If we get it directly from the UIWindow's traitCollection property, it works as it should. Also, in traitCollectionDidChange: we are checking for changes in the traitCollection of the UIWindow's, not of the viewController's. Change-Id: I437e6922b268fd0069d80557a1034391ed52644b Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qiostheme.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/ios/qiostheme.mm b/src/plugins/platforms/ios/qiostheme.mm index 51d88710bdf..62ba4d669bc 100644 --- a/src/plugins/platforms/ios/qiostheme.mm +++ b/src/plugins/platforms/ios/qiostheme.mm @@ -135,7 +135,7 @@ QVariant QIOSTheme::themeHint(ThemeHint hint) const Qt::Appearance QIOSTheme::appearance() const { if (UIWindow *window = qt_apple_sharedApplication().windows.lastObject) { - return window.rootViewController.traitCollection.userInterfaceStyle + return window.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? Qt::Appearance::Dark : Qt::Appearance::Light;