Added QML for Harmattan
authorLuciano Montanaro <mikelima@cirulla.net>
Mon, 11 Jul 2011 14:16:41 +0000 (16:16 +0200)
committerLuciano Montanaro <mikelima@cirulla.net>
Mon, 11 Jul 2011 14:16:41 +0000 (16:16 +0200)
First dummy version of the Harmattan main view

application/resources/harmattan/qml/main.qml [new file with mode: 0644]
application/view.cpp [new file with mode: 0644]
application/view.h [new file with mode: 0644]

diff --git a/application/resources/harmattan/qml/main.qml b/application/resources/harmattan/qml/main.qml
new file mode 100644 (file)
index 0000000..94c0b94
--- /dev/null
@@ -0,0 +1,19 @@
+import QtQuick 1.1
+import com.nokia.meego 1.0
+
+
+ApplicationWindow {
+    showToolBar: true
+    showStatusBar: true
+    Page {
+        id: mainPage
+        CheckBox {
+            anchors.horizontalCenter: parent.horizontalCenter
+            anchors.verticalCenter: parent.verticalCenter
+        }
+    }
+    ToolBarLayout {
+        id: mainToolBar
+    }
+
+}
diff --git a/application/view.cpp b/application/view.cpp
new file mode 100644 (file)
index 0000000..7dd2611
--- /dev/null
@@ -0,0 +1,40 @@
+#include "view.h"
+#include <QDeclarativeView>
+#include <QDebug>
+#include <QDir>
+#include <QFile>
+
+// search Paths seem to be broken in Harmattan?
+
+static QString trueFilePath(QString path)
+{
+    qDebug() << "searching for" << path;
+    QString searchPathName = path.section(':', 0, 0);
+    qDebug() << "path is" << searchPathName;
+    QString fileName = path.section(':', 1, 1);
+    qDebug() << "filename is" << fileName;
+    QStringList dirs = QDir::searchPaths(searchPathName);
+    foreach(QString dir, dirs) {
+        qDebug() << "searching in" << dir;
+       QDir current(dir);
+       QString absoluteFileName = current.absoluteFilePath(fileName);
+        if (current.exists(fileName)) {
+            qDebug() << "found " << fileName << "in path" << absoluteFileName;
+            return absoluteFileName;
+        }
+    }
+    qDebug() << "file not found";
+    return QString();
+}
+
+View::View(QWidget *parent) :
+    QWidget(parent),
+    m_view(new QDeclarativeView(this))
+{
+    showFullScreen();
+
+    // 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"));
+    m_view->setSource(QUrl::fromLocalFile(trueFilePath("qml:main.qml")));
+}
diff --git a/application/view.h b/application/view.h
new file mode 100644 (file)
index 0000000..17870c6
--- /dev/null
@@ -0,0 +1,22 @@
+#ifndef QP_VIEW_H
+#define QP_VIEW_H
+
+#include <QWidget>
+
+class QDeclarativeView;
+
+class View : public QWidget
+{
+    Q_OBJECT
+public:
+    explicit View(QWidget *parent = 0);
+
+signals:
+
+public slots:
+
+private:
+    QDeclarativeView *m_view;
+};
+
+#endif // QP_VIEW_H