From 68f13d3f9a93859a9ff8b6750b97ab3e748ee0d5 Mon Sep 17 00:00:00 2001
From: Christian Kandeler <christian.kandeler@nokia.com>
Date: Wed, 8 Sep 2010 16:50:47 +0200
Subject: [PATCH] QML Wizard: Let executable find its QML files on Linux.

Reviewed-by: dt
---
 .../qmlapp/qmlapplicationviewer/qmlapplicationviewer.cpp | 9 +++++++++
 .../qmlapp/qmlapplicationviewer/qmlapplicationviewer.pri | 5 +++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/share/qtcreator/templates/qmlapp/qmlapplicationviewer/qmlapplicationviewer.cpp b/share/qtcreator/templates/qmlapp/qmlapplicationviewer/qmlapplicationviewer.cpp
index ab23b827f8e..7cd6ca1f6a7 100644
--- a/share/qtcreator/templates/qmlapp/qmlapplicationviewer/qmlapplicationviewer.cpp
+++ b/share/qtcreator/templates/qmlapp/qmlapplicationviewer/qmlapplicationviewer.cpp
@@ -23,10 +23,19 @@ class QmlApplicationViewerPrivate
 
 QString QmlApplicationViewerPrivate::adjustPath(const QString &path)
 {
+#ifdef Q_OS_UNIX
 #ifdef Q_OS_MAC
     if (!QDir::isAbsolutePath(path))
         return QCoreApplication::applicationDirPath()
                 + QLatin1String("/../Resources/") + path;
+#else
+    const QString pathInShareDir = QCoreApplication::applicationDirPath()
+        + QLatin1String("/../share/")
+        + QFileInfo(QCoreApplication::applicationFilePath()).fileName()
+        + QLatin1Char('/') + path;
+    if (QFileInfo(pathInShareDir).exists())
+        return pathInShareDir;
+#endif
 #endif
     return path;
 }
diff --git a/share/qtcreator/templates/qmlapp/qmlapplicationviewer/qmlapplicationviewer.pri b/share/qtcreator/templates/qmlapp/qmlapplicationviewer/qmlapplicationviewer.pri
index 42391327e15..da53f3bc94b 100644
--- a/share/qtcreator/templates/qmlapp/qmlapplicationviewer/qmlapplicationviewer.pri
+++ b/share/qtcreator/templates/qmlapp/qmlapplicationviewer/qmlapplicationviewer.pri
@@ -69,17 +69,18 @@ symbian {
             QMAKE_EXTRA_TARGETS += first copydeploymentfolders
         }
     }
+    installPrefix = /opt
     for(deploymentfolder, DEPLOYMENTFOLDERS) {
         item = item$${deploymentfolder}
         itemfiles = $${item}.files
         $$itemfiles = $$eval($${deploymentfolder}.source)
         itempath = $${item}.path
-        $$itempath = /opt/share/$$eval($${deploymentfolder}.target)
+        $$itempath = $${installPrefix}/share/$${TARGET}/$$eval($${deploymentfolder}.target)
         INSTALLS += $$item
     }
     icon.files = $${TARGET}.png
     icon.path = /usr/share/icons/hicolor/64x64
     desktopfile.files = $${TARGET}.desktop
-    target.path = /opt/bin
+    target.path = $${installPrefix}/bin
     INSTALLS += desktopfile icon target
 }
-- 
GitLab