diff options
author | Tor Arne Vestbø <tor.arne.vestbo@digia.com> | 2013-12-11 14:37:19 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com> | 2015-01-09 11:22:59 +0100 |
commit | 95cb745e002c38e821b385e90d954adf73363e3c (patch) | |
tree | 612d068ebd27c694a6cf52a6fa8f1987d8465008 /src/plugins/platforms/ios/qiosscreen.mm | |
parent | 5c5f43e95b8f56d2bdf34cf5c11aae9d5102f9c6 (diff) |
iOS: Fix QWindow::reportContentOrientationChange on iOS6+
On iOS 6 and above, [UIViewController supportedInterfaceOrientations]
needs to return 0 for [UIApplication setStatusBarOrientation] to work.
This means once you report a content orientation other than the primary
orientation, you'll disable auto-rotation. Reporting the orientation as
Qt::PrimaryOrientation restores the auto-rotation behavior.
Change-Id: I1b8c765c507728fdbc5b828e0b4215324014e221
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@theqtcompany.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
Diffstat (limited to 'src/plugins/platforms/ios/qiosscreen.mm')
-rw-r--r-- | src/plugins/platforms/ios/qiosscreen.mm | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm index 4af2a4965f..712bf0098b 100644 --- a/src/plugins/platforms/ios/qiosscreen.mm +++ b/src/plugins/platforms/ios/qiosscreen.mm @@ -46,6 +46,7 @@ #include <qpa/qwindowsysteminterface.h> #include "qiosapplicationdelegate.h" #include "qiosviewcontroller.h" +#include "quiview.h" #include <sys/sysctl.h> @@ -244,6 +245,22 @@ void QIOSScreen::updateProperties() m_geometry = fromCGRect([rootView convertRect:m_uiScreen.bounds fromView:m_uiWindow]).toRect(); m_availableGeometry = fromCGRect([rootView convertRect:m_uiScreen.applicationFrame fromView:m_uiWindow]).toRect(); + if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_8_0 && ![m_uiWindow.rootViewController shouldAutorotate]) { + // Setting the statusbar orientation (content orientation) on iOS8+ will result in the UIScreen + // updating its geometry and available geometry, which in the case of content orientation is not + // what we want. We want to reflect the screen geometry based on the locked orientation, and + // adjust the available geometry based on the repositioned status bar for the current status + // bar orientation. + + Qt::ScreenOrientation lockedOrientation = toQtScreenOrientation(UIDeviceOrientation(rootView.qtViewController.lockedOrientation)); + Qt::ScreenOrientation contenOrientation = toQtScreenOrientation(UIDeviceOrientation([UIApplication sharedApplication].statusBarOrientation)); + + QTransform transform = screen()->transformBetween(lockedOrientation, contenOrientation, m_geometry).inverted(); + + m_geometry = transform.mapRect(m_geometry); + m_availableGeometry = transform.mapRect(m_availableGeometry); + } + if (m_geometry != previousGeometry || m_availableGeometry != previousAvailableGeometry) { const qreal millimetersPerInch = 25.4; m_physicalSize = QSizeF(m_geometry.size()) / m_unscaledDpi * millimetersPerInch; |