From: Luciano Montanaro Date: Mon, 11 Jul 2011 14:16:41 +0000 (+0200) Subject: Added QML for Harmattan X-Git-Tag: tags/0.4.81~130 X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;ds=sidebyside;h=9ff7147b262af0550ea60f28a9f888de9d91f36d;p=quandoparte Added QML for Harmattan First dummy version of the Harmattan main view --- diff --git a/application/resources/harmattan/qml/main.qml b/application/resources/harmattan/qml/main.qml new file mode 100644 index 0000000..94c0b94 --- /dev/null +++ b/application/resources/harmattan/qml/main.qml @@ -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 index 0000000..7dd2611 --- /dev/null +++ b/application/view.cpp @@ -0,0 +1,40 @@ +#include "view.h" +#include +#include +#include +#include + +// 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 index 0000000..17870c6 --- /dev/null +++ b/application/view.h @@ -0,0 +1,22 @@ +#ifndef QP_VIEW_H +#define QP_VIEW_H + +#include + +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