Added (currently disabled) resources file
authorLuciano Montanaro <mikelima@cirulla.net>
Sun, 8 Jan 2012 14:48:25 +0000 (15:48 +0100)
committerLuciano Montanaro <mikelima@cirulla.net>
Sun, 8 Jan 2012 14:48:25 +0000 (15:48 +0100)
It is not working yet...
But it would make simulator debugging easier.

application/application.pro
application/main.cpp
application/quandoparte.qrc [new file with mode: 0644]
application/view.cpp

index a0c7beb..e8123c6 100644 (file)
@@ -5,6 +5,7 @@
 #-------------------------------------------------
 
 VERSION = 0.4.80
+USE_RESOURCES=0
 
 QT += webkit network
 CONFIG += qt webkit mobility
@@ -65,6 +66,10 @@ TEMPLATE = app
 VERSION_STRING = '\\"$${VERSION}\\"'
 DEFINES += QP_VERSION=\"$${VERSION_STRING}\"
 
+contains(USE_RESOURCES,1) {
+    DEFINES += USE_RESOURCES=1
+}
+
 !debug {
 #    DEFINES += QT_NO_DEBUG_OUTPUT
 }
@@ -151,7 +156,11 @@ unix {
 
     BINDIR=$$PREFIX/bin
     DESKTOPDIR=$$PREFIX/share/applications
-    DATADIR=$$PREFIX/share/apps/$${TARGET}
+    contains(USE_RESOURCES,1) {
+        DATADIR=":"
+    } else {
+        DATADIR=$$PREFIX/share/apps/$${TARGET}
+    }
     DEFINES += DATADIR=\\\"$${DATADIR}\\\" PKGDATADIR=\\\"$${PKGDATADIR}\\\"
 }
 
@@ -188,15 +197,22 @@ unix:!symbian {
     INSTALLS += icon48
     INSTALLS += icon64
     INSTALLS += iconscalable
-    INSTALLS += css
-    INSTALLS += i18n
-    INSTALLS += stations
+    !contains(USE_RESOURCES,1) {
+        INSTALLS += css
+        INSTALLS += i18n
+        INSTALLS += stations
+    }
 }
 
-harmattan {
-    qml.files = resources/harmattan/qml/*.qml resources/harmattan/qml/*.js
-    qml.path = $$DATADIR/qml
-    INSTALLS += qml
+!contains(USE_RESOURCES,1) {
+    harmattan {
+        qml.files = resources/harmattan/qml/*.qml resources/harmattan/qml/*.js
+        qml.path = $$DATADIR/qml
+        INSTALLS += qml
+    }
 }
 
-
+contains(USE_RESOURCES,1) {
+    RESOURCES += \
+        quandoparte.qrc
+}
index 7e2c5b7..bcb261d 100644 (file)
@@ -44,7 +44,11 @@ int main(int argc, char *argv[])
     QDir::setSearchPaths("css", QStringList(DATADIR "/css"));
     QDir::setSearchPaths("stations", QStringList(DATADIR "/stations"));
     QDir::setSearchPaths("i18n", QStringList(DATADIR "/i18n"));
+#ifdef USE_RESOURCES
+    QDir::setSearchPaths("qml", QStringList(DATADIR ""));
+#else
     QDir::setSearchPaths("qml", QStringList(DATADIR "/qml"));
+#endif
 
 #ifdef QT_KEYPAD_NAVIGATION
     QApplication::setNavigationMode(Qt::NavigationModeKeypadTabOrder);
diff --git a/application/quandoparte.qrc b/application/quandoparte.qrc
new file mode 100644 (file)
index 0000000..3af30a8
--- /dev/null
@@ -0,0 +1,21 @@
+<RCC>
+    <qresource prefix="/">
+        <file alias="uiconstants.js">resources/harmattan/qml/uiconstants.js</file>
+        <file alias="StationPage.qml">resources/harmattan/qml/StationPage.qml</file>
+        <file alias="StationListPage.qml">resources/harmattan/qml/StationListPage.qml</file>
+        <file alias="StationListPage.js">resources/harmattan/qml/StationListPage.js</file>
+        <file alias="SearchBar.qml">resources/harmattan/qml/SearchBar.qml</file>
+        <file alias="PageHeader.qml">resources/harmattan/qml/PageHeader.qml</file>
+        <file alias="main.qml">resources/harmattan/qml/main.qml</file>
+        <file alias="InfoBar.qml">resources/harmattan/qml/InfoBar.qml</file>
+        <file alias="DroppedShadow.qml">resources/harmattan/qml/DroppedShadow.qml</file>
+        <file alias="DelayIndicator.qml">resources/harmattan/qml/DelayIndicator.qml</file>
+        <file alias="AboutPage.qml">resources/harmattan/qml/AboutPage.qml</file>
+    </qresource>
+    <qresource prefix="/stations">
+        <file alias="stations.qpl">resources/stations/stations.qpl</file>
+    </qresource>
+    <qresource prefix="/i18n">
+        <file>resources/i18n/quandoparte_it.qm</file>
+    </qresource>
+</RCC>
index 8c92d75..3e2f8d2 100644 (file)
@@ -35,9 +35,12 @@ Boston, MA 02110-1301, USA.
 
 // search Paths seem to be broken in Harmattan?
 
-static QString trueFilePath(QString path)
+static QString trueFilePath(const QString &path)
 {
     qDebug() << "searching for" << path;
+#if USE_RESOURCES
+    return path;
+#else
     QString searchPathName = path.section(':', 0, 0);
     qDebug() << "path is" << searchPathName;
     QString fileName = path.section(':', 1, 1);
@@ -54,6 +57,7 @@ static QString trueFilePath(QString path)
     }
     qDebug() << "file not found";
     return QString();
+#endif
 }
 
 View::View(QWidget *parent) :
@@ -84,7 +88,8 @@ View::View(QWidget *parent) :
     // This does not seem ot work in harmattan. As a workaround, change dir to
     // the qml dir, then load the file.
     // m_view->setSource(QUrl::fromLocalFile("qml:main.qml"));
-    setSource(QUrl::fromLocalFile(trueFilePath("qml:main.qml")));
+    future.waitForFinished();
+    setSource(trueFilePath("qml:main.qml"));
 }
 
 View::~View()