diff options
Diffstat (limited to 'demos/qmlweather/qmlapplicationviewer/qmlapplicationviewer.cpp')
-rw-r--r-- | demos/qmlweather/qmlapplicationviewer/qmlapplicationviewer.cpp | 107 |
1 files changed, 55 insertions, 52 deletions
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 <QDir> #include <QFileInfo> -#include <QtDeclarative/QDeclarativeComponent> -#include <QtDeclarative/QDeclarativeEngine> -#include <QtDeclarative/QDeclarativeContext> #include <QApplication> +#include <QDeclarativeComponent> +#include <QDeclarativeEngine> +#include <QDeclarativeContext> #include <qplatformdefs.h> // 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<Qt::WidgetAttribute>(128); -// break; -// case ScreenOrientationLockLandscape: -// attribute = static_cast<Qt::WidgetAttribute>(129); -// break; -// default: -// case ScreenOrientationAuto: -// attribute = static_cast<Qt::WidgetAttribute>(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<Qt::WidgetAttribute>(128); + break; + case ScreenOrientationLockLandscape: + attribute = static_cast<Qt::WidgetAttribute>(129); + break; + default: + case ScreenOrientationAuto: + attribute = static_cast<Qt::WidgetAttribute>(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(); |