summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/ios/qiosviewcontroller.mm
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@digia.com>2014-09-26 15:06:46 +0200
committerTor Arne Vestbø <tor.arne.vestbo@digia.com>2014-10-02 13:58:01 +0200
commit231a4a11011f9feb35b1eb41846f09d12b79e1ae (patch)
treebcd32c22cedb2eed3f324973c29fd00583d38c0b /src/plugins/platforms/ios/qiosviewcontroller.mm
parentc027175021e0d8b0d1b66cda4667c73cae5e2941 (diff)
iOS: Move statusbar visibility handling to QIOSViewController
It doesn't belong in QIOScreen, and simplifies the flow when changing the focus window or the window state of the focus window. Both will result in calling updateProperties on the view-controller, which will re-configure the statusbar visibility and hide/show it as appropriate, before triggering a re-layout of its own view, which will in turn trigger an update of the screen properties based on the new statusbar state, before re-layouting of QWindow based on the new screen state. Change-Id: I89077a3fb5f843949ce833e4e727d2c753ea2eb6 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
Diffstat (limited to 'src/plugins/platforms/ios/qiosviewcontroller.mm')
-rw-r--r--src/plugins/platforms/ios/qiosviewcontroller.mm62
1 files changed, 50 insertions, 12 deletions
diff --git a/src/plugins/platforms/ios/qiosviewcontroller.mm b/src/plugins/platforms/ios/qiosviewcontroller.mm
index 1c06228e81..ca8d48bf6d 100644
--- a/src/plugins/platforms/ios/qiosviewcontroller.mm
+++ b/src/plugins/platforms/ios/qiosviewcontroller.mm
@@ -147,6 +147,13 @@
#endif
self.changingOrientation = NO;
+
+ // Status bar may be initially hidden at startup through Info.plist
+ self.prefersStatusBarHidden = infoPlistValue(@"UIStatusBarHidden", false);
+
+ QObject::connect(qApp, &QGuiApplication::focusWindowChanged, [self]() {
+ [self updateProperties];
+ });
}
return self;
@@ -173,6 +180,49 @@
[super viewDidUnload];
}
+// -------------------------------------------------------------------------
+
+- (void)updateProperties
+{
+ if (!isQtApplication())
+ return;
+
+ QWindow *focusWindow = QGuiApplication::focusWindow();
+
+ // If we don't have a focus window we leave the statusbar
+ // as is, so that the user can activate a new window with
+ // the same window state without the status bar jumping
+ // back and forth.
+ if (!focusWindow)
+ return;
+
+ // We only care about changes to focusWindow that involves our screen
+ if (!focusWindow->screen() || focusWindow->screen()->handle() != m_screen)
+ return;
+
+ // All decisions are based on the the top level window
+ focusWindow = qt_window_private(focusWindow)->topLevelWindow();
+
+ bool currentStatusBarVisibility = self.prefersStatusBarHidden;
+ self.prefersStatusBarHidden = focusWindow->windowState() == Qt::WindowFullScreen;
+ if (self.prefersStatusBarHidden != currentStatusBarVisibility) {
+#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_7_0)
+ if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_7_0) {
+ [self setNeedsStatusBarAppearanceUpdate];
+ } else
+#endif
+ {
+ [[UIApplication sharedApplication]
+ setStatusBarHidden:self.prefersStatusBarHidden
+ withAnimation:UIStatusBarAnimationNone];
+ }
+
+ [self.view setNeedsLayout];
+ }
+}
+
+// -------------------------------------------------------------------------
+
-(BOOL)shouldAutorotate
{
// Until a proper orientation and rotation API is in place, we always auto rotate.
@@ -261,17 +311,5 @@
}
#endif
-- (BOOL)prefersStatusBarHidden
-{
- static bool hiddenFromPlist = infoPlistValue(@"UIStatusBarHidden", false);
- if (hiddenFromPlist)
- return YES;
- QWindow *focusWindow = QGuiApplication::focusWindow();
- if (!focusWindow)
- return [UIApplication sharedApplication].statusBarHidden;
-
- return qt_window_private(focusWindow)->topLevelWindow()->windowState() == Qt::WindowFullScreen;
-}
-
@end