summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@digia.com>2012-11-07 09:31:00 +0100
committerTor Arne Vestbø <tor.arne.vestbo@digia.com>2013-02-27 23:55:38 +0100
commit19de726725dc123f478ecb2b122d03862c725650 (patch)
tree96348c2dd7ba5549b824687605c1604b33dd6e8d /src/plugins/platforms
parent09187f602c8ac84c9982bb2e433af5524ac2d37d (diff)
iOS: create top-level UIWindow and UIViewController
Create a UIWIndow with a view controller and a view where we can reparent our QIOSWindow views inside. Change-Id: Ic90707d3ebe1af970a3aa2aa0f8c0f4be192456a Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/ios/qiosapplicationdelegate.mm18
-rw-r--r--src/plugins/platforms/ios/qioswindow.mm6
2 files changed, 24 insertions, 0 deletions
diff --git a/src/plugins/platforms/ios/qiosapplicationdelegate.mm b/src/plugins/platforms/ios/qiosapplicationdelegate.mm
index d88b2b83f1..6fed4c1a23 100644
--- a/src/plugins/platforms/ios/qiosapplicationdelegate.mm
+++ b/src/plugins/platforms/ios/qiosapplicationdelegate.mm
@@ -40,6 +40,7 @@
****************************************************************************/
#import "qiosapplicationdelegate.h"
+#include "qioswindow.h"
#include <QtCore/QtCore>
@implementation QIOSApplicationDelegate
@@ -48,7 +49,24 @@
{
Q_UNUSED(application)
Q_UNUSED(launchOptions)
+
+ // If this application delegate is instanciated, it means that
+ // this plugin also created UIApplication. We then also create a
+ // window with a view controller, and set all QWindow views
+ // as children of the controller view:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
+ UIViewController *controller = [[UIViewController alloc] init];
+ self.window.rootViewController = controller;
+ controller.view = [[UIView alloc] init];
+
+ QWindowList windows = QGuiApplication::topLevelWindows();
+ for (int i=0; i<windows.size(); ++i) {
+ if (QIOSWindow *w = static_cast<QIOSWindow *>(windows[i]->handle())) {
+ UIView *winView = w->nativeView();
+ if (winView && !winView.superview)
+ [controller.view addSubview:winView];
+ }
+ }
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm
index 46612ae699..2888228f18 100644
--- a/src/plugins/platforms/ios/qioswindow.mm
+++ b/src/plugins/platforms/ios/qioswindow.mm
@@ -42,6 +42,7 @@
#include "qioswindow.h"
#include "qioscontext.h"
#include "qiosscreen.h"
+#include "qiosapplicationdelegate.h"
#import <QuartzCore/CAEAGLLayer.h>
@@ -170,6 +171,11 @@ QIOSWindow::QIOSWindow(QWindow *window)
: QPlatformWindow(window)
, m_view([[EAGLView alloc] init])
{
+ UIApplication *uiApplication = [UIApplication sharedApplication];
+ if (uiApplication) {
+ if ([uiApplication.delegate isMemberOfClass:[QIOSApplicationDelegate class]])
+ [uiApplication.delegate.window.rootViewController.view addSubview:m_view];
+ }
}
QIOSWindow::~QIOSWindow()