summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/ios/qiostheme.mm
diff options
context:
space:
mode:
authorDoris Verria <doris.verria@qt.io>2022-03-24 16:21:49 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2022-03-29 18:10:37 +0000
commit1b6874034aec21ada0a5ddba46ac3c03c4ad0fcb (patch)
treec06445133771532890b9cdfbaf7d2d0b81b1841e /src/plugins/platforms/ios/qiostheme.mm
parenta86ee60887e1ef0a83931ee761b542b493673c92 (diff)
Implement QPlatformTheme::appearance() for iOS
Implement support for detecting Light/Dark mode on iOS. This is needed by the QQuickIOSStyle in order to display the proper image assets according to the theme. A further improvement would be to react to theme changes dynamically. Change-Id: I95e11c4a4b647614bdd78d734941d2b11546687a Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/plugins/platforms/ios/qiostheme.mm')
-rw-r--r--src/plugins/platforms/ios/qiostheme.mm13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/plugins/platforms/ios/qiostheme.mm b/src/plugins/platforms/ios/qiostheme.mm
index 9131963818..045b4d45c9 100644
--- a/src/plugins/platforms/ios/qiostheme.mm
+++ b/src/plugins/platforms/ios/qiostheme.mm
@@ -167,6 +167,19 @@ QVariant QIOSTheme::themeHint(ThemeHint hint) const
}
}
+QPlatformTheme::Appearance QIOSTheme::appearance() const
+{
+ if (@available(ios 12, *)) {
+ if (UIWindow *window = qt_apple_sharedApplication().keyWindow) {
+ return window.rootViewController.traitCollection.userInterfaceStyle
+ == UIUserInterfaceStyleDark
+ ? QPlatformTheme::Appearance::Dark
+ : QPlatformTheme::Appearance::Light;
+ }
+ }
+ return QPlatformTheme::Appearance::Unknown;
+}
+
const QFont *QIOSTheme::font(Font type) const
{
const auto *platformIntegration = QGuiApplicationPrivate::platformIntegration();