From eccd365ac544c0e24da86bfaf09d24130feb2e0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 15 Nov 2013 19:42:49 +0100 Subject: iOS: Don't enable kEAGLDrawablePropertyRetainedBacking We report our swap-behavior as QSurfaceFormat::DoubleBuffer, which means there's no point in using retained backing. This was a left-over from when we reported single-buffered swaps, which didn't work to well as clients would wrongly assume swap was not needed at all. Change-Id: Id26df2f8b282892c720d48cfe85eb9e010f1500d Reviewed-by: Richard Moe Gustavsen Reviewed-by: Gunnar Sletta --- src/plugins/platforms/ios/qioswindow.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index e02f570634..af429f9d65 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -105,7 +105,7 @@ CAEAGLLayer *eaglLayer = static_cast(self.layer); eaglLayer.opaque = TRUE; eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithBool:YES], kEAGLDrawablePropertyRetainedBacking, + [NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil]; // Set up text input -- cgit v1.2.3 From dcd71a08972e9d6de73242ce8073de89a19f7c97 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 13 Nov 2013 13:23:09 +0100 Subject: Android: Remove usage of QObject::tr() Change-Id: I948d9fc36aa52d2d247a84b5d9b2cf949b93387d Reviewed-by: Eskil Abrahamsen Blomfeldt Reviewed-by: Paul Olav Tvete --- .../android/src/qandroidplatformdialoghelpers.cpp | 57 ++++++++-------------- 1 file changed, 19 insertions(+), 38 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/android/src/qandroidplatformdialoghelpers.cpp b/src/plugins/platforms/android/src/qandroidplatformdialoghelpers.cpp index f9eb34751e..f379402e18 100644 --- a/src/plugins/platforms/android/src/qandroidplatformdialoghelpers.cpp +++ b/src/plugins/platforms/android/src/qandroidplatformdialoghelpers.cpp @@ -63,64 +63,45 @@ void QAndroidPlatformMessageDialogHelper::exec() static QString standardButtonText(int sbutton) { - QString buttonText = 0; switch (sbutton) { case QMessageDialogOptions::Ok: - buttonText = QObject::tr("OK"); - break; + return QAndroidPlatformMessageDialogHelper::tr("OK"); case QMessageDialogOptions::Save: - buttonText = QObject::tr("Save"); - break; + return QAndroidPlatformMessageDialogHelper::tr("Save"); case QMessageDialogOptions::Open: - buttonText = QObject::tr("Open"); - break; + return QAndroidPlatformMessageDialogHelper::tr("Open"); case QMessageDialogOptions::Cancel: - buttonText = QObject::tr("Cancel"); - break; + return QAndroidPlatformMessageDialogHelper::tr("Cancel"); case QMessageDialogOptions::Close: - buttonText = QObject::tr("Close"); - break; + return QAndroidPlatformMessageDialogHelper::tr("Close"); case QMessageDialogOptions::Apply: - buttonText = QObject::tr("Apply"); - break; + return QAndroidPlatformMessageDialogHelper::tr("Apply"); case QMessageDialogOptions::Reset: - buttonText = QObject::tr("Reset"); - break; + return QAndroidPlatformMessageDialogHelper::tr("Reset"); case QMessageDialogOptions::Help: - buttonText = QObject::tr("Help"); - break; + return QAndroidPlatformMessageDialogHelper::tr("Help"); case QMessageDialogOptions::Discard: - buttonText = QObject::tr("Discard"); - break; + return QAndroidPlatformMessageDialogHelper::tr("Discard"); case QMessageDialogOptions::Yes: - buttonText = QObject::tr("Yes"); - break; + return QAndroidPlatformMessageDialogHelper::tr("Yes"); case QMessageDialogOptions::YesToAll: - buttonText = QObject::tr("Yes to All"); - break; + return QAndroidPlatformMessageDialogHelper::tr("Yes to All"); case QMessageDialogOptions::No: - buttonText = QObject::tr("No"); - break; + return QAndroidPlatformMessageDialogHelper::tr("No"); case QMessageDialogOptions::NoToAll: - buttonText = QObject::tr("No to All"); - break; + return QAndroidPlatformMessageDialogHelper::tr("No to All"); case QMessageDialogOptions::SaveAll: - buttonText = QObject::tr("Save All"); - break; + return QAndroidPlatformMessageDialogHelper::tr("Save All"); case QMessageDialogOptions::Abort: - buttonText = QObject::tr("Abort"); - break; + return QAndroidPlatformMessageDialogHelper::tr("Abort"); case QMessageDialogOptions::Retry: - buttonText = QObject::tr("Retry"); - break; + return QAndroidPlatformMessageDialogHelper::tr("Retry"); case QMessageDialogOptions::Ignore: - buttonText = QObject::tr("Ignore"); - break; + return QAndroidPlatformMessageDialogHelper::tr("Ignore"); case QMessageDialogOptions::RestoreDefaults: - buttonText = QObject::tr("Restore Defaults"); - break; + return QAndroidPlatformMessageDialogHelper::tr("Restore Defaults"); } // switch - return buttonText; + return QString(); } bool QAndroidPlatformMessageDialogHelper::show(Qt::WindowFlags windowFlags -- cgit v1.2.3 From 0c012b647064bd39eaf751b9a0e467fbf18441ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 15 Nov 2013 10:52:50 +0100 Subject: iOS: Send expose events in the window's coordinate system, not the parent's Change-Id: I4aa1a354ca14864bd9898ebd331871d7b32d3ae0 Reviewed-by: Richard Moe Gustavsen Reviewed-by: Gunnar Sletta --- src/plugins/platforms/ios/qioswindow.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index af429f9d65..3d1fe935e5 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -168,7 +168,7 @@ QRect geometry = fromCGRect(self.frame); m_qioswindow->QPlatformWindow::setGeometry(geometry); QWindowSystemInterface::handleGeometryChange(m_qioswindow->window(), geometry); - QWindowSystemInterface::handleExposeEvent(m_qioswindow->window(), geometry); + QWindowSystemInterface::handleExposeEvent(m_qioswindow->window(), QRect(QPoint(), geometry.size())); // If we have a new size here we need to resize the FBO's corresponding buffers, // but we defer that to when the application calls makeCurrent. -- cgit v1.2.3 From 837228151d085264e8244969349b3d68d6f9cc94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 18 Nov 2013 11:32:32 +0100 Subject: iOS: Don't keep around reference to a single QIOSViewController We might have more of them in a multi-screen setup or when implementing support for modal windows using sub-viewcontrollers. Change-Id: Ibe98273a13af981fffe2704a2c05bfd9d3f3e9e0 Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/ios/qiosapplicationdelegate.h | 1 - src/plugins/platforms/ios/qiosapplicationdelegate.mm | 5 +---- src/plugins/platforms/ios/qiosglobal.h | 1 - src/plugins/platforms/ios/qiosglobal.mm | 11 ----------- src/plugins/platforms/ios/qiosscreen.mm | 2 +- src/plugins/platforms/ios/qioswindow.h | 1 + src/plugins/platforms/ios/qioswindow.mm | 19 +++++++++++++++++-- 7 files changed, 20 insertions(+), 20 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/ios/qiosapplicationdelegate.h b/src/plugins/platforms/ios/qiosapplicationdelegate.h index bfe31af198..617b740d6e 100644 --- a/src/plugins/platforms/ios/qiosapplicationdelegate.h +++ b/src/plugins/platforms/ios/qiosapplicationdelegate.h @@ -47,6 +47,5 @@ @interface QIOSApplicationDelegate : UIResponder @property (strong, nonatomic) UIWindow *window; -@property (strong, nonatomic) QIOSViewController *qiosViewController; @end diff --git a/src/plugins/platforms/ios/qiosapplicationdelegate.mm b/src/plugins/platforms/ios/qiosapplicationdelegate.mm index 4d88faba75..775074baae 100644 --- a/src/plugins/platforms/ios/qiosapplicationdelegate.mm +++ b/src/plugins/platforms/ios/qiosapplicationdelegate.mm @@ -49,7 +49,6 @@ @implementation QIOSApplicationDelegate @synthesize window; -@synthesize qiosViewController; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { @@ -57,8 +56,7 @@ Q_UNUSED(launchOptions); self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; - self.qiosViewController = [[[QIOSViewController alloc] init] autorelease]; - self.window.rootViewController = self.qiosViewController; + self.window.rootViewController = [[[QIOSViewController alloc] init] autorelease]; self.window.hidden = NO; @@ -67,7 +65,6 @@ - (void)dealloc { - [qiosViewController release]; [window release]; [super dealloc]; } diff --git a/src/plugins/platforms/ios/qiosglobal.h b/src/plugins/platforms/ios/qiosglobal.h index fd328c9171..41b0d7f93a 100644 --- a/src/plugins/platforms/ios/qiosglobal.h +++ b/src/plugins/platforms/ios/qiosglobal.h @@ -52,7 +52,6 @@ QT_BEGIN_NAMESPACE class QPlatformScreen; bool isQtApplication(); -QIOSViewController *qiosViewController(); CGRect toCGRect(const QRect &rect); QRect fromCGRect(const CGRect &rect); diff --git a/src/plugins/platforms/ios/qiosglobal.mm b/src/plugins/platforms/ios/qiosglobal.mm index 9b8462a6cc..be68e4d7d5 100644 --- a/src/plugins/platforms/ios/qiosglobal.mm +++ b/src/plugins/platforms/ios/qiosglobal.mm @@ -58,17 +58,6 @@ bool isQtApplication() return isQt; } -QIOSViewController *qiosViewController() -{ - // If Qt controls the application, we have created a root view controller were we place top-level - // QWindows. Note that in a mixed native application, our view controller might later be removed or - // added as a child of another controller. To protect against that, we keep an explicit pointer to the - // view controller in cases where this is the controller we need to access. - static QIOSViewController *c = isQtApplication() ? - static_cast([UIApplication sharedApplication].delegate).qiosViewController : nil; - return c; -} - CGRect toCGRect(const QRect &rect) { return CGRectMake(rect.x(), rect.y(), rect.width(), rect.height()); diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm index d57e678810..9d01053548 100644 --- a/src/plugins/platforms/ios/qiosscreen.mm +++ b/src/plugins/platforms/ios/qiosscreen.mm @@ -149,7 +149,7 @@ QIOSScreen::QIOSScreen(unsigned int screenIndex) if (isQtApplication()) { // When in a non-mixed environment, let QScreen follow the current interface orientation: - setPrimaryOrientation(toQtScreenOrientation(UIDeviceOrientation(qiosViewController().interfaceOrientation))); + setPrimaryOrientation(toQtScreenOrientation(UIDeviceOrientation([UIApplication sharedApplication].statusBarOrientation))); } } diff --git a/src/plugins/platforms/ios/qioswindow.h b/src/plugins/platforms/ios/qioswindow.h index 5ded589205..6e8683af00 100644 --- a/src/plugins/platforms/ios/qioswindow.h +++ b/src/plugins/platforms/ios/qioswindow.h @@ -52,6 +52,7 @@ class QIOSWindow; @interface UIView (QIOS) @property(readonly) QWindow *qwindow; +@property(readonly) UIViewController *viewController; @end QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index 3d1fe935e5..b13ce456a4 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -348,6 +348,16 @@ return nil; } +- (UIViewController *)viewController +{ + id responder = self; + while ((responder = [responder nextResponder])) { + if ([responder isKindOfClass:UIViewController.class]) + return responder; + } + return nil; +} + @end QT_BEGIN_NAMESPACE @@ -404,7 +414,7 @@ void QIOSWindow::setVisible(bool visible) requestActivateWindow(); } else { // Activate top-most visible QWindow: - NSArray *subviews = qiosViewController().view.subviews; + NSArray *subviews = m_view.viewController.view.subviews; for (int i = int(subviews.count) - 1; i >= 0; --i) { UIView *view = [subviews objectAtIndex:i]; if (!view.hidden) { @@ -460,7 +470,12 @@ void QIOSWindow::setParent(const QPlatformWindow *parentWindow) UIView *parentView = reinterpret_cast(parentWindow->winId()); [parentView addSubview:m_view]; } else if (isQtApplication()) { - [qiosViewController().view addSubview:m_view]; + for (UIWindow *uiWindow in [[UIApplication sharedApplication] windows]) { + if (uiWindow.screen == static_cast(screen())->uiScreen()) { + [uiWindow.rootViewController.view addSubview:m_view]; + break; + } + } } } -- cgit v1.2.3 From c3e949ac7dd9ddfc3c089061908000c5b4d9dc4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 15 Nov 2013 19:33:57 +0100 Subject: iOS: Allow non-top-level windows to be activated As tested and assumed by tst_QWindow::isActive(). Change-Id: I8d09263ce0acc9c3390a70b4089396257197a1be Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/ios/qioswindow.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index b13ce456a4..de56084848 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -484,12 +484,14 @@ void QIOSWindow::requestActivateWindow() // Note that several windows can be active at the same time if they exist in the same // hierarchy (transient children). But only one window can be QGuiApplication::focusWindow(). // Dispite the name, 'requestActivateWindow' means raise and transfer focus to the window: - if (!window()->isTopLevel() || blockedByModal()) + if (blockedByModal()) return; [m_view.window makeKeyWindow]; - raise(); + if (window()->isTopLevel()) + raise(); + QPlatformInputContext *context = QGuiApplicationPrivate::platformIntegration()->inputContext(); static_cast(context)->focusViewChanged(m_view); QWindowSystemInterface::handleWindowActivated(window()); -- cgit v1.2.3 From 2e2c7327dd26678d26fd7fc431a78c1d05d94411 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 18 Nov 2013 18:25:24 +0100 Subject: iOS: Prepare platform screen for reacting to dynamic updates to properties Change-Id: Idb378416da2b559ed88eb5a764cacff149264f70 Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/ios/qiosscreen.h | 3 +- src/plugins/platforms/ios/qiosscreen.mm | 78 +++++++++++++------------ src/plugins/platforms/ios/qiosviewcontroller.mm | 9 +-- 3 files changed, 45 insertions(+), 45 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/ios/qiosscreen.h b/src/plugins/platforms/ios/qiosscreen.h index 40c7a3ccf7..e70ff4b1a9 100644 --- a/src/plugins/platforms/ios/qiosscreen.h +++ b/src/plugins/platforms/ios/qiosscreen.h @@ -72,13 +72,14 @@ public: UIScreen *uiScreen() const; - void setPrimaryOrientation(Qt::ScreenOrientation orientation); + void updateProperties(); private: UIScreen *m_uiScreen; QRect m_geometry; QRect m_availableGeometry; int m_depth; + uint m_unscaledDpi; QSizeF m_physicalSize; QIOSOrientationListener *m_orientationListener; }; diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm index 9d01053548..2d8ff7d8e1 100644 --- a/src/plugins/platforms/ios/qiosscreen.mm +++ b/src/plugins/platforms/ios/qiosscreen.mm @@ -132,25 +132,14 @@ QIOSScreen::QIOSScreen(unsigned int screenIndex) m_depth = 24; } - int unscaledDpi = 163; // Regular iPhone DPI if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad && !deviceIdentifier.contains(QRegularExpression("^iPad2,[567]$")) /* excluding iPad Mini */) { - unscaledDpi = 132; - }; - - CGRect bounds = [m_uiScreen bounds]; - m_geometry = QRect(bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height); - - CGRect frame = m_uiScreen.applicationFrame; - m_availableGeometry = QRect(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height); - - const qreal millimetersPerInch = 25.4; - m_physicalSize = QSizeF(m_geometry.size()) / unscaledDpi * millimetersPerInch; - - if (isQtApplication()) { - // When in a non-mixed environment, let QScreen follow the current interface orientation: - setPrimaryOrientation(toQtScreenOrientation(UIDeviceOrientation([UIApplication sharedApplication].statusBarOrientation))); + m_unscaledDpi = 132; + } else { + m_unscaledDpi = 163; // Regular iPhone DPI } + + updateProperties(); } QIOSScreen::~QIOSScreen() @@ -158,6 +147,41 @@ QIOSScreen::~QIOSScreen() [m_orientationListener release]; } +void QIOSScreen::updateProperties() +{ + UIWindow *uiWindow = 0; + for (uiWindow in [[UIApplication sharedApplication] windows]) { + if (uiWindow.screen == m_uiScreen) + break; + } + + bool inPortrait = UIInterfaceOrientationIsPortrait(uiWindow.rootViewController.interfaceOrientation); + QRect geometry = inPortrait ? fromCGRect(m_uiScreen.bounds) + : QRect(m_uiScreen.bounds.origin.x, m_uiScreen.bounds.origin.y, + m_uiScreen.bounds.size.height, m_uiScreen.bounds.size.width); + + if (geometry != m_geometry) { + m_geometry = geometry; + + const qreal millimetersPerInch = 25.4; + m_physicalSize = QSizeF(m_geometry.size()) / m_unscaledDpi * millimetersPerInch; + + QWindowSystemInterface::handleScreenGeometryChange(screen(), m_geometry); + } + + QRect availableGeometry = geometry; + + CGSize applicationFrameSize = m_uiScreen.applicationFrame.size; + int statusBarHeight = geometry.height() - (inPortrait ? applicationFrameSize.height : applicationFrameSize.width); + + availableGeometry.adjust(0, statusBarHeight, 0, 0); + + if (availableGeometry != m_availableGeometry) { + m_availableGeometry = availableGeometry; + QWindowSystemInterface::handleScreenAvailableGeometryChange(screen(), m_availableGeometry); + } +} + QRect QIOSScreen::geometry() const { return m_geometry; @@ -213,28 +237,6 @@ void QIOSScreen::setOrientationUpdateMask(Qt::ScreenOrientations mask) } } -void QIOSScreen::setPrimaryOrientation(Qt::ScreenOrientation orientation) -{ - // Note that UIScreen never changes orientation, but QScreen should. To work around - // this, we let QIOSViewController call us whenever interface orientation changes, and - // use that as primary orientation. After all, the viewcontrollers geometry is what we - // place QWindows on top of. A problem with this approach is that QIOSViewController is - // not in use in a mixed environment, which results in no change to primary orientation. - // We see that as acceptable since Qt should most likely not interfere with orientation - // for that case anyway. - bool portrait = screen()->isPortrait(orientation); - if (portrait && m_geometry.width() < m_geometry.height()) - return; - - // Switching portrait/landscape means swapping width/height (and adjusting x/y): - m_geometry = QRect(0, 0, m_geometry.height(), m_geometry.width()); - m_physicalSize = QSizeF(m_physicalSize.height(), m_physicalSize.width()); - m_availableGeometry = fromPortraitToPrimary(fromCGRect(m_uiScreen.applicationFrame), this); - - QWindowSystemInterface::handleScreenGeometryChange(screen(), m_geometry); - QWindowSystemInterface::handleScreenAvailableGeometryChange(screen(), m_availableGeometry); -} - UIScreen *QIOSScreen::uiScreen() const { return m_uiScreen; diff --git a/src/plugins/platforms/ios/qiosviewcontroller.mm b/src/plugins/platforms/ios/qiosviewcontroller.mm index 656a86027d..1d5e69beac 100644 --- a/src/plugins/platforms/ios/qiosviewcontroller.mm +++ b/src/plugins/platforms/ios/qiosviewcontroller.mm @@ -62,19 +62,16 @@ return UIInterfaceOrientationMaskAll; } -- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration +- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration { Q_UNUSED(duration); + Q_UNUSED(interfaceOrientation); if (!QCoreApplication::instance()) return; // FIXME: Store orientation for later (?) - Qt::ScreenOrientation orientation = toQtScreenOrientation(UIDeviceOrientation(toInterfaceOrientation)); - if (orientation == -1) - return; - QIOSScreen *qiosScreen = static_cast(QGuiApplication::primaryScreen()->handle()); - qiosScreen->setPrimaryOrientation(orientation); + qiosScreen->updateProperties(); } @end -- cgit v1.2.3 From ce6fd574b46cb10204f6ef598ea4377639ad1516 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 18 Nov 2013 18:27:37 +0100 Subject: iOS: Report native orientation of QScreen in relation to size Instead of hard-coding it to assume the properties of the main/device screen. Change-Id: I94c978d4334cae5be9d1094a0c315031e54e8e1f Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/ios/qiosscreen.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm index 2d8ff7d8e1..b93511d755 100644 --- a/src/plugins/platforms/ios/qiosscreen.mm +++ b/src/plugins/platforms/ios/qiosscreen.mm @@ -219,7 +219,9 @@ qreal QIOSScreen::devicePixelRatio() const Qt::ScreenOrientation QIOSScreen::nativeOrientation() const { - return Qt::PortraitOrientation; + // A UIScreen stays in the native orientation, regardless of rotation + return m_uiScreen.bounds.size.width >= m_uiScreen.bounds.size.height ? + Qt::LandscapeOrientation : Qt::PortraitOrientation; } Qt::ScreenOrientation QIOSScreen::orientation() const -- cgit v1.2.3 From 16ad93af4959b3c0ae96a4a0d88e25c1626f587d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 18 Nov 2013 19:21:10 +0100 Subject: iOS: Don't use auto resizing masks to deal with maximized/fullscreen It breaks down when the view-controller is fullscreen and we want to take statusbar height into account as well. Unfortunately we can't use constraints either, as it's iOS6+. The approach of managing the geometry manually is closer to what Android does as well. Change-Id: Ib521ba0f50b110c440ab68aacef5a524d5d41154 Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/ios/qiosscreen.mm | 3 +++ src/plugins/platforms/ios/qioswindow.mm | 27 +++++++++++++++++---------- 2 files changed, 20 insertions(+), 10 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm index b93511d755..de6585fd19 100644 --- a/src/plugins/platforms/ios/qiosscreen.mm +++ b/src/plugins/platforms/ios/qiosscreen.mm @@ -180,6 +180,9 @@ void QIOSScreen::updateProperties() m_availableGeometry = availableGeometry; QWindowSystemInterface::handleScreenAvailableGeometryChange(screen(), m_availableGeometry); } + + if (screen()) + resizeMaximizedWindows(); } QRect QIOSScreen::geometry() const diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index de56084848..2413a45e11 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -448,19 +448,26 @@ void QIOSWindow::setWindowState(Qt::WindowState state) // Perhaps setting QWindow to maximized should also mean that we'll show // the statusbar, and vice versa for fullscreen? + if (state != Qt::WindowNoState) + m_normalGeometry = geometry(); + switch (state) { + case Qt::WindowNoState: + setGeometry(m_normalGeometry); + break; case Qt::WindowMaximized: - case Qt::WindowFullScreen: { - // Since UIScreen does not take orientation into account when - // reporting geometry, we need to look at the top view instead: - CGSize fullscreenSize = m_view.window.rootViewController.view.bounds.size; - m_view.frame = CGRectMake(0, 0, fullscreenSize.width, fullscreenSize.height); - m_view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; - break; } - default: - m_view.frame = toCGRect(m_normalGeometry); - m_view.autoresizingMask = UIViewAutoresizingNone; + setGeometry(screen()->availableGeometry()); break; + case Qt::WindowFullScreen: + setGeometry(screen()->geometry()); + break; + case Qt::WindowMinimized: + setGeometry(QRect()); + break; + case Qt::WindowActive: + Q_UNREACHABLE(); + default: + Q_UNREACHABLE(); } } -- cgit v1.2.3