diff options
Diffstat (limited to 'src/plugins/platforms/ios/qiosapplicationdelegate.mm')
-rw-r--r-- | src/plugins/platforms/ios/qiosapplicationdelegate.mm | 59 |
1 files changed, 33 insertions, 26 deletions
diff --git a/src/plugins/platforms/ios/qiosapplicationdelegate.mm b/src/plugins/platforms/ios/qiosapplicationdelegate.mm index 10cbe529c4..52d94f38fb 100644 --- a/src/plugins/platforms/ios/qiosapplicationdelegate.mm +++ b/src/plugins/platforms/ios/qiosapplicationdelegate.mm @@ -39,10 +39,15 @@ ** ****************************************************************************/ -#import "qiosapplicationdelegate.h" +#include "qiosapplicationdelegate.h" + +#include "qiosviewcontroller.h" #include "qioswindow.h" + #include <QtCore/QtCore> +extern int qt_user_main(int argc, char *argv[]); + @implementation QIOSApplicationDelegate @synthesize window; @@ -50,40 +55,43 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - Q_UNUSED(application) - Q_UNUSED(launchOptions) + Q_UNUSED(application); + Q_UNUSED(launchOptions); - return YES; -} + self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; + self.qiosViewController = [[[QIOSViewController alloc] init] autorelease]; + self.window.rootViewController = self.qiosViewController; -- (void)applicationWillResignActive:(UIApplication *)application -{ - Q_UNUSED(application) -} +#ifdef QT_DEBUG + self.window.backgroundColor = [UIColor cyanColor]; +#endif -- (void)applicationDidEnterBackground:(UIApplication *)application -{ - Q_UNUSED(application) -} + [self.window makeKeyAndVisible]; -- (void)applicationWillEnterForeground:(UIApplication *)application -{ - Q_UNUSED(application) - // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. -} + // We schedule the main-redirection for the next eventloop pass so that we + // can return from this function and let UIApplicationMain finish its job. + [NSTimer scheduledTimerWithTimeInterval:.01f target:self + selector:@selector(runUserMain) userInfo:nil repeats:NO]; -- (void)applicationDidBecomeActive:(UIApplication *)application -{ - Q_UNUSED(application) - // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + return YES; } -- (void)applicationWillTerminate:(UIApplication *)application +- (void)runUserMain { - Q_UNUSED(application) - // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + NSArray *arguments = [[NSProcessInfo processInfo] arguments]; + int argc = arguments.count; + char **argv = new char*[argc]; + for (int i = 0; i < argc; ++i) { + NSString *arg = [arguments objectAtIndex:i]; + argv[i] = reinterpret_cast<char *>(malloc([arg lengthOfBytesUsingEncoding:[NSString defaultCStringEncoding]])); + strcpy(argv[i], [arg cStringUsingEncoding:[NSString defaultCStringEncoding]]); + } + + qt_user_main(argc, argv); + delete[] argv; } + - (void)dealloc { [qiosViewController release]; @@ -93,4 +101,3 @@ @end - |