summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/ios/qiosglobal.mm
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@digia.com>2012-12-18 12:50:50 +0100
committerTor Arne Vestbø <tor.arne.vestbo@digia.com>2013-02-27 23:55:56 +0100
commitb960424195634c00673d499e4719ccb4f8704ad0 (patch)
tree92dbe82a5ce08f2392423258f0176d7d157587a2 /src/plugins/platforms/ios/qiosglobal.mm
parent5abe9aa435c316b845f4cf5f6a930eefd449f4e1 (diff)
iOS: add global function 'isQtApplication'
Several places in the code we need to check if the plugin is running as a cross-platform Qt application or inside a native app. So we refactor this function to qiosglobal so we can access it from everywhere. Change-Id: I78db0dcde71b7d281868ce304867c8f876caef2a Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
Diffstat (limited to 'src/plugins/platforms/ios/qiosglobal.mm')
-rw-r--r--src/plugins/platforms/ios/qiosglobal.mm13
1 files changed, 13 insertions, 0 deletions
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());