diff options
-rw-r--r-- | src/plugins/platforms/ios/qiosglobal.h | 1 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qiosglobal.mm | 13 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qiosscreen.mm | 2 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qioswindow.mm | 2 |
4 files changed, 16 insertions, 2 deletions
diff --git a/src/plugins/platforms/ios/qiosglobal.h b/src/plugins/platforms/ios/qiosglobal.h index cf4c89cfad..7a23a2a485 100644 --- a/src/plugins/platforms/ios/qiosglobal.h +++ b/src/plugins/platforms/ios/qiosglobal.h @@ -49,6 +49,7 @@ QT_BEGIN_NAMESPACE +bool isQtApplication(); CGRect toCGRect(const QRect &rect); QRect fromCGRect(const CGRect &rect); Qt::ScreenOrientation toQtScreenOrientation(UIDeviceOrientation uiDeviceOrientation); diff --git a/src/plugins/platforms/ios/qiosglobal.mm b/src/plugins/platforms/ios/qiosglobal.mm index 30138acc1b..a8a89a1637 100644 --- a/src/plugins/platforms/ios/qiosglobal.mm +++ b/src/plugins/platforms/ios/qiosglobal.mm @@ -40,10 +40,23 @@ ****************************************************************************/ #include "qiosglobal.h" +#include "qiosapplicationdelegate.h" #include <QtGui/qscreen.h> QT_BEGIN_NAMESPACE +bool isQtApplication() +{ + // Returns true if the plugin is in full control of the whole application. This means + // that we control the application delegate and the top view controller, and can take + // actions that impacts all parts of the application. The opposite means that we are + // embedded inside a native iOS application, and should be more focused on playing along + // with native UIControls, and less inclined to change structures that lies outside the + // scope of our QWindows/UIViews. + static bool isQt = ([[UIApplication sharedApplication].delegate isKindOfClass:[QIOSApplicationDelegate class]]); + return isQt; +} + 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 87ddc63f4a..fdf2f31ea1 100644 --- a/src/plugins/platforms/ios/qiosscreen.mm +++ b/src/plugins/platforms/ios/qiosscreen.mm @@ -139,7 +139,7 @@ QIOSScreen::QIOSScreen(unsigned int screenIndex) const qreal millimetersPerInch = 25.4; m_physicalSize = QSizeF(m_geometry.size()) / unscaledDpi * millimetersPerInch; - if ([[UIApplication sharedApplication].delegate isKindOfClass:[QIOSApplicationDelegate class]]) { + if (isQtApplication()) { // When in a non-mixed environment, let QScreen follow the current interface orientation: UIViewController *controller = [UIApplication sharedApplication].delegate.window.rootViewController; setPrimaryOrientation(toQtScreenOrientation(controller.interfaceOrientation)); diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index 9b10ba4e1c..af184e2e7b 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -196,7 +196,7 @@ QIOSWindow::QIOSWindow(QWindow *window) , m_glData() , m_devicePixelRatio(1.0) { - if ([[UIApplication sharedApplication].delegate isKindOfClass:[QIOSApplicationDelegate class]]) + if (isQtApplication()) [[UIApplication sharedApplication].delegate.window.rootViewController.view addSubview:m_view]; setWindowState(window->windowState()); |