2
This file was generated by the Qt Quick 1 Application wizard of Qt Creator.
3
QtQuick1ApplicationViewer is a convenience class containing mobile device
4
specific code such as screen orientation handling. Also QML paths are
6
It is recommended not to modify this file, since newer versions of Qt Creator
7
may offer an updated version of it.
10
#include "qtquick1applicationviewer.h"
14
#include <QApplication>
15
#include <QDeclarativeComponent>
16
#include <QDeclarativeEngine>
17
#include <QDeclarativeContext>
19
#include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN
21
class QtQuick1ApplicationViewerPrivate
24
friend class QtQuick1ApplicationViewer;
25
static QString adjustPath(const QString &path);
28
QString QtQuick1ApplicationViewerPrivate::adjustPath(const QString &path)
31
if (!QDir::isAbsolutePath(path))
32
return QString::fromLatin1("%1/%2")
33
.arg(QCoreApplication::applicationDirPath(), path);
34
#elif defined(Q_OS_MAC)
35
if (!QDir::isAbsolutePath(path))
36
return QString::fromLatin1("%1/../Resources/%2")
37
.arg(QCoreApplication::applicationDirPath(), path);
38
#elif defined(Q_OS_BLACKBERRY)
39
if (!QDir::isAbsolutePath(path))
40
return QString::fromLatin1("app/native/%1").arg(path);
41
#elif !defined(Q_OS_ANDROID)
42
QString pathInInstallDir =
43
QString::fromLatin1("%1/../%2").arg(
44
QCoreApplication::applicationDirPath(), path);
45
if (QFileInfo(pathInInstallDir).exists())
46
return pathInInstallDir;
48
QString::fromLatin1("%1/%2").arg(
49
QCoreApplication::applicationDirPath(), path);
50
if (QFileInfo(pathInInstallDir).exists())
51
return pathInInstallDir;
56
QtQuick1ApplicationViewer::QtQuick1ApplicationViewer(QWidget *parent)
57
: QDeclarativeView(parent)
58
, d(new QtQuick1ApplicationViewerPrivate())
60
connect(engine(), SIGNAL(quit()), SLOT(close()));
61
setResizeMode(QDeclarativeView::SizeRootObjectToView);
64
QtQuick1ApplicationViewer::~QtQuick1ApplicationViewer()
69
QtQuick1ApplicationViewer *QtQuick1ApplicationViewer::create()
71
return new QtQuick1ApplicationViewer();
74
void QtQuick1ApplicationViewer::setMainQmlFile(const QString &file)
76
d->mainQmlFile = QtQuick1ApplicationViewerPrivate::adjustPath(file);
78
setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile));
80
setSource(QUrl::fromLocalFile(d->mainQmlFile));
84
void QtQuick1ApplicationViewer::addImportPath(const QString &path)
86
engine()->addImportPath(QtQuick1ApplicationViewerPrivate::adjustPath(path));
89
void QtQuick1ApplicationViewer::setOrientation(ScreenOrientation orientation)
91
#if QT_VERSION < 0x050000
92
Qt::WidgetAttribute attribute;
93
switch (orientation) {
94
case ScreenOrientationLockPortrait:
95
attribute = Qt::WA_LockPortraitOrientation;
97
case ScreenOrientationLockLandscape:
98
attribute = Qt::WA_LockLandscapeOrientation;
101
case ScreenOrientationAuto:
102
attribute = Qt::WA_AutoOrientation;
105
setAttribute(attribute, true);
106
#else // QT_VERSION < 0x050000
107
Q_UNUSED(orientation)
108
#endif // QT_VERSION < 0x050000
111
void QtQuick1ApplicationViewer::showExpanded()
113
#if defined(Q_WS_SIMULATOR) || defined(Q_OS_QNX)