From 92b9e13486f56cabf4a3c935f8c26e0ccb8f1cfb Mon Sep 17 00:00:00 2001 From: Tero Ahola Date: Tue, 18 Dec 2012 10:34:59 +0200 Subject: Forced update of qmlapplicationviewer templates --- .../qmlapplicationviewer/qmlapplicationviewer.cpp | 161 ++++----- .../qmlapplicationviewer/qmlapplicationviewer.h | 9 +- .../qmlapplicationviewer/qmlapplicationviewer.cpp | 161 ++++----- .../qmlapplicationviewer/qmlapplicationviewer.h | 9 +- .../qmlapplicationviewer/qmlapplicationviewer.cpp | 161 ++++----- .../qmlapplicationviewer/qmlapplicationviewer.h | 9 +- .../qmlapplicationviewer/qmlapplicationviewer.cpp | 377 ++++++++++----------- .../qmlapplicationviewer/qmlapplicationviewer.h | 93 +++-- .../qmlapplicationviewer/qmlapplicationviewer.cpp | 161 ++++----- .../qmlapplicationviewer/qmlapplicationviewer.h | 9 +- .../qmlapplicationviewer/qmlapplicationviewer.cpp | 108 +++--- .../qmlapplicationviewer/qmlapplicationviewer.h | 8 +- .../qmlapplicationviewer/qmlapplicationviewer.pri | 37 +- .../qmlapplicationviewer/qmlapplicationviewer.cpp | 161 ++++----- .../qmlapplicationviewer/qmlapplicationviewer.h | 9 +- .../qmlapplicationviewer/qmlapplicationviewer.cpp | 107 +++--- .../qmlapplicationviewer/qmlapplicationviewer.h | 6 +- .../qmlapplicationviewer/qmlapplicationviewer.pri | 37 +- .../qmlapplicationviewer/qmlapplicationviewer.cpp | 161 ++++----- .../qmlapplicationviewer/qmlapplicationviewer.h | 9 +- .../qmlapplicationviewer/qmlapplicationviewer.cpp | 161 ++++----- .../qmlapplicationviewer/qmlapplicationviewer.h | 9 +- .../qmlapplicationviewer/qmlapplicationviewer.cpp | 161 ++++----- .../qmlapplicationviewer/qmlapplicationviewer.h | 9 +- 24 files changed, 983 insertions(+), 1150 deletions(-) diff --git a/demos/qmlaxes/qmlapplicationviewer/qmlapplicationviewer.cpp b/demos/qmlaxes/qmlapplicationviewer/qmlapplicationviewer.cpp index efbf1e37..0f12265e 100644 --- a/demos/qmlaxes/qmlapplicationviewer/qmlapplicationviewer.cpp +++ b/demos/qmlaxes/qmlapplicationviewer/qmlapplicationviewer.cpp @@ -1,4 +1,4 @@ -// checksum 0x78c version 0x60010 +// checksum 0xbd34 version 0x80016 /* This file was generated by the Qt Quick Application wizard of Qt Creator. QmlApplicationViewer is a convenience class containing mobile device specific @@ -10,12 +10,12 @@ #include "qmlapplicationviewer.h" -#include -#include -#include -#include -#include +#include +#include #include +#include +#include +#include #include // MEEGO_EDITION_HARMATTAN @@ -50,63 +50,47 @@ 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) { -#ifdef Q_OS_UNIX #ifdef Q_OS_MAC if (!QDir::isAbsolutePath(path)) - return QCoreApplication::applicationDirPath() - + QLatin1String("/../Resources/") + path; -#else - QString pathInInstallDir; - const QString applicationDirPath = QCoreApplication::applicationDirPath(); - pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); - + return QString::fromLatin1("%1/../Resources/%2") + .arg(QCoreApplication::applicationDirPath(), path); +#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()) + return pathInInstallDir; + pathInInstallDir = + QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); if (QFileInfo(pathInInstallDir).exists()) return pathInInstallDir; -#endif #endif return 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 } @@ -118,75 +102,68 @@ 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) -//{ -//#if defined(Q_OS_SYMBIAN) -// // If the version of Qt on the device is < 4.7.2, that attribute won't work -// if (orientation != ScreenOrientationAuto) { -// const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); -// if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { -// qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); -// return; -// } -// } -//#endif // Q_OS_SYMBIAN - -// Qt::WidgetAttribute attribute; -// switch (orientation) { -//#if QT_VERSION < 0x040702 -// // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes -// case ScreenOrientationLockPortrait: -// attribute = static_cast(128); -// break; -// case ScreenOrientationLockLandscape: -// attribute = static_cast(129); -// break; -// default: -// case ScreenOrientationAuto: -// attribute = static_cast(130); -// break; -//#else // QT_VERSION < 0x040702 -// case ScreenOrientationLockPortrait: -// attribute = Qt::WA_LockPortraitOrientation; -// break; -// case ScreenOrientationLockLandscape: -// attribute = Qt::WA_LockLandscapeOrientation; -// break; -// default: -// case ScreenOrientationAuto: -// attribute = Qt::WA_AutoOrientation; -// break; -//#endif // QT_VERSION < 0x040702 -// }; -// setAttribute(attribute, true); -//} +void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) +{ +#if QT_VERSION < 0x050000 + Qt::WidgetAttribute attribute; + switch (orientation) { +#if QT_VERSION < 0x040702 + // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes + case ScreenOrientationLockPortrait: + attribute = static_cast(128); + break; + case ScreenOrientationLockLandscape: + attribute = static_cast(129); + break; + default: + case ScreenOrientationAuto: + attribute = static_cast(130); + break; +#else // QT_VERSION < 0x040702 + case ScreenOrientationLockPortrait: + attribute = Qt::WA_LockPortraitOrientation; + break; + case ScreenOrientationLockLandscape: + attribute = Qt::WA_LockLandscapeOrientation; + break; + default: + case ScreenOrientationAuto: + attribute = Qt::WA_AutoOrientation; + break; +#endif // QT_VERSION < 0x040702 + }; + setAttribute(attribute, true); +#else // QT_VERSION < 0x050000 + Q_UNUSED(orientation) +#endif // QT_VERSION < 0x050000 +} void QmlApplicationViewer::showExpanded() { -#if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) - d->view->showFullScreen(); -#elif defined(Q_WS_MAEMO_5) - d->view->showMaximized(); +#if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) + showFullScreen(); +#elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) + showMaximized(); #else - d->view->show(); + show(); #endif } diff --git a/demos/qmlaxes/qmlapplicationviewer/qmlapplicationviewer.h b/demos/qmlaxes/qmlapplicationviewer/qmlapplicationviewer.h index 9d0fea29..fba2d52a 100644 --- a/demos/qmlaxes/qmlapplicationviewer/qmlapplicationviewer.h +++ b/demos/qmlaxes/qmlapplicationviewer/qmlapplicationviewer.h @@ -1,4 +1,4 @@ -// checksum 0x82ed version 0x60010 +// checksum 0xc67a version 0x80016 /* This file was generated by the Qt Quick Application wizard of Qt Creator. QmlApplicationViewer is a convenience class containing mobile device specific @@ -11,7 +11,7 @@ #ifndef QMLAPPLICATIONVIEWER_H #define QMLAPPLICATIONVIEWER_H -#include +#include class QmlApplicationViewer : public QDeclarativeView { @@ -32,13 +32,12 @@ public: void setMainQmlFile(const QString &file); void addImportPath(const QString &path); - // Note that this will only have an effect on Symbian and Fremantle. - // void setOrientation(ScreenOrientation orientation); + // Note that this will only have an effect on Fremantle. + void setOrientation(ScreenOrientation orientation); void showExpanded(); private: - explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); class QmlApplicationViewerPrivate *d; }; diff --git a/demos/qmlchart/qmlapplicationviewer/qmlapplicationviewer.cpp b/demos/qmlchart/qmlapplicationviewer/qmlapplicationviewer.cpp index efbf1e37..0f12265e 100644 --- a/demos/qmlchart/qmlapplicationviewer/qmlapplicationviewer.cpp +++ b/demos/qmlchart/qmlapplicationviewer/qmlapplicationviewer.cpp @@ -1,4 +1,4 @@ -// checksum 0x78c version 0x60010 +// checksum 0xbd34 version 0x80016 /* This file was generated by the Qt Quick Application wizard of Qt Creator. QmlApplicationViewer is a convenience class containing mobile device specific @@ -10,12 +10,12 @@ #include "qmlapplicationviewer.h" -#include -#include -#include -#include -#include +#include +#include #include +#include +#include +#include #include // MEEGO_EDITION_HARMATTAN @@ -50,63 +50,47 @@ 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) { -#ifdef Q_OS_UNIX #ifdef Q_OS_MAC if (!QDir::isAbsolutePath(path)) - return QCoreApplication::applicationDirPath() - + QLatin1String("/../Resources/") + path; -#else - QString pathInInstallDir; - const QString applicationDirPath = QCoreApplication::applicationDirPath(); - pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); - + return QString::fromLatin1("%1/../Resources/%2") + .arg(QCoreApplication::applicationDirPath(), path); +#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()) + return pathInInstallDir; + pathInInstallDir = + QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); if (QFileInfo(pathInInstallDir).exists()) return pathInInstallDir; -#endif #endif return 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 } @@ -118,75 +102,68 @@ 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) -//{ -//#if defined(Q_OS_SYMBIAN) -// // If the version of Qt on the device is < 4.7.2, that attribute won't work -// if (orientation != ScreenOrientationAuto) { -// const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); -// if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { -// qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); -// return; -// } -// } -//#endif // Q_OS_SYMBIAN - -// Qt::WidgetAttribute attribute; -// switch (orientation) { -//#if QT_VERSION < 0x040702 -// // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes -// case ScreenOrientationLockPortrait: -// attribute = static_cast(128); -// break; -// case ScreenOrientationLockLandscape: -// attribute = static_cast(129); -// break; -// default: -// case ScreenOrientationAuto: -// attribute = static_cast(130); -// break; -//#else // QT_VERSION < 0x040702 -// case ScreenOrientationLockPortrait: -// attribute = Qt::WA_LockPortraitOrientation; -// break; -// case ScreenOrientationLockLandscape: -// attribute = Qt::WA_LockLandscapeOrientation; -// break; -// default: -// case ScreenOrientationAuto: -// attribute = Qt::WA_AutoOrientation; -// break; -//#endif // QT_VERSION < 0x040702 -// }; -// setAttribute(attribute, true); -//} +void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) +{ +#if QT_VERSION < 0x050000 + Qt::WidgetAttribute attribute; + switch (orientation) { +#if QT_VERSION < 0x040702 + // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes + case ScreenOrientationLockPortrait: + attribute = static_cast(128); + break; + case ScreenOrientationLockLandscape: + attribute = static_cast(129); + break; + default: + case ScreenOrientationAuto: + attribute = static_cast(130); + break; +#else // QT_VERSION < 0x040702 + case ScreenOrientationLockPortrait: + attribute = Qt::WA_LockPortraitOrientation; + break; + case ScreenOrientationLockLandscape: + attribute = Qt::WA_LockLandscapeOrientation; + break; + default: + case ScreenOrientationAuto: + attribute = Qt::WA_AutoOrientation; + break; +#endif // QT_VERSION < 0x040702 + }; + setAttribute(attribute, true); +#else // QT_VERSION < 0x050000 + Q_UNUSED(orientation) +#endif // QT_VERSION < 0x050000 +} void QmlApplicationViewer::showExpanded() { -#if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) - d->view->showFullScreen(); -#elif defined(Q_WS_MAEMO_5) - d->view->showMaximized(); +#if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) + showFullScreen(); +#elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) + showMaximized(); #else - d->view->show(); + show(); #endif } diff --git a/demos/qmlchart/qmlapplicationviewer/qmlapplicationviewer.h b/demos/qmlchart/qmlapplicationviewer/qmlapplicationviewer.h index 9d0fea29..fba2d52a 100644 --- a/demos/qmlchart/qmlapplicationviewer/qmlapplicationviewer.h +++ b/demos/qmlchart/qmlapplicationviewer/qmlapplicationviewer.h @@ -1,4 +1,4 @@ -// checksum 0x82ed version 0x60010 +// checksum 0xc67a version 0x80016 /* This file was generated by the Qt Quick Application wizard of Qt Creator. QmlApplicationViewer is a convenience class containing mobile device specific @@ -11,7 +11,7 @@ #ifndef QMLAPPLICATIONVIEWER_H #define QMLAPPLICATIONVIEWER_H -#include +#include class QmlApplicationViewer : public QDeclarativeView { @@ -32,13 +32,12 @@ public: void setMainQmlFile(const QString &file); void addImportPath(const QString &path); - // Note that this will only have an effect on Symbian and Fremantle. - // void setOrientation(ScreenOrientation orientation); + // Note that this will only have an effect on Fremantle. + void setOrientation(ScreenOrientation orientation); void showExpanded(); private: - explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); class QmlApplicationViewerPrivate *d; }; diff --git a/demos/qmlcustomizations/qmlapplicationviewer/qmlapplicationviewer.cpp b/demos/qmlcustomizations/qmlapplicationviewer/qmlapplicationviewer.cpp index efbf1e37..0f12265e 100644 --- a/demos/qmlcustomizations/qmlapplicationviewer/qmlapplicationviewer.cpp +++ b/demos/qmlcustomizations/qmlapplicationviewer/qmlapplicationviewer.cpp @@ -1,4 +1,4 @@ -// checksum 0x78c version 0x60010 +// checksum 0xbd34 version 0x80016 /* This file was generated by the Qt Quick Application wizard of Qt Creator. QmlApplicationViewer is a convenience class containing mobile device specific @@ -10,12 +10,12 @@ #include "qmlapplicationviewer.h" -#include -#include -#include -#include -#include +#include +#include #include +#include +#include +#include #include // MEEGO_EDITION_HARMATTAN @@ -50,63 +50,47 @@ 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) { -#ifdef Q_OS_UNIX #ifdef Q_OS_MAC if (!QDir::isAbsolutePath(path)) - return QCoreApplication::applicationDirPath() - + QLatin1String("/../Resources/") + path; -#else - QString pathInInstallDir; - const QString applicationDirPath = QCoreApplication::applicationDirPath(); - pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); - + return QString::fromLatin1("%1/../Resources/%2") + .arg(QCoreApplication::applicationDirPath(), path); +#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()) + return pathInInstallDir; + pathInInstallDir = + QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); if (QFileInfo(pathInInstallDir).exists()) return pathInInstallDir; -#endif #endif return 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 } @@ -118,75 +102,68 @@ 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) -//{ -//#if defined(Q_OS_SYMBIAN) -// // If the version of Qt on the device is < 4.7.2, that attribute won't work -// if (orientation != ScreenOrientationAuto) { -// const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); -// if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { -// qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); -// return; -// } -// } -//#endif // Q_OS_SYMBIAN - -// Qt::WidgetAttribute attribute; -// switch (orientation) { -//#if QT_VERSION < 0x040702 -// // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes -// case ScreenOrientationLockPortrait: -// attribute = static_cast(128); -// break; -// case ScreenOrientationLockLandscape: -// attribute = static_cast(129); -// break; -// default: -// case ScreenOrientationAuto: -// attribute = static_cast(130); -// break; -//#else // QT_VERSION < 0x040702 -// case ScreenOrientationLockPortrait: -// attribute = Qt::WA_LockPortraitOrientation; -// break; -// case ScreenOrientationLockLandscape: -// attribute = Qt::WA_LockLandscapeOrientation; -// break; -// default: -// case ScreenOrientationAuto: -// attribute = Qt::WA_AutoOrientation; -// break; -//#endif // QT_VERSION < 0x040702 -// }; -// setAttribute(attribute, true); -//} +void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) +{ +#if QT_VERSION < 0x050000 + Qt::WidgetAttribute attribute; + switch (orientation) { +#if QT_VERSION < 0x040702 + // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes + case ScreenOrientationLockPortrait: + attribute = static_cast(128); + break; + case ScreenOrientationLockLandscape: + attribute = static_cast(129); + break; + default: + case ScreenOrientationAuto: + attribute = static_cast(130); + break; +#else // QT_VERSION < 0x040702 + case ScreenOrientationLockPortrait: + attribute = Qt::WA_LockPortraitOrientation; + break; + case ScreenOrientationLockLandscape: + attribute = Qt::WA_LockLandscapeOrientation; + break; + default: + case ScreenOrientationAuto: + attribute = Qt::WA_AutoOrientation; + break; +#endif // QT_VERSION < 0x040702 + }; + setAttribute(attribute, true); +#else // QT_VERSION < 0x050000 + Q_UNUSED(orientation) +#endif // QT_VERSION < 0x050000 +} void QmlApplicationViewer::showExpanded() { -#if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) - d->view->showFullScreen(); -#elif defined(Q_WS_MAEMO_5) - d->view->showMaximized(); +#if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) + showFullScreen(); +#elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) + showMaximized(); #else - d->view->show(); + show(); #endif } diff --git a/demos/qmlcustomizations/qmlapplicationviewer/qmlapplicationviewer.h b/demos/qmlcustomizations/qmlapplicationviewer/qmlapplicationviewer.h index 9d0fea29..fba2d52a 100644 --- a/demos/qmlcustomizations/qmlapplicationviewer/qmlapplicationviewer.h +++ b/demos/qmlcustomizations/qmlapplicationviewer/qmlapplicationviewer.h @@ -1,4 +1,4 @@ -// checksum 0x82ed version 0x60010 +// checksum 0xc67a version 0x80016 /* This file was generated by the Qt Quick Application wizard of Qt Creator. QmlApplicationViewer is a convenience class containing mobile device specific @@ -11,7 +11,7 @@ #ifndef QMLAPPLICATIONVIEWER_H #define QMLAPPLICATIONVIEWER_H -#include +#include class QmlApplicationViewer : public QDeclarativeView { @@ -32,13 +32,12 @@ public: void setMainQmlFile(const QString &file); void addImportPath(const QString &path); - // Note that this will only have an effect on Symbian and Fremantle. - // void setOrientation(ScreenOrientation orientation); + // Note that this will only have an effect on Fremantle. + void setOrientation(ScreenOrientation orientation); void showExpanded(); private: - explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); class QmlApplicationViewerPrivate *d; }; diff --git a/demos/qmlcustomlegend/qmlapplicationviewer/qmlapplicationviewer.cpp b/demos/qmlcustomlegend/qmlapplicationviewer/qmlapplicationviewer.cpp index 2e99f533..0f12265e 100644 --- a/demos/qmlcustomlegend/qmlapplicationviewer/qmlapplicationviewer.cpp +++ b/demos/qmlcustomlegend/qmlapplicationviewer/qmlapplicationviewer.cpp @@ -1,200 +1,177 @@ -// checksum 0x78c version 0x60010 -/* - This file was generated by the Qt Quick Application wizard of Qt Creator. - QmlApplicationViewer is a convenience class containing mobile device specific - code such as screen orientation handling. Also QML paths and debugging are - handled here. - It is recommended not to modify this file, since newer versions of Qt Creator - may offer an updated version of it. -*/ - -#include "qmlapplicationviewer.h" - -#include -#include -#include -#include -#include -#include - -#include // MEEGO_EDITION_HARMATTAN - -#ifdef HARMATTAN_BOOSTER -#include -#endif - -#if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 - -#include - -#if !defined(NO_JSDEBUGGER) -#include -#endif -#if !defined(NO_QMLOBSERVER) -#include -#endif - -// Enable debugging before any QDeclarativeEngine is created -struct QmlJsDebuggingEnabler -{ - QmlJsDebuggingEnabler() - { - QDeclarativeDebugHelper::enableDebugging(); - } -}; - -// Execute code in constructor before first QDeclarativeEngine is instantiated -static QmlJsDebuggingEnabler enableDebuggingHelper; - -#endif // QMLJSDEBUGGER - -class QmlApplicationViewerPrivate -{ - QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} - - QString mainQmlFile; - QDeclarativeView *view; - friend class QmlApplicationViewer; - QString adjustPath(const QString &path); -}; - -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 - QString pathInInstallDir; - const QString applicationDirPath = QCoreApplication::applicationDirPath(); - pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); - - if (QFileInfo(pathInInstallDir).exists()) - return pathInInstallDir; -#endif -#endif - return path; -} - -QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) - : QDeclarativeView(parent) - , d(new QmlApplicationViewerPrivate(this)) -{ - 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()); -#endif -#if !defined(NO_QMLOBSERVER) - new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); -#endif -#endif -} - -QmlApplicationViewer::~QmlApplicationViewer() -{ - delete d; -} - -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)); -} - -void QmlApplicationViewer::addImportPath(const QString &path) -{ - d->view->engine()->addImportPath(d->adjustPath(path)); -} - -//void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) -//{ -//#if defined(Q_OS_SYMBIAN) -// // If the version of Qt on the device is < 4.7.2, that attribute won't work -// if (orientation != ScreenOrientationAuto) { -// const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); -// if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { -// qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); -// return; -// } -// } -//#endif // Q_OS_SYMBIAN - -// Qt::WidgetAttribute attribute; -// switch (orientation) { -//#if QT_VERSION < 0x040702 -// // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes -// case ScreenOrientationLockPortrait: -// attribute = static_cast(128); -// break; -// case ScreenOrientationLockLandscape: -// attribute = static_cast(129); -// break; -// default: -// case ScreenOrientationAuto: -// attribute = static_cast(130); -// break; -//#else // QT_VERSION < 0x040702 -// case ScreenOrientationLockPortrait: -// attribute = Qt::WA_LockPortraitOrientation; -// break; -// case ScreenOrientationLockLandscape: -// attribute = Qt::WA_LockLandscapeOrientation; -// break; -// default: -// case ScreenOrientationAuto: -// attribute = Qt::WA_AutoOrientation; -// break; -//#endif // QT_VERSION < 0x040702 -// }; -// setAttribute(attribute, true); -//} - -void QmlApplicationViewer::showExpanded() -{ -#if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) - d->view->showFullScreen(); -#elif defined(Q_WS_MAEMO_5) - d->view->showMaximized(); -#else - d->view->show(); -#endif -} - -QApplication *createApplication(int &argc, char **argv) -{ -#ifdef HARMATTAN_BOOSTER - return MDeclarativeCache::qApplication(argc, argv); -#else - return new QApplication(argc, argv); -#endif -} +// checksum 0xbd34 version 0x80016 +/* + This file was generated by the Qt Quick Application wizard of Qt Creator. + QmlApplicationViewer is a convenience class containing mobile device specific + code such as screen orientation handling. Also QML paths and debugging are + handled here. + It is recommended not to modify this file, since newer versions of Qt Creator + may offer an updated version of it. +*/ + +#include "qmlapplicationviewer.h" + +#include +#include +#include +#include +#include +#include + +#include // MEEGO_EDITION_HARMATTAN + +#ifdef HARMATTAN_BOOSTER +#include +#endif + +#if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 + +#include + +#if !defined(NO_JSDEBUGGER) +#include +#endif +#if !defined(NO_QMLOBSERVER) +#include +#endif + +// Enable debugging before any QDeclarativeEngine is created +struct QmlJsDebuggingEnabler +{ + QmlJsDebuggingEnabler() + { + QDeclarativeDebugHelper::enableDebugging(); + } +}; + +// Execute code in constructor before first QDeclarativeEngine is instantiated +static QmlJsDebuggingEnabler enableDebuggingHelper; + +#endif // QMLJSDEBUGGER + +class QmlApplicationViewerPrivate +{ + QString mainQmlFile; + friend class QmlApplicationViewer; + static QString adjustPath(const QString &path); +}; + +QString QmlApplicationViewerPrivate::adjustPath(const QString &path) +{ +#ifdef Q_OS_MAC + if (!QDir::isAbsolutePath(path)) + return QString::fromLatin1("%1/../Resources/%2") + .arg(QCoreApplication::applicationDirPath(), path); +#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()) + return pathInInstallDir; + pathInInstallDir = + QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); + if (QFileInfo(pathInInstallDir).exists()) + return pathInInstallDir; +#endif + return path; +} + +QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) + : QDeclarativeView(parent) + , 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(engine()); +#endif +#if !defined(NO_QMLOBSERVER) + new QmlJSDebugger::QDeclarativeViewObserver(this, this); +#endif +#endif +} + +QmlApplicationViewer::~QmlApplicationViewer() +{ + delete d; +} + +QmlApplicationViewer *QmlApplicationViewer::create() +{ + return new QmlApplicationViewer(); +} + +void QmlApplicationViewer::setMainQmlFile(const QString &file) +{ + 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) +{ + engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); +} + +void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) +{ +#if QT_VERSION < 0x050000 + Qt::WidgetAttribute attribute; + switch (orientation) { +#if QT_VERSION < 0x040702 + // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes + case ScreenOrientationLockPortrait: + attribute = static_cast(128); + break; + case ScreenOrientationLockLandscape: + attribute = static_cast(129); + break; + default: + case ScreenOrientationAuto: + attribute = static_cast(130); + break; +#else // QT_VERSION < 0x040702 + case ScreenOrientationLockPortrait: + attribute = Qt::WA_LockPortraitOrientation; + break; + case ScreenOrientationLockLandscape: + attribute = Qt::WA_LockLandscapeOrientation; + break; + default: + case ScreenOrientationAuto: + attribute = Qt::WA_AutoOrientation; + break; +#endif // QT_VERSION < 0x040702 + }; + setAttribute(attribute, true); +#else // QT_VERSION < 0x050000 + Q_UNUSED(orientation) +#endif // QT_VERSION < 0x050000 +} + +void QmlApplicationViewer::showExpanded() +{ +#if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) + showFullScreen(); +#elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) + showMaximized(); +#else + show(); +#endif +} + +QApplication *createApplication(int &argc, char **argv) +{ +#ifdef HARMATTAN_BOOSTER + return MDeclarativeCache::qApplication(argc, argv); +#else + return new QApplication(argc, argv); +#endif +} diff --git a/demos/qmlcustomlegend/qmlapplicationviewer/qmlapplicationviewer.h b/demos/qmlcustomlegend/qmlapplicationviewer/qmlapplicationviewer.h index 9d7d7766..fba2d52a 100644 --- a/demos/qmlcustomlegend/qmlapplicationviewer/qmlapplicationviewer.h +++ b/demos/qmlcustomlegend/qmlapplicationviewer/qmlapplicationviewer.h @@ -1,47 +1,46 @@ -// checksum 0x82ed version 0x60010 -/* - This file was generated by the Qt Quick Application wizard of Qt Creator. - QmlApplicationViewer is a convenience class containing mobile device specific - code such as screen orientation handling. Also QML paths and debugging are - handled here. - It is recommended not to modify this file, since newer versions of Qt Creator - may offer an updated version of it. -*/ - -#ifndef QMLAPPLICATIONVIEWER_H -#define QMLAPPLICATIONVIEWER_H - -#include - -class QmlApplicationViewer : public QDeclarativeView -{ - Q_OBJECT - -public: - enum ScreenOrientation { - ScreenOrientationLockPortrait, - ScreenOrientationLockLandscape, - ScreenOrientationAuto - }; - - explicit QmlApplicationViewer(QWidget *parent = 0); - virtual ~QmlApplicationViewer(); - - static QmlApplicationViewer *create(); - - void setMainQmlFile(const QString &file); - void addImportPath(const QString &path); - - // Note that this will only have an effect on Symbian and Fremantle. - // void setOrientation(ScreenOrientation orientation); - - void showExpanded(); - -private: - explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); - class QmlApplicationViewerPrivate *d; -}; - -QApplication *createApplication(int &argc, char **argv); - -#endif // QMLAPPLICATIONVIEWER_H +// checksum 0xc67a version 0x80016 +/* + This file was generated by the Qt Quick Application wizard of Qt Creator. + QmlApplicationViewer is a convenience class containing mobile device specific + code such as screen orientation handling. Also QML paths and debugging are + handled here. + It is recommended not to modify this file, since newer versions of Qt Creator + may offer an updated version of it. +*/ + +#ifndef QMLAPPLICATIONVIEWER_H +#define QMLAPPLICATIONVIEWER_H + +#include + +class QmlApplicationViewer : public QDeclarativeView +{ + Q_OBJECT + +public: + enum ScreenOrientation { + ScreenOrientationLockPortrait, + ScreenOrientationLockLandscape, + ScreenOrientationAuto + }; + + explicit QmlApplicationViewer(QWidget *parent = 0); + virtual ~QmlApplicationViewer(); + + static QmlApplicationViewer *create(); + + void setMainQmlFile(const QString &file); + void addImportPath(const QString &path); + + // Note that this will only have an effect on Fremantle. + void setOrientation(ScreenOrientation orientation); + + void showExpanded(); + +private: + class QmlApplicationViewerPrivate *d; +}; + +QApplication *createApplication(int &argc, char **argv); + +#endif // QMLAPPLICATIONVIEWER_H diff --git a/demos/qmlcustommodel/qmlapplicationviewer/qmlapplicationviewer.cpp b/demos/qmlcustommodel/qmlapplicationviewer/qmlapplicationviewer.cpp index efbf1e37..0f12265e 100644 --- a/demos/qmlcustommodel/qmlapplicationviewer/qmlapplicationviewer.cpp +++ b/demos/qmlcustommodel/qmlapplicationviewer/qmlapplicationviewer.cpp @@ -1,4 +1,4 @@ -// checksum 0x78c version 0x60010 +// checksum 0xbd34 version 0x80016 /* This file was generated by the Qt Quick Application wizard of Qt Creator. QmlApplicationViewer is a convenience class containing mobile device specific @@ -10,12 +10,12 @@ #include "qmlapplicationviewer.h" -#include -#include -#include -#include -#include +#include +#include #include +#include +#include +#include #include // MEEGO_EDITION_HARMATTAN @@ -50,63 +50,47 @@ 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) { -#ifdef Q_OS_UNIX #ifdef Q_OS_MAC if (!QDir::isAbsolutePath(path)) - return QCoreApplication::applicationDirPath() - + QLatin1String("/../Resources/") + path; -#else - QString pathInInstallDir; - const QString applicationDirPath = QCoreApplication::applicationDirPath(); - pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); - + return QString::fromLatin1("%1/../Resources/%2") + .arg(QCoreApplication::applicationDirPath(), path); +#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()) + return pathInInstallDir; + pathInInstallDir = + QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); if (QFileInfo(pathInInstallDir).exists()) return pathInInstallDir; -#endif #endif return 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 } @@ -118,75 +102,68 @@ 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) -//{ -//#if defined(Q_OS_SYMBIAN) -// // If the version of Qt on the device is < 4.7.2, that attribute won't work -// if (orientation != ScreenOrientationAuto) { -// const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); -// if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { -// qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); -// return; -// } -// } -//#endif // Q_OS_SYMBIAN - -// Qt::WidgetAttribute attribute; -// switch (orientation) { -//#if QT_VERSION < 0x040702 -// // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes -// case ScreenOrientationLockPortrait: -// attribute = static_cast(128); -// break; -// case ScreenOrientationLockLandscape: -// attribute = static_cast(129); -// break; -// default: -// case ScreenOrientationAuto: -// attribute = static_cast(130); -// break; -//#else // QT_VERSION < 0x040702 -// case ScreenOrientationLockPortrait: -// attribute = Qt::WA_LockPortraitOrientation; -// break; -// case ScreenOrientationLockLandscape: -// attribute = Qt::WA_LockLandscapeOrientation; -// break; -// default: -// case ScreenOrientationAuto: -// attribute = Qt::WA_AutoOrientation; -// break; -//#endif // QT_VERSION < 0x040702 -// }; -// setAttribute(attribute, true); -//} +void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) +{ +#if QT_VERSION < 0x050000 + Qt::WidgetAttribute attribute; + switch (orientation) { +#if QT_VERSION < 0x040702 + // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes + case ScreenOrientationLockPortrait: + attribute = static_cast(128); + break; + case ScreenOrientationLockLandscape: + attribute = static_cast(129); + break; + default: + case ScreenOrientationAuto: + attribute = static_cast(130); + break; +#else // QT_VERSION < 0x040702 + case ScreenOrientationLockPortrait: + attribute = Qt::WA_LockPortraitOrientation; + break; + case ScreenOrientationLockLandscape: + attribute = Qt::WA_LockLandscapeOrientation; + break; + default: + case ScreenOrientationAuto: + attribute = Qt::WA_AutoOrientation; + break; +#endif // QT_VERSION < 0x040702 + }; + setAttribute(attribute, true); +#else // QT_VERSION < 0x050000 + Q_UNUSED(orientation) +#endif // QT_VERSION < 0x050000 +} void QmlApplicationViewer::showExpanded() { -#if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) - d->view->showFullScreen(); -#elif defined(Q_WS_MAEMO_5) - d->view->showMaximized(); +#if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) + showFullScreen(); +#elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) + showMaximized(); #else - d->view->show(); + show(); #endif } diff --git a/demos/qmlcustommodel/qmlapplicationviewer/qmlapplicationviewer.h b/demos/qmlcustommodel/qmlapplicationviewer/qmlapplicationviewer.h index 9d0fea29..fba2d52a 100644 --- a/demos/qmlcustommodel/qmlapplicationviewer/qmlapplicationviewer.h +++ b/demos/qmlcustommodel/qmlapplicationviewer/qmlapplicationviewer.h @@ -1,4 +1,4 @@ -// checksum 0x82ed version 0x60010 +// checksum 0xc67a version 0x80016 /* This file was generated by the Qt Quick Application wizard of Qt Creator. QmlApplicationViewer is a convenience class containing mobile device specific @@ -11,7 +11,7 @@ #ifndef QMLAPPLICATIONVIEWER_H #define QMLAPPLICATIONVIEWER_H -#include +#include class QmlApplicationViewer : public QDeclarativeView { @@ -32,13 +32,12 @@ public: void setMainQmlFile(const QString &file); void addImportPath(const QString &path); - // Note that this will only have an effect on Symbian and Fremantle. - // void setOrientation(ScreenOrientation orientation); + // Note that this will only have an effect on Fremantle. + void setOrientation(ScreenOrientation orientation); void showExpanded(); private: - explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); class QmlApplicationViewerPrivate *d; }; diff --git a/demos/qmlf1legends/qmlapplicationviewer/qmlapplicationviewer.cpp b/demos/qmlf1legends/qmlapplicationviewer/qmlapplicationviewer.cpp index f204eaf4..0f12265e 100644 --- a/demos/qmlf1legends/qmlapplicationviewer/qmlapplicationviewer.cpp +++ b/demos/qmlf1legends/qmlapplicationviewer/qmlapplicationviewer.cpp @@ -1,4 +1,4 @@ -// checksum 0x3fbf version 0x70013 +// checksum 0xbd34 version 0x80016 /* This file was generated by the Qt Quick Application wizard of Qt Creator. QmlApplicationViewer is a convenience class containing mobile device specific @@ -13,9 +13,10 @@ #include #include #include -#include -#include -#include +#include +#include +#include + #include // MEEGO_EDITION_HARMATTAN #ifdef HARMATTAN_BOOSTER @@ -56,17 +57,22 @@ class QmlApplicationViewerPrivate QString QmlApplicationViewerPrivate::adjustPath(const QString &path) { -#ifdef Q_OS_UNIX #ifdef Q_OS_MAC if (!QDir::isAbsolutePath(path)) return QString::fromLatin1("%1/../Resources/%2") .arg(QCoreApplication::applicationDirPath(), path); -#else - const QString pathInInstallDir = +#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()) return pathInInstallDir; -#endif + pathInInstallDir = + QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); + if (QFileInfo(pathInInstallDir).exists()) + return pathInInstallDir; #endif return path; } @@ -77,6 +83,7 @@ QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) { 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) @@ -101,7 +108,11 @@ QmlApplicationViewer *QmlApplicationViewer::create() void QmlApplicationViewer::setMainQmlFile(const QString &file) { 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) @@ -109,54 +120,47 @@ void QmlApplicationViewer::addImportPath(const QString &path) engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); } -//void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) -//{ -//#if defined(Q_OS_SYMBIAN) -// // If the version of Qt on the device is < 4.7.2, that attribute won't work -// if (orientation != ScreenOrientationAuto) { -// const QStringList v = QString::fromLatin1(qVersion()).split(QLatin1Char('.')); -// if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { -// qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); -// return; -// } -// } -//#endif // Q_OS_SYMBIAN - -// Qt::WidgetAttribute attribute; -// switch (orientation) { -//#if QT_VERSION < 0x040702 -// // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes -// case ScreenOrientationLockPortrait: -// attribute = static_cast(128); -// break; -// case ScreenOrientationLockLandscape: -// attribute = static_cast(129); -// break; -// default: -// case ScreenOrientationAuto: -// attribute = static_cast(130); -// break; -//#else // QT_VERSION < 0x040702 -// case ScreenOrientationLockPortrait: -// attribute = Qt::WA_LockPortraitOrientation; -// break; -// case ScreenOrientationLockLandscape: -// attribute = Qt::WA_LockLandscapeOrientation; -// break; -// default: -// case ScreenOrientationAuto: -// attribute = Qt::WA_AutoOrientation; -// break; -//#endif // QT_VERSION < 0x040702 -// }; -// setAttribute(attribute, true); -//} +void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) +{ +#if QT_VERSION < 0x050000 + Qt::WidgetAttribute attribute; + switch (orientation) { +#if QT_VERSION < 0x040702 + // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes + case ScreenOrientationLockPortrait: + attribute = static_cast(128); + break; + case ScreenOrientationLockLandscape: + attribute = static_cast(129); + break; + default: + case ScreenOrientationAuto: + attribute = static_cast(130); + break; +#else // QT_VERSION < 0x040702 + case ScreenOrientationLockPortrait: + attribute = Qt::WA_LockPortraitOrientation; + break; + case ScreenOrientationLockLandscape: + attribute = Qt::WA_LockLandscapeOrientation; + break; + default: + case ScreenOrientationAuto: + attribute = Qt::WA_AutoOrientation; + break; +#endif // QT_VERSION < 0x040702 + }; + setAttribute(attribute, true); +#else // QT_VERSION < 0x050000 + Q_UNUSED(orientation) +#endif // QT_VERSION < 0x050000 +} void QmlApplicationViewer::showExpanded() { -#if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) +#if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) showFullScreen(); -#elif defined(Q_WS_MAEMO_5) +#elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) showMaximized(); #else show(); diff --git a/demos/qmlf1legends/qmlapplicationviewer/qmlapplicationviewer.h b/demos/qmlf1legends/qmlapplicationviewer/qmlapplicationviewer.h index 49832088..fba2d52a 100644 --- a/demos/qmlf1legends/qmlapplicationviewer/qmlapplicationviewer.h +++ b/demos/qmlf1legends/qmlapplicationviewer/qmlapplicationviewer.h @@ -1,4 +1,4 @@ -// checksum 0x734b version 0x70013 +// checksum 0xc67a version 0x80016 /* This file was generated by the Qt Quick Application wizard of Qt Creator. QmlApplicationViewer is a convenience class containing mobile device specific @@ -11,7 +11,7 @@ #ifndef QMLAPPLICATIONVIEWER_H #define QMLAPPLICATIONVIEWER_H -#include +#include class QmlApplicationViewer : public QDeclarativeView { @@ -32,8 +32,8 @@ public: void setMainQmlFile(const QString &file); void addImportPath(const QString &path); - // Note that this will only have an effect on Symbian and Fremantle. - // void setOrientation(ScreenOrientation orientation); + // Note that this will only have an effect on Fremantle. + void setOrientation(ScreenOrientation orientation); void showExpanded(); diff --git a/demos/qmlf1legends/qmlapplicationviewer/qmlapplicationviewer.pri b/demos/qmlf1legends/qmlapplicationviewer/qmlapplicationviewer.pri index b6931d04..1134cbcd 100644 --- a/demos/qmlf1legends/qmlapplicationviewer/qmlapplicationviewer.pri +++ b/demos/qmlf1legends/qmlapplicationviewer/qmlapplicationviewer.pri @@ -1,4 +1,4 @@ -# checksum 0x5b42 version 0x70013 +# checksum 0x77b version 0x80016 # This file was generated by the Qt Quick Application wizard of Qt Creator. # The code below adds the QmlApplicationViewer to the project and handles the # activation of QML debugging. @@ -22,7 +22,7 @@ contains(CONFIG,qdeclarative-boostable):contains(MEEGO_EDITION,harmattan) { DEFINES += HARMATTAN_BOOSTER } # This file was generated by an application wizard of Qt Creator. -# The code below handles deployment to Symbian and Maemo, aswell as copying +# The code below handles deployment to Android and Maemo, aswell as copying # of the application data to shadow build directories on desktop. # It is recommended not to modify this file, since newer versions of Qt Creator # may offer an updated version of it. @@ -30,7 +30,11 @@ contains(CONFIG,qdeclarative-boostable):contains(MEEGO_EDITION,harmattan) { defineTest(qtcAddDeployment) { for(deploymentfolder, DEPLOYMENTFOLDERS) { item = item$${deploymentfolder} - itemsources = $${item}.sources + greaterThan(QT_MAJOR_VERSION, 4) { + itemsources = $${item}.files + } else { + itemsources = $${item}.sources + } $$itemsources = $$eval($${deploymentfolder}.source) itempath = $${item}.path $$itempath= $$eval($${deploymentfolder}.target) @@ -41,9 +45,28 @@ for(deploymentfolder, DEPLOYMENTFOLDERS) { MAINPROFILEPWD = $$PWD -symbian { - isEmpty(ICON):exists($${TARGET}.svg):ICON = $${TARGET}.svg - isEmpty(TARGET.EPOCHEAPSIZE):TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 +android { + for(deploymentfolder, DEPLOYMENTFOLDERS) { + item = item$${deploymentfolder} + itemfiles = $${item}.files + $$itemfiles = $$eval($${deploymentfolder}.source) + itempath = $${item}.path + $$itempath = /assets/$$eval($${deploymentfolder}.target) + export($$itemfiles) + export($$itempath) + INSTALLS += $$item + } + + x86 { + target.path = /libs/x86 + } else: armeabi-v7a { + target.path = /libs/armeabi-v7a + } else { + target.path = /libs/armeabi + } + + export(target.path) + INSTALLS += target } else:win32 { copyCommand = for(deploymentfolder, DEPLOYMENTFOLDERS) { @@ -141,8 +164,6 @@ symbian { export (ICON) export (INSTALLS) export (DEPLOYMENT) -export (TARGET.EPOCHEAPSIZE) -export (TARGET.CAPABILITY) export (LIBS) export (QMAKE_EXTRA_TARGETS) } diff --git a/demos/qmloscilloscope/qmlapplicationviewer/qmlapplicationviewer.cpp b/demos/qmloscilloscope/qmlapplicationviewer/qmlapplicationviewer.cpp index efbf1e37..0f12265e 100644 --- a/demos/qmloscilloscope/qmlapplicationviewer/qmlapplicationviewer.cpp +++ b/demos/qmloscilloscope/qmlapplicationviewer/qmlapplicationviewer.cpp @@ -1,4 +1,4 @@ -// checksum 0x78c version 0x60010 +// checksum 0xbd34 version 0x80016 /* This file was generated by the Qt Quick Application wizard of Qt Creator. QmlApplicationViewer is a convenience class containing mobile device specific @@ -10,12 +10,12 @@ #include "qmlapplicationviewer.h" -#include -#include -#include -#include -#include +#include +#include #include +#include +#include +#include #include // MEEGO_EDITION_HARMATTAN @@ -50,63 +50,47 @@ 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) { -#ifdef Q_OS_UNIX #ifdef Q_OS_MAC if (!QDir::isAbsolutePath(path)) - return QCoreApplication::applicationDirPath() - + QLatin1String("/../Resources/") + path; -#else - QString pathInInstallDir; - const QString applicationDirPath = QCoreApplication::applicationDirPath(); - pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); - + return QString::fromLatin1("%1/../Resources/%2") + .arg(QCoreApplication::applicationDirPath(), path); +#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()) + return pathInInstallDir; + pathInInstallDir = + QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); if (QFileInfo(pathInInstallDir).exists()) return pathInInstallDir; -#endif #endif return 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 } @@ -118,75 +102,68 @@ 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) -//{ -//#if defined(Q_OS_SYMBIAN) -// // If the version of Qt on the device is < 4.7.2, that attribute won't work -// if (orientation != ScreenOrientationAuto) { -// const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); -// if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { -// qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); -// return; -// } -// } -//#endif // Q_OS_SYMBIAN - -// Qt::WidgetAttribute attribute; -// switch (orientation) { -//#if QT_VERSION < 0x040702 -// // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes -// case ScreenOrientationLockPortrait: -// attribute = static_cast(128); -// break; -// case ScreenOrientationLockLandscape: -// attribute = static_cast(129); -// break; -// default: -// case ScreenOrientationAuto: -// attribute = static_cast(130); -// break; -//#else // QT_VERSION < 0x040702 -// case ScreenOrientationLockPortrait: -// attribute = Qt::WA_LockPortraitOrientation; -// break; -// case ScreenOrientationLockLandscape: -// attribute = Qt::WA_LockLandscapeOrientation; -// break; -// default: -// case ScreenOrientationAuto: -// attribute = Qt::WA_AutoOrientation; -// break; -//#endif // QT_VERSION < 0x040702 -// }; -// setAttribute(attribute, true); -//} +void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) +{ +#if QT_VERSION < 0x050000 + Qt::WidgetAttribute attribute; + switch (orientation) { +#if QT_VERSION < 0x040702 + // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes + case ScreenOrientationLockPortrait: + attribute = static_cast(128); + break; + case ScreenOrientationLockLandscape: + attribute = static_cast(129); + break; + default: + case ScreenOrientationAuto: + attribute = static_cast(130); + break; +#else // QT_VERSION < 0x040702 + case ScreenOrientationLockPortrait: + attribute = Qt::WA_LockPortraitOrientation; + break; + case ScreenOrientationLockLandscape: + attribute = Qt::WA_LockLandscapeOrientation; + break; + default: + case ScreenOrientationAuto: + attribute = Qt::WA_AutoOrientation; + break; +#endif // QT_VERSION < 0x040702 + }; + setAttribute(attribute, true); +#else // QT_VERSION < 0x050000 + Q_UNUSED(orientation) +#endif // QT_VERSION < 0x050000 +} void QmlApplicationViewer::showExpanded() { -#if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) - d->view->showFullScreen(); -#elif defined(Q_WS_MAEMO_5) - d->view->showMaximized(); +#if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) + showFullScreen(); +#elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) + showMaximized(); #else - d->view->show(); + show(); #endif } diff --git a/demos/qmloscilloscope/qmlapplicationviewer/qmlapplicationviewer.h b/demos/qmloscilloscope/qmlapplicationviewer/qmlapplicationviewer.h index 9d0fea29..fba2d52a 100644 --- a/demos/qmloscilloscope/qmlapplicationviewer/qmlapplicationviewer.h +++ b/demos/qmloscilloscope/qmlapplicationviewer/qmlapplicationviewer.h @@ -1,4 +1,4 @@ -// checksum 0x82ed version 0x60010 +// checksum 0xc67a version 0x80016 /* This file was generated by the Qt Quick Application wizard of Qt Creator. QmlApplicationViewer is a convenience class containing mobile device specific @@ -11,7 +11,7 @@ #ifndef QMLAPPLICATIONVIEWER_H #define QMLAPPLICATIONVIEWER_H -#include +#include class QmlApplicationViewer : public QDeclarativeView { @@ -32,13 +32,12 @@ public: void setMainQmlFile(const QString &file); void addImportPath(const QString &path); - // Note that this will only have an effect on Symbian and Fremantle. - // void setOrientation(ScreenOrientation orientation); + // Note that this will only have an effect on Fremantle. + void setOrientation(ScreenOrientation orientation); void showExpanded(); private: - explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); class QmlApplicationViewerPrivate *d; }; diff --git a/demos/qmlweather/qmlapplicationviewer/qmlapplicationviewer.cpp b/demos/qmlweather/qmlapplicationviewer/qmlapplicationviewer.cpp index a8f9aef0..0f12265e 100644 --- a/demos/qmlweather/qmlapplicationviewer/qmlapplicationviewer.cpp +++ b/demos/qmlweather/qmlapplicationviewer/qmlapplicationviewer.cpp @@ -1,4 +1,4 @@ -// checksum 0x3fbf version 0x70013 +// checksum 0xbd34 version 0x80016 /* This file was generated by the Qt Quick Application wizard of Qt Creator. QmlApplicationViewer is a convenience class containing mobile device specific @@ -12,10 +12,10 @@ #include #include -#include -#include -#include #include +#include +#include +#include #include // MEEGO_EDITION_HARMATTAN @@ -57,17 +57,22 @@ class QmlApplicationViewerPrivate QString QmlApplicationViewerPrivate::adjustPath(const QString &path) { -#ifdef Q_OS_UNIX #ifdef Q_OS_MAC if (!QDir::isAbsolutePath(path)) return QString::fromLatin1("%1/../Resources/%2") .arg(QCoreApplication::applicationDirPath(), path); -#else - const QString pathInInstallDir = +#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()) return pathInInstallDir; -#endif + pathInInstallDir = + QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); + if (QFileInfo(pathInInstallDir).exists()) + return pathInInstallDir; #endif return path; } @@ -78,6 +83,7 @@ QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) { 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) @@ -102,7 +108,11 @@ QmlApplicationViewer *QmlApplicationViewer::create() void QmlApplicationViewer::setMainQmlFile(const QString &file) { 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) @@ -110,54 +120,47 @@ void QmlApplicationViewer::addImportPath(const QString &path) engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); } -//void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) -//{ -//#if defined(Q_OS_SYMBIAN) -// // If the version of Qt on the device is < 4.7.2, that attribute won't work -// if (orientation != ScreenOrientationAuto) { -// const QStringList v = QString::fromLatin1(qVersion()).split(QLatin1Char('.')); -// if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { -// qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); -// return; -// } -// } -//#endif // Q_OS_SYMBIAN - -// Qt::WidgetAttribute attribute; -// switch (orientation) { -//#if QT_VERSION < 0x040702 -// // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes -// case ScreenOrientationLockPortrait: -// attribute = static_cast(128); -// break; -// case ScreenOrientationLockLandscape: -// attribute = static_cast(129); -// break; -// default: -// case ScreenOrientationAuto: -// attribute = static_cast(130); -// break; -//#else // QT_VERSION < 0x040702 -// case ScreenOrientationLockPortrait: -// attribute = Qt::WA_LockPortraitOrientation; -// break; -// case ScreenOrientationLockLandscape: -// attribute = Qt::WA_LockLandscapeOrientation; -// break; -// default: -// case ScreenOrientationAuto: -// attribute = Qt::WA_AutoOrientation; -// break; -//#endif // QT_VERSION < 0x040702 -// }; -// setAttribute(attribute, true); -//} +void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) +{ +#if QT_VERSION < 0x050000 + Qt::WidgetAttribute attribute; + switch (orientation) { +#if QT_VERSION < 0x040702 + // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes + case ScreenOrientationLockPortrait: + attribute = static_cast(128); + break; + case ScreenOrientationLockLandscape: + attribute = static_cast(129); + break; + default: + case ScreenOrientationAuto: + attribute = static_cast(130); + break; +#else // QT_VERSION < 0x040702 + case ScreenOrientationLockPortrait: + attribute = Qt::WA_LockPortraitOrientation; + break; + case ScreenOrientationLockLandscape: + attribute = Qt::WA_LockLandscapeOrientation; + break; + default: + case ScreenOrientationAuto: + attribute = Qt::WA_AutoOrientation; + break; +#endif // QT_VERSION < 0x040702 + }; + setAttribute(attribute, true); +#else // QT_VERSION < 0x050000 + Q_UNUSED(orientation) +#endif // QT_VERSION < 0x050000 +} void QmlApplicationViewer::showExpanded() { -#if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) +#if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) showFullScreen(); -#elif defined(Q_WS_MAEMO_5) +#elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) showMaximized(); #else show(); diff --git a/demos/qmlweather/qmlapplicationviewer/qmlapplicationviewer.h b/demos/qmlweather/qmlapplicationviewer/qmlapplicationviewer.h index e672718c..fba2d52a 100644 --- a/demos/qmlweather/qmlapplicationviewer/qmlapplicationviewer.h +++ b/demos/qmlweather/qmlapplicationviewer/qmlapplicationviewer.h @@ -1,4 +1,4 @@ -// checksum 0x734b version 0x70013 +// checksum 0xc67a version 0x80016 /* This file was generated by the Qt Quick Application wizard of Qt Creator. QmlApplicationViewer is a convenience class containing mobile device specific @@ -32,8 +32,8 @@ public: void setMainQmlFile(const QString &file); void addImportPath(const QString &path); - // Note that this will only have an effect on Symbian and Fremantle. - // void setOrientation(ScreenOrientation orientation); + // Note that this will only have an effect on Fremantle. + void setOrientation(ScreenOrientation orientation); void showExpanded(); diff --git a/demos/qmlweather/qmlapplicationviewer/qmlapplicationviewer.pri b/demos/qmlweather/qmlapplicationviewer/qmlapplicationviewer.pri index b6931d04..1134cbcd 100644 --- a/demos/qmlweather/qmlapplicationviewer/qmlapplicationviewer.pri +++ b/demos/qmlweather/qmlapplicationviewer/qmlapplicationviewer.pri @@ -1,4 +1,4 @@ -# checksum 0x5b42 version 0x70013 +# checksum 0x77b version 0x80016 # This file was generated by the Qt Quick Application wizard of Qt Creator. # The code below adds the QmlApplicationViewer to the project and handles the # activation of QML debugging. @@ -22,7 +22,7 @@ contains(CONFIG,qdeclarative-boostable):contains(MEEGO_EDITION,harmattan) { DEFINES += HARMATTAN_BOOSTER } # This file was generated by an application wizard of Qt Creator. -# The code below handles deployment to Symbian and Maemo, aswell as copying +# The code below handles deployment to Android and Maemo, aswell as copying # of the application data to shadow build directories on desktop. # It is recommended not to modify this file, since newer versions of Qt Creator # may offer an updated version of it. @@ -30,7 +30,11 @@ contains(CONFIG,qdeclarative-boostable):contains(MEEGO_EDITION,harmattan) { defineTest(qtcAddDeployment) { for(deploymentfolder, DEPLOYMENTFOLDERS) { item = item$${deploymentfolder} - itemsources = $${item}.sources + greaterThan(QT_MAJOR_VERSION, 4) { + itemsources = $${item}.files + } else { + itemsources = $${item}.sources + } $$itemsources = $$eval($${deploymentfolder}.source) itempath = $${item}.path $$itempath= $$eval($${deploymentfolder}.target) @@ -41,9 +45,28 @@ for(deploymentfolder, DEPLOYMENTFOLDERS) { MAINPROFILEPWD = $$PWD -symbian { - isEmpty(ICON):exists($${TARGET}.svg):ICON = $${TARGET}.svg - isEmpty(TARGET.EPOCHEAPSIZE):TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 +android { + for(deploymentfolder, DEPLOYMENTFOLDERS) { + item = item$${deploymentfolder} + itemfiles = $${item}.files + $$itemfiles = $$eval($${deploymentfolder}.source) + itempath = $${item}.path + $$itempath = /assets/$$eval($${deploymentfolder}.target) + export($$itemfiles) + export($$itempath) + INSTALLS += $$item + } + + x86 { + target.path = /libs/x86 + } else: armeabi-v7a { + target.path = /libs/armeabi-v7a + } else { + target.path = /libs/armeabi + } + + export(target.path) + INSTALLS += target } else:win32 { copyCommand = for(deploymentfolder, DEPLOYMENTFOLDERS) { @@ -141,8 +164,6 @@ symbian { export (ICON) export (INSTALLS) export (DEPLOYMENT) -export (TARGET.EPOCHEAPSIZE) -export (TARGET.CAPABILITY) export (LIBS) export (QMAKE_EXTRA_TARGETS) } diff --git a/examples/qmlpiechart/qmlapplicationviewer/qmlapplicationviewer.cpp b/examples/qmlpiechart/qmlapplicationviewer/qmlapplicationviewer.cpp index efbf1e37..0f12265e 100644 --- a/examples/qmlpiechart/qmlapplicationviewer/qmlapplicationviewer.cpp +++ b/examples/qmlpiechart/qmlapplicationviewer/qmlapplicationviewer.cpp @@ -1,4 +1,4 @@ -// checksum 0x78c version 0x60010 +// checksum 0xbd34 version 0x80016 /* This file was generated by the Qt Quick Application wizard of Qt Creator. QmlApplicationViewer is a convenience class containing mobile device specific @@ -10,12 +10,12 @@ #include "qmlapplicationviewer.h" -#include -#include -#include -#include -#include +#include +#include #include +#include +#include +#include #include // MEEGO_EDITION_HARMATTAN @@ -50,63 +50,47 @@ 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) { -#ifdef Q_OS_UNIX #ifdef Q_OS_MAC if (!QDir::isAbsolutePath(path)) - return QCoreApplication::applicationDirPath() - + QLatin1String("/../Resources/") + path; -#else - QString pathInInstallDir; - const QString applicationDirPath = QCoreApplication::applicationDirPath(); - pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); - + return QString::fromLatin1("%1/../Resources/%2") + .arg(QCoreApplication::applicationDirPath(), path); +#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()) + return pathInInstallDir; + pathInInstallDir = + QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); if (QFileInfo(pathInInstallDir).exists()) return pathInInstallDir; -#endif #endif return 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 } @@ -118,75 +102,68 @@ 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) -//{ -//#if defined(Q_OS_SYMBIAN) -// // If the version of Qt on the device is < 4.7.2, that attribute won't work -// if (orientation != ScreenOrientationAuto) { -// const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); -// if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { -// qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); -// return; -// } -// } -//#endif // Q_OS_SYMBIAN - -// Qt::WidgetAttribute attribute; -// switch (orientation) { -//#if QT_VERSION < 0x040702 -// // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes -// case ScreenOrientationLockPortrait: -// attribute = static_cast(128); -// break; -// case ScreenOrientationLockLandscape: -// attribute = static_cast(129); -// break; -// default: -// case ScreenOrientationAuto: -// attribute = static_cast(130); -// break; -//#else // QT_VERSION < 0x040702 -// case ScreenOrientationLockPortrait: -// attribute = Qt::WA_LockPortraitOrientation; -// break; -// case ScreenOrientationLockLandscape: -// attribute = Qt::WA_LockLandscapeOrientation; -// break; -// default: -// case ScreenOrientationAuto: -// attribute = Qt::WA_AutoOrientation; -// break; -//#endif // QT_VERSION < 0x040702 -// }; -// setAttribute(attribute, true); -//} +void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) +{ +#if QT_VERSION < 0x050000 + Qt::WidgetAttribute attribute; + switch (orientation) { +#if QT_VERSION < 0x040702 + // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes + case ScreenOrientationLockPortrait: + attribute = static_cast(128); + break; + case ScreenOrientationLockLandscape: + attribute = static_cast(129); + break; + default: + case ScreenOrientationAuto: + attribute = static_cast(130); + break; +#else // QT_VERSION < 0x040702 + case ScreenOrientationLockPortrait: + attribute = Qt::WA_LockPortraitOrientation; + break; + case ScreenOrientationLockLandscape: + attribute = Qt::WA_LockLandscapeOrientation; + break; + default: + case ScreenOrientationAuto: + attribute = Qt::WA_AutoOrientation; + break; +#endif // QT_VERSION < 0x040702 + }; + setAttribute(attribute, true); +#else // QT_VERSION < 0x050000 + Q_UNUSED(orientation) +#endif // QT_VERSION < 0x050000 +} void QmlApplicationViewer::showExpanded() { -#if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) - d->view->showFullScreen(); -#elif defined(Q_WS_MAEMO_5) - d->view->showMaximized(); +#if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) + showFullScreen(); +#elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) + showMaximized(); #else - d->view->show(); + show(); #endif } diff --git a/examples/qmlpiechart/qmlapplicationviewer/qmlapplicationviewer.h b/examples/qmlpiechart/qmlapplicationviewer/qmlapplicationviewer.h index 9d0fea29..fba2d52a 100644 --- a/examples/qmlpiechart/qmlapplicationviewer/qmlapplicationviewer.h +++ b/examples/qmlpiechart/qmlapplicationviewer/qmlapplicationviewer.h @@ -1,4 +1,4 @@ -// checksum 0x82ed version 0x60010 +// checksum 0xc67a version 0x80016 /* This file was generated by the Qt Quick Application wizard of Qt Creator. QmlApplicationViewer is a convenience class containing mobile device specific @@ -11,7 +11,7 @@ #ifndef QMLAPPLICATIONVIEWER_H #define QMLAPPLICATIONVIEWER_H -#include +#include class QmlApplicationViewer : public QDeclarativeView { @@ -32,13 +32,12 @@ public: void setMainQmlFile(const QString &file); void addImportPath(const QString &path); - // Note that this will only have an effect on Symbian and Fremantle. - // void setOrientation(ScreenOrientation orientation); + // Note that this will only have an effect on Fremantle. + void setOrientation(ScreenOrientation orientation); void showExpanded(); private: - explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); class QmlApplicationViewerPrivate *d; }; diff --git a/tests/qmlchartaxis/qmlapplicationviewer/qmlapplicationviewer.cpp b/tests/qmlchartaxis/qmlapplicationviewer/qmlapplicationviewer.cpp index efbf1e37..0f12265e 100644 --- a/tests/qmlchartaxis/qmlapplicationviewer/qmlapplicationviewer.cpp +++ b/tests/qmlchartaxis/qmlapplicationviewer/qmlapplicationviewer.cpp @@ -1,4 +1,4 @@ -// checksum 0x78c version 0x60010 +// checksum 0xbd34 version 0x80016 /* This file was generated by the Qt Quick Application wizard of Qt Creator. QmlApplicationViewer is a convenience class containing mobile device specific @@ -10,12 +10,12 @@ #include "qmlapplicationviewer.h" -#include -#include -#include -#include -#include +#include +#include #include +#include +#include +#include #include // MEEGO_EDITION_HARMATTAN @@ -50,63 +50,47 @@ 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) { -#ifdef Q_OS_UNIX #ifdef Q_OS_MAC if (!QDir::isAbsolutePath(path)) - return QCoreApplication::applicationDirPath() - + QLatin1String("/../Resources/") + path; -#else - QString pathInInstallDir; - const QString applicationDirPath = QCoreApplication::applicationDirPath(); - pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); - + return QString::fromLatin1("%1/../Resources/%2") + .arg(QCoreApplication::applicationDirPath(), path); +#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()) + return pathInInstallDir; + pathInInstallDir = + QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); if (QFileInfo(pathInInstallDir).exists()) return pathInInstallDir; -#endif #endif return 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 } @@ -118,75 +102,68 @@ 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) -//{ -//#if defined(Q_OS_SYMBIAN) -// // If the version of Qt on the device is < 4.7.2, that attribute won't work -// if (orientation != ScreenOrientationAuto) { -// const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); -// if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { -// qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); -// return; -// } -// } -//#endif // Q_OS_SYMBIAN - -// Qt::WidgetAttribute attribute; -// switch (orientation) { -//#if QT_VERSION < 0x040702 -// // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes -// case ScreenOrientationLockPortrait: -// attribute = static_cast(128); -// break; -// case ScreenOrientationLockLandscape: -// attribute = static_cast(129); -// break; -// default: -// case ScreenOrientationAuto: -// attribute = static_cast(130); -// break; -//#else // QT_VERSION < 0x040702 -// case ScreenOrientationLockPortrait: -// attribute = Qt::WA_LockPortraitOrientation; -// break; -// case ScreenOrientationLockLandscape: -// attribute = Qt::WA_LockLandscapeOrientation; -// break; -// default: -// case ScreenOrientationAuto: -// attribute = Qt::WA_AutoOrientation; -// break; -//#endif // QT_VERSION < 0x040702 -// }; -// setAttribute(attribute, true); -//} +void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) +{ +#if QT_VERSION < 0x050000 + Qt::WidgetAttribute attribute; + switch (orientation) { +#if QT_VERSION < 0x040702 + // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes + case ScreenOrientationLockPortrait: + attribute = static_cast(128); + break; + case ScreenOrientationLockLandscape: + attribute = static_cast(129); + break; + default: + case ScreenOrientationAuto: + attribute = static_cast(130); + break; +#else // QT_VERSION < 0x040702 + case ScreenOrientationLockPortrait: + attribute = Qt::WA_LockPortraitOrientation; + break; + case ScreenOrientationLockLandscape: + attribute = Qt::WA_LockLandscapeOrientation; + break; + default: + case ScreenOrientationAuto: + attribute = Qt::WA_AutoOrientation; + break; +#endif // QT_VERSION < 0x040702 + }; + setAttribute(attribute, true); +#else // QT_VERSION < 0x050000 + Q_UNUSED(orientation) +#endif // QT_VERSION < 0x050000 +} void QmlApplicationViewer::showExpanded() { -#if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) - d->view->showFullScreen(); -#elif defined(Q_WS_MAEMO_5) - d->view->showMaximized(); +#if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) + showFullScreen(); +#elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) + showMaximized(); #else - d->view->show(); + show(); #endif } diff --git a/tests/qmlchartaxis/qmlapplicationviewer/qmlapplicationviewer.h b/tests/qmlchartaxis/qmlapplicationviewer/qmlapplicationviewer.h index 9d0fea29..fba2d52a 100644 --- a/tests/qmlchartaxis/qmlapplicationviewer/qmlapplicationviewer.h +++ b/tests/qmlchartaxis/qmlapplicationviewer/qmlapplicationviewer.h @@ -1,4 +1,4 @@ -// checksum 0x82ed version 0x60010 +// checksum 0xc67a version 0x80016 /* This file was generated by the Qt Quick Application wizard of Qt Creator. QmlApplicationViewer is a convenience class containing mobile device specific @@ -11,7 +11,7 @@ #ifndef QMLAPPLICATIONVIEWER_H #define QMLAPPLICATIONVIEWER_H -#include +#include class QmlApplicationViewer : public QDeclarativeView { @@ -32,13 +32,12 @@ public: void setMainQmlFile(const QString &file); void addImportPath(const QString &path); - // Note that this will only have an effect on Symbian and Fremantle. - // void setOrientation(ScreenOrientation orientation); + // Note that this will only have an effect on Fremantle. + void setOrientation(ScreenOrientation orientation); void showExpanded(); private: - explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); class QmlApplicationViewerPrivate *d; }; diff --git a/tests/qmlchartproperties/qmlapplicationviewer/qmlapplicationviewer.cpp b/tests/qmlchartproperties/qmlapplicationviewer/qmlapplicationviewer.cpp index efbf1e37..0f12265e 100644 --- a/tests/qmlchartproperties/qmlapplicationviewer/qmlapplicationviewer.cpp +++ b/tests/qmlchartproperties/qmlapplicationviewer/qmlapplicationviewer.cpp @@ -1,4 +1,4 @@ -// checksum 0x78c version 0x60010 +// checksum 0xbd34 version 0x80016 /* This file was generated by the Qt Quick Application wizard of Qt Creator. QmlApplicationViewer is a convenience class containing mobile device specific @@ -10,12 +10,12 @@ #include "qmlapplicationviewer.h" -#include -#include -#include -#include -#include +#include +#include #include +#include +#include +#include #include // MEEGO_EDITION_HARMATTAN @@ -50,63 +50,47 @@ 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) { -#ifdef Q_OS_UNIX #ifdef Q_OS_MAC if (!QDir::isAbsolutePath(path)) - return QCoreApplication::applicationDirPath() - + QLatin1String("/../Resources/") + path; -#else - QString pathInInstallDir; - const QString applicationDirPath = QCoreApplication::applicationDirPath(); - pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); - + return QString::fromLatin1("%1/../Resources/%2") + .arg(QCoreApplication::applicationDirPath(), path); +#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()) + return pathInInstallDir; + pathInInstallDir = + QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); if (QFileInfo(pathInInstallDir).exists()) return pathInInstallDir; -#endif #endif return 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 } @@ -118,75 +102,68 @@ 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) -//{ -//#if defined(Q_OS_SYMBIAN) -// // If the version of Qt on the device is < 4.7.2, that attribute won't work -// if (orientation != ScreenOrientationAuto) { -// const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); -// if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { -// qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); -// return; -// } -// } -//#endif // Q_OS_SYMBIAN - -// Qt::WidgetAttribute attribute; -// switch (orientation) { -//#if QT_VERSION < 0x040702 -// // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes -// case ScreenOrientationLockPortrait: -// attribute = static_cast(128); -// break; -// case ScreenOrientationLockLandscape: -// attribute = static_cast(129); -// break; -// default: -// case ScreenOrientationAuto: -// attribute = static_cast(130); -// break; -//#else // QT_VERSION < 0x040702 -// case ScreenOrientationLockPortrait: -// attribute = Qt::WA_LockPortraitOrientation; -// break; -// case ScreenOrientationLockLandscape: -// attribute = Qt::WA_LockLandscapeOrientation; -// break; -// default: -// case ScreenOrientationAuto: -// attribute = Qt::WA_AutoOrientation; -// break; -//#endif // QT_VERSION < 0x040702 -// }; -// setAttribute(attribute, true); -//} +void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) +{ +#if QT_VERSION < 0x050000 + Qt::WidgetAttribute attribute; + switch (orientation) { +#if QT_VERSION < 0x040702 + // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes + case ScreenOrientationLockPortrait: + attribute = static_cast(128); + break; + case ScreenOrientationLockLandscape: + attribute = static_cast(129); + break; + default: + case ScreenOrientationAuto: + attribute = static_cast(130); + break; +#else // QT_VERSION < 0x040702 + case ScreenOrientationLockPortrait: + attribute = Qt::WA_LockPortraitOrientation; + break; + case ScreenOrientationLockLandscape: + attribute = Qt::WA_LockLandscapeOrientation; + break; + default: + case ScreenOrientationAuto: + attribute = Qt::WA_AutoOrientation; + break; +#endif // QT_VERSION < 0x040702 + }; + setAttribute(attribute, true); +#else // QT_VERSION < 0x050000 + Q_UNUSED(orientation) +#endif // QT_VERSION < 0x050000 +} void QmlApplicationViewer::showExpanded() { -#if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) - d->view->showFullScreen(); -#elif defined(Q_WS_MAEMO_5) - d->view->showMaximized(); +#if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) + showFullScreen(); +#elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) + showMaximized(); #else - d->view->show(); + show(); #endif } diff --git a/tests/qmlchartproperties/qmlapplicationviewer/qmlapplicationviewer.h b/tests/qmlchartproperties/qmlapplicationviewer/qmlapplicationviewer.h index 9d0fea29..fba2d52a 100644 --- a/tests/qmlchartproperties/qmlapplicationviewer/qmlapplicationviewer.h +++ b/tests/qmlchartproperties/qmlapplicationviewer/qmlapplicationviewer.h @@ -1,4 +1,4 @@ -// checksum 0x82ed version 0x60010 +// checksum 0xc67a version 0x80016 /* This file was generated by the Qt Quick Application wizard of Qt Creator. QmlApplicationViewer is a convenience class containing mobile device specific @@ -11,7 +11,7 @@ #ifndef QMLAPPLICATIONVIEWER_H #define QMLAPPLICATIONVIEWER_H -#include +#include class QmlApplicationViewer : public QDeclarativeView { @@ -32,13 +32,12 @@ public: void setMainQmlFile(const QString &file); void addImportPath(const QString &path); - // Note that this will only have an effect on Symbian and Fremantle. - // void setOrientation(ScreenOrientation orientation); + // Note that this will only have an effect on Fremantle. + void setOrientation(ScreenOrientation orientation); void showExpanded(); private: - explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); class QmlApplicationViewerPrivate *d; }; -- cgit v1.2.3