diff options
Diffstat (limited to 'examples/helper/qmlapplicationviewer/qmlapplicationviewer.cpp')
-rw-r--r-- | examples/helper/qmlapplicationviewer/qmlapplicationviewer.cpp | 68 |
1 files changed, 26 insertions, 42 deletions
diff --git a/examples/helper/qmlapplicationviewer/qmlapplicationviewer.cpp b/examples/helper/qmlapplicationviewer/qmlapplicationviewer.cpp index 6a9a1fd5..05d481be 100644 --- a/examples/helper/qmlapplicationviewer/qmlapplicationviewer.cpp +++ b/examples/helper/qmlapplicationviewer/qmlapplicationviewer.cpp @@ -40,12 +40,12 @@ #include "qmlapplicationviewer.h" -#include <QtCore/QDir> -#include <QtCore/QFileInfo> -#include <QtDeclarative/QDeclarativeComponent> -#include <QtDeclarative/QDeclarativeEngine> -#include <QtDeclarative/QDeclarativeContext> -#include <QtWidgets/QApplication> +#include <QDir> +#include <QFileInfo> +#include <QApplication> +#include <QDeclarativeComponent> +#include <QDeclarativeEngine> +#include <QDeclarativeContext> #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN @@ -80,12 +80,9 @@ static QmlJsDebuggingEnabler enableDebuggingHelper; class QmlApplicationViewerPrivate { - QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} - QString mainQmlFile; - QDeclarativeView *view; friend class QmlApplicationViewer; - QString adjustPath(const QString &path); + static QString adjustPath(const QString &path); }; QString QmlApplicationViewerPrivate::adjustPath(const QString &path) @@ -94,7 +91,10 @@ QString QmlApplicationViewerPrivate::adjustPath(const QString &path) if (!QDir::isAbsolutePath(path)) return QString::fromLatin1("%1/../Resources/%2") .arg(QCoreApplication::applicationDirPath(), path); -#else +#elif defined(Q_OS_QNX) + if (!QDir::isAbsolutePath(path)) + return QString::fromLatin1("app/native/%1").arg(path); +#elif !defined(Q_OS_ANDROID) QString pathInInstallDir = QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); if (QFileInfo(pathInInstallDir).exists()) @@ -109,34 +109,18 @@ QString QmlApplicationViewerPrivate::adjustPath(const QString &path) QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) : QDeclarativeView(parent) - , d(new QmlApplicationViewerPrivate(this)) + , d(new QmlApplicationViewerPrivate()) { connect(engine(), SIGNAL(quit()), SLOT(close())); setResizeMode(QDeclarativeView::SizeRootObjectToView); - // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in -#if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 -#if !defined(NO_JSDEBUGGER) - new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); -#endif -#if !defined(NO_QMLOBSERVER) - new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); -#endif -#endif -} -QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) - : QDeclarativeView(parent) - , d(new QmlApplicationViewerPrivate(view)) -{ - connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); - view->setResizeMode(QDeclarativeView::SizeRootObjectToView); // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 #if !defined(NO_JSDEBUGGER) - new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); + new QmlJSDebugger::JSDebuggerAgent(engine()); #endif #if !defined(NO_QMLOBSERVER) - new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); + new QmlJSDebugger::QDeclarativeViewObserver(this, this); #endif #endif } @@ -148,38 +132,38 @@ QmlApplicationViewer::~QmlApplicationViewer() QmlApplicationViewer *QmlApplicationViewer::create() { -#ifdef HARMATTAN_BOOSTER - return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); -#else return new QmlApplicationViewer(); -#endif } void QmlApplicationViewer::setMainQmlFile(const QString &file) { - d->mainQmlFile = d->adjustPath(file); - d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); + d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); +#ifdef Q_OS_ANDROID + setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); +#else + setSource(QUrl::fromLocalFile(d->mainQmlFile)); +#endif } void QmlApplicationViewer::addImportPath(const QString &path) { - d->view->engine()->addImportPath(d->adjustPath(path)); + engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); } void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) { - // TODO: Needs a Qt5 implmentation + // TODO: Needs a Qt5 implementation Q_UNUSED(orientation) } void QmlApplicationViewer::showExpanded() { #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) - d->view->showFullScreen(); -#elif defined(Q_WS_MAEMO_5) - d->view->showMaximized(); + showFullScreen(); +#elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) + showMaximized(); #else - d->view->show(); + show(); #endif } |