From 99b18fe22e8f7058d9a4d325b75c30ff109f9f71 Mon Sep 17 00:00:00 2001
From: Alessandro Portale <alessandro.portale@nokia.com>
Date: Fri, 30 Jul 2010 10:49:11 +0200
Subject: [PATCH] Application data deployment on the mac

Using the QMAKE_BUNDLE_DATA variable to copy the data into
the Resource directory in the application bundle.
---
 src/plugins/qmlprojectmanager/wizards/templates/app.pro  | 9 +++++++++
 .../wizards/templates/cpp/qmlapplicationview.cpp         | 6 ++++++
 2 files changed, 15 insertions(+)

diff --git a/src/plugins/qmlprojectmanager/wizards/templates/app.pro b/src/plugins/qmlprojectmanager/wizards/templates/app.pro
index 1faf7f87af4..08c9e729172 100644
--- a/src/plugins/qmlprojectmanager/wizards/templates/app.pro
+++ b/src/plugins/qmlprojectmanager/wizards/templates/app.pro
@@ -67,6 +67,15 @@ symbian {
     }
     target.path = /opt/bin
     INSTALLS += target
+} else:macx {
+    for(deploymentfolder, DEPLOYMENTFOLDERS) {
+        item = item$${deploymentfolder}
+        itemsources = $${item}.files
+        $$itemsources = $$eval($${deploymentfolder}.source)
+        itempath = $${item}.path
+        $$itempath = Resources/$$eval($${deploymentfolder}.target)
+        QMAKE_BUNDLE_DATA += $$item
+    }
 } else { #linux
     !isEqual(PWD,$$OUT_PWD) {
         copyCommand = @echo Copying application data...
diff --git a/src/plugins/qmlprojectmanager/wizards/templates/cpp/qmlapplicationview.cpp b/src/plugins/qmlprojectmanager/wizards/templates/cpp/qmlapplicationview.cpp
index cff33e560bb..d9a24eebfb3 100644
--- a/src/plugins/qmlprojectmanager/wizards/templates/cpp/qmlapplicationview.cpp
+++ b/src/plugins/qmlprojectmanager/wizards/templates/cpp/qmlapplicationview.cpp
@@ -1,5 +1,6 @@
 #include "qmlapplicationview.h"
 
+#include <QtCore/QCoreApplication>
 #include <QtCore/QDir>
 #include <QtCore/QFileInfo>
 #include <QtDeclarative/QDeclarativeComponent>
@@ -23,7 +24,12 @@ QmlApplicationView::QmlApplicationView(const QString &mainQmlFile, QWidget *pare
     : QDeclarativeView(parent)
     , m_d(new QmlApplicationViewPrivate)
 {
+#ifdef Q_OS_MAC
+    m_d->mainQmlFile = QCoreApplication::applicationDirPath()
+            + QLatin1String("/../../Resources/") + mainQmlFile;
+#else
     m_d->mainQmlFile = mainQmlFile;
+#endif
     setSource(QUrl(m_d->mainQmlFile));
     connect(engine(), SIGNAL(quit()), SLOT(close()));
     setResizeMode(QDeclarativeView::SizeRootObjectToView);
-- 
GitLab