iOS: Update statusbar visibility and screen properties before window geometry

When setting a new window state. Otherwise we set the geometry based on
the old screen properties, and then rely on the properties causing
another window layout, which may not always happen. We also need to
explicitly update the screen properties when the statusbar changes
visibility, as there are no callbacks from iOS that consistently gives
us that information.

Change-Id: I1c3328aa3f34d294bc7db8884e611d205fd2c761
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
This commit is contained in:
Tor Arne Vestbø 2013-11-25 15:45:43 +01:00 committed by The Qt Project
parent 6820ac594a
commit c2f08598e1
2 changed files with 12 additions and 8 deletions

View File

@ -205,10 +205,14 @@ void QIOSScreen::updateStatusBarVisibility()
} else
#endif
{
bool wasHidden = [UIApplication sharedApplication].statusBarHidden;
QIOSViewController *viewController = static_cast<QIOSViewController *>(view.viewController);
[[UIApplication sharedApplication]
setStatusBarHidden:[viewController prefersStatusBarHidden]
withAnimation:UIStatusBarAnimationNone];
if ([UIApplication sharedApplication].statusBarHidden != wasHidden)
updateProperties();
}
}

View File

@ -581,6 +581,14 @@ void QIOSWindow::applyGeometry(const QRect &rect)
void QIOSWindow::setWindowState(Qt::WindowState state)
{
// Update the QWindow representation straight away, so that
// we can update the statusbar visibility based on the new
// state before applying geometry changes.
qt_window_private(window())->windowState = state;
if (window()->isTopLevel() && window()->isVisible() && window()->isActive())
static_cast<QIOSScreen *>(screen())->updateStatusBarVisibility();
switch (state) {
case Qt::WindowNoState:
applyGeometry(m_normalGeometry);
@ -599,14 +607,6 @@ void QIOSWindow::setWindowState(Qt::WindowState state)
default:
Q_UNREACHABLE();
}
if (window()->isTopLevel() && window()->isVisible() && window()->isActive()) {
// The window state of the QWindow is not updated until after
// we return from this method, so we have to defer any updates
// of the statusbar that depend on the current window state.
QMetaObject::invokeMethod(static_cast<QIOSScreen *>(screen()),
"updateStatusBarVisibility", Qt::QueuedConnection);
}
}
void QIOSWindow::setParent(const QPlatformWindow *parentWindow)