@@ -1,200 +1,177 | |||
|
1 |
// checksum 0x |
|
|
1 | // checksum 0xbd34 version 0x80016 | |
|
2 | 2 | /* |
|
3 | 3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
4 | 4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
5 | 5 | code such as screen orientation handling. Also QML paths and debugging are |
|
6 | 6 | handled here. |
|
7 | 7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
8 | 8 | may offer an updated version of it. |
|
9 | 9 | */ |
|
10 | 10 | |
|
11 | 11 | #include "qmlapplicationviewer.h" |
|
12 | 12 | |
|
13 |
#include <Q |
|
|
14 |
#include <Q |
|
|
15 | #include <QtDeclarative/QDeclarativeComponent> | |
|
16 | #include <QtDeclarative/QDeclarativeEngine> | |
|
17 | #include <QtDeclarative/QDeclarativeContext> | |
|
13 | #include <QDir> | |
|
14 | #include <QFileInfo> | |
|
18 | 15 | #include <QApplication> |
|
16 | #include <QDeclarativeComponent> | |
|
17 | #include <QDeclarativeEngine> | |
|
18 | #include <QDeclarativeContext> | |
|
19 | 19 | |
|
20 | 20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
21 | 21 | |
|
22 | 22 | #ifdef HARMATTAN_BOOSTER |
|
23 | 23 | #include <MDeclarativeCache> |
|
24 | 24 | #endif |
|
25 | 25 | |
|
26 | 26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
27 | 27 | |
|
28 | 28 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
29 | 29 | |
|
30 | 30 | #if !defined(NO_JSDEBUGGER) |
|
31 | 31 | #include <jsdebuggeragent.h> |
|
32 | 32 | #endif |
|
33 | 33 | #if !defined(NO_QMLOBSERVER) |
|
34 | 34 | #include <qdeclarativeviewobserver.h> |
|
35 | 35 | #endif |
|
36 | 36 | |
|
37 | 37 | // Enable debugging before any QDeclarativeEngine is created |
|
38 | 38 | struct QmlJsDebuggingEnabler |
|
39 | 39 | { |
|
40 | 40 | QmlJsDebuggingEnabler() |
|
41 | 41 | { |
|
42 | 42 | QDeclarativeDebugHelper::enableDebugging(); |
|
43 | 43 | } |
|
44 | 44 | }; |
|
45 | 45 | |
|
46 | 46 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
47 | 47 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
48 | 48 | |
|
49 | 49 | #endif // QMLJSDEBUGGER |
|
50 | 50 | |
|
51 | 51 | class QmlApplicationViewerPrivate |
|
52 | 52 | { |
|
53 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} | |
|
54 | ||
|
55 | 53 | QString mainQmlFile; |
|
56 | QDeclarativeView *view; | |
|
57 | 54 | friend class QmlApplicationViewer; |
|
58 | QString adjustPath(const QString &path); | |
|
55 | static QString adjustPath(const QString &path); | |
|
59 | 56 | }; |
|
60 | 57 | |
|
61 | 58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
62 | 59 | { |
|
63 | #ifdef Q_OS_UNIX | |
|
64 | 60 | #ifdef Q_OS_MAC |
|
65 | 61 | if (!QDir::isAbsolutePath(path)) |
|
66 | return QCoreApplication::applicationDirPath() | |
|
67 | + QLatin1String("/../Resources/") + path; | |
|
68 | #else | |
|
69 | QString pathInInstallDir; | |
|
70 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); | |
|
71 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); | |
|
72 | ||
|
62 | return QString::fromLatin1("%1/../Resources/%2") | |
|
63 | .arg(QCoreApplication::applicationDirPath(), path); | |
|
64 | #elif defined(Q_OS_QNX) | |
|
65 | if (!QDir::isAbsolutePath(path)) | |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
|
67 | #elif !defined(Q_OS_ANDROID) | |
|
68 | QString pathInInstallDir = | |
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |
|
71 | return pathInInstallDir; | |
|
72 | pathInInstallDir = | |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
|
73 | 74 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | 75 | return pathInInstallDir; |
|
75 | #endif | |
|
76 | 76 | #endif |
|
77 | 77 | return path; |
|
78 | 78 | } |
|
79 | 79 | |
|
80 | 80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
81 | 81 | : QDeclarativeView(parent) |
|
82 |
, d(new QmlApplicationViewerPrivate( |
|
|
82 | , d(new QmlApplicationViewerPrivate()) | |
|
83 | 83 | { |
|
84 | 84 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
85 | 85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
86 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
|
87 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
|
88 | #if !defined(NO_JSDEBUGGER) | |
|
89 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); | |
|
90 | #endif | |
|
91 | #if !defined(NO_QMLOBSERVER) | |
|
92 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); | |
|
93 | #endif | |
|
94 | #endif | |
|
95 | } | |
|
96 | 86 | |
|
97 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) | |
|
98 | : QDeclarativeView(parent) | |
|
99 | , d(new QmlApplicationViewerPrivate(view)) | |
|
100 | { | |
|
101 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); | |
|
102 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
|
103 | 87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
104 | 88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
105 | 89 | #if !defined(NO_JSDEBUGGER) |
|
106 |
new QmlJSDebugger::JSDebuggerAgent( |
|
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
|
107 | 91 | #endif |
|
108 | 92 | #if !defined(NO_QMLOBSERVER) |
|
109 |
new QmlJSDebugger::QDeclarativeViewObserver( |
|
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
|
110 | 94 | #endif |
|
111 | 95 | #endif |
|
112 | 96 | } |
|
113 | 97 | |
|
114 | 98 | QmlApplicationViewer::~QmlApplicationViewer() |
|
115 | 99 | { |
|
116 | 100 | delete d; |
|
117 | 101 | } |
|
118 | 102 | |
|
119 | 103 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
120 | 104 | { |
|
121 | #ifdef HARMATTAN_BOOSTER | |
|
122 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); | |
|
123 | #else | |
|
124 | 105 | return new QmlApplicationViewer(); |
|
125 | #endif | |
|
126 | 106 | } |
|
127 | 107 | |
|
128 | 108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
129 | 109 | { |
|
130 |
d->mainQmlFile = |
|
|
131 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
|
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
|
111 | #ifdef Q_OS_ANDROID | |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
|
113 | #else | |
|
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
|
115 | #endif | |
|
132 | 116 | } |
|
133 | 117 | |
|
134 | 118 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
135 | 119 | { |
|
136 |
|
|
|
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
|
137 | 121 | } |
|
138 | 122 | |
|
139 |
|
|
|
140 | //{ | |
|
141 | //#if defined(Q_OS_SYMBIAN) | |
|
142 | // // If the version of Qt on the device is < 4.7.2, that attribute won't work | |
|
143 | // if (orientation != ScreenOrientationAuto) { | |
|
144 | // const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); | |
|
145 | // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { | |
|
146 | // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); | |
|
147 | // return; | |
|
148 |
|
|
|
149 | // } | |
|
150 | //#endif // Q_OS_SYMBIAN | |
|
151 | ||
|
152 | // Qt::WidgetAttribute attribute; | |
|
153 | // switch (orientation) { | |
|
154 | //#if QT_VERSION < 0x040702 | |
|
155 | // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
|
156 | // case ScreenOrientationLockPortrait: | |
|
157 | // attribute = static_cast<Qt::WidgetAttribute>(128); | |
|
158 | // break; | |
|
159 | // case ScreenOrientationLockLandscape: | |
|
160 | // attribute = static_cast<Qt::WidgetAttribute>(129); | |
|
161 | // break; | |
|
162 | // default: | |
|
163 | // case ScreenOrientationAuto: | |
|
164 | // attribute = static_cast<Qt::WidgetAttribute>(130); | |
|
165 | // break; | |
|
166 | //#else // QT_VERSION < 0x040702 | |
|
167 | // case ScreenOrientationLockPortrait: | |
|
168 | // attribute = Qt::WA_LockPortraitOrientation; | |
|
169 | // break; | |
|
170 | // case ScreenOrientationLockLandscape: | |
|
171 | // attribute = Qt::WA_LockLandscapeOrientation; | |
|
172 | // break; | |
|
173 | // default: | |
|
174 | // case ScreenOrientationAuto: | |
|
175 | // attribute = Qt::WA_AutoOrientation; | |
|
176 | // break; | |
|
177 | //#endif // QT_VERSION < 0x040702 | |
|
178 | // }; | |
|
179 | // setAttribute(attribute, true); | |
|
180 | //} | |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
|
124 | { | |
|
125 | #if QT_VERSION < 0x050000 | |
|
126 | Qt::WidgetAttribute attribute; | |
|
127 | switch (orientation) { | |
|
128 | #if QT_VERSION < 0x040702 | |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
|
130 | case ScreenOrientationLockPortrait: | |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
|
132 | break; | |
|
133 | case ScreenOrientationLockLandscape: | |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
|
135 | break; | |
|
136 | default: | |
|
137 | case ScreenOrientationAuto: | |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
|
139 | break; | |
|
140 | #else // QT_VERSION < 0x040702 | |
|
141 | case ScreenOrientationLockPortrait: | |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
|
143 | break; | |
|
144 | case ScreenOrientationLockLandscape: | |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
|
146 | break; | |
|
147 | default: | |
|
148 | case ScreenOrientationAuto: | |
|
149 | attribute = Qt::WA_AutoOrientation; | |
|
150 | break; | |
|
151 | #endif // QT_VERSION < 0x040702 | |
|
152 | }; | |
|
153 | setAttribute(attribute, true); | |
|
154 | #else // QT_VERSION < 0x050000 | |
|
155 | Q_UNUSED(orientation) | |
|
156 | #endif // QT_VERSION < 0x050000 | |
|
157 | } | |
|
181 | 158 | |
|
182 | 159 | void QmlApplicationViewer::showExpanded() |
|
183 | 160 | { |
|
184 |
#if defined( |
|
|
185 |
|
|
|
186 | #elif defined(Q_WS_MAEMO_5) | |
|
187 |
|
|
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
|
162 | showFullScreen(); | |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
|
164 | showMaximized(); | |
|
188 | 165 | #else |
|
189 |
|
|
|
166 | show(); | |
|
190 | 167 | #endif |
|
191 | 168 | } |
|
192 | 169 | |
|
193 | 170 | QApplication *createApplication(int &argc, char **argv) |
|
194 | 171 | { |
|
195 | 172 | #ifdef HARMATTAN_BOOSTER |
|
196 | 173 | return MDeclarativeCache::qApplication(argc, argv); |
|
197 | 174 | #else |
|
198 | 175 | return new QApplication(argc, argv); |
|
199 | 176 | #endif |
|
200 | 177 | } |
@@ -1,47 +1,46 | |||
|
1 |
// checksum 0x |
|
|
1 | // checksum 0xc67a version 0x80016 | |
|
2 | 2 | /* |
|
3 | 3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
4 | 4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
5 | 5 | code such as screen orientation handling. Also QML paths and debugging are |
|
6 | 6 | handled here. |
|
7 | 7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
8 | 8 | may offer an updated version of it. |
|
9 | 9 | */ |
|
10 | 10 | |
|
11 | 11 | #ifndef QMLAPPLICATIONVIEWER_H |
|
12 | 12 | #define QMLAPPLICATIONVIEWER_H |
|
13 | 13 | |
|
14 |
#include <Q |
|
|
14 | #include <QDeclarativeView> | |
|
15 | 15 | |
|
16 | 16 | class QmlApplicationViewer : public QDeclarativeView |
|
17 | 17 | { |
|
18 | 18 | Q_OBJECT |
|
19 | 19 | |
|
20 | 20 | public: |
|
21 | 21 | enum ScreenOrientation { |
|
22 | 22 | ScreenOrientationLockPortrait, |
|
23 | 23 | ScreenOrientationLockLandscape, |
|
24 | 24 | ScreenOrientationAuto |
|
25 | 25 | }; |
|
26 | 26 | |
|
27 | 27 | explicit QmlApplicationViewer(QWidget *parent = 0); |
|
28 | 28 | virtual ~QmlApplicationViewer(); |
|
29 | 29 | |
|
30 | 30 | static QmlApplicationViewer *create(); |
|
31 | 31 | |
|
32 | 32 | void setMainQmlFile(const QString &file); |
|
33 | 33 | void addImportPath(const QString &path); |
|
34 | 34 | |
|
35 |
// Note that this will only have an effect on |
|
|
36 |
|
|
|
35 | // Note that this will only have an effect on Fremantle. | |
|
36 | void setOrientation(ScreenOrientation orientation); | |
|
37 | 37 | |
|
38 | 38 | void showExpanded(); |
|
39 | 39 | |
|
40 | 40 | private: |
|
41 | explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); | |
|
42 | 41 | class QmlApplicationViewerPrivate *d; |
|
43 | 42 | }; |
|
44 | 43 | |
|
45 | 44 | QApplication *createApplication(int &argc, char **argv); |
|
46 | 45 | |
|
47 | 46 | #endif // QMLAPPLICATIONVIEWER_H |
@@ -1,200 +1,177 | |||
|
1 |
// checksum 0x |
|
|
1 | // checksum 0xbd34 version 0x80016 | |
|
2 | 2 | /* |
|
3 | 3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
4 | 4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
5 | 5 | code such as screen orientation handling. Also QML paths and debugging are |
|
6 | 6 | handled here. |
|
7 | 7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
8 | 8 | may offer an updated version of it. |
|
9 | 9 | */ |
|
10 | 10 | |
|
11 | 11 | #include "qmlapplicationviewer.h" |
|
12 | 12 | |
|
13 |
#include <Q |
|
|
14 |
#include <Q |
|
|
15 | #include <QtDeclarative/QDeclarativeComponent> | |
|
16 | #include <QtDeclarative/QDeclarativeEngine> | |
|
17 | #include <QtDeclarative/QDeclarativeContext> | |
|
13 | #include <QDir> | |
|
14 | #include <QFileInfo> | |
|
18 | 15 | #include <QApplication> |
|
16 | #include <QDeclarativeComponent> | |
|
17 | #include <QDeclarativeEngine> | |
|
18 | #include <QDeclarativeContext> | |
|
19 | 19 | |
|
20 | 20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
21 | 21 | |
|
22 | 22 | #ifdef HARMATTAN_BOOSTER |
|
23 | 23 | #include <MDeclarativeCache> |
|
24 | 24 | #endif |
|
25 | 25 | |
|
26 | 26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
27 | 27 | |
|
28 | 28 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
29 | 29 | |
|
30 | 30 | #if !defined(NO_JSDEBUGGER) |
|
31 | 31 | #include <jsdebuggeragent.h> |
|
32 | 32 | #endif |
|
33 | 33 | #if !defined(NO_QMLOBSERVER) |
|
34 | 34 | #include <qdeclarativeviewobserver.h> |
|
35 | 35 | #endif |
|
36 | 36 | |
|
37 | 37 | // Enable debugging before any QDeclarativeEngine is created |
|
38 | 38 | struct QmlJsDebuggingEnabler |
|
39 | 39 | { |
|
40 | 40 | QmlJsDebuggingEnabler() |
|
41 | 41 | { |
|
42 | 42 | QDeclarativeDebugHelper::enableDebugging(); |
|
43 | 43 | } |
|
44 | 44 | }; |
|
45 | 45 | |
|
46 | 46 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
47 | 47 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
48 | 48 | |
|
49 | 49 | #endif // QMLJSDEBUGGER |
|
50 | 50 | |
|
51 | 51 | class QmlApplicationViewerPrivate |
|
52 | 52 | { |
|
53 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} | |
|
54 | ||
|
55 | 53 | QString mainQmlFile; |
|
56 | QDeclarativeView *view; | |
|
57 | 54 | friend class QmlApplicationViewer; |
|
58 | QString adjustPath(const QString &path); | |
|
55 | static QString adjustPath(const QString &path); | |
|
59 | 56 | }; |
|
60 | 57 | |
|
61 | 58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
62 | 59 | { |
|
63 | #ifdef Q_OS_UNIX | |
|
64 | 60 | #ifdef Q_OS_MAC |
|
65 | 61 | if (!QDir::isAbsolutePath(path)) |
|
66 | return QCoreApplication::applicationDirPath() | |
|
67 | + QLatin1String("/../Resources/") + path; | |
|
68 | #else | |
|
69 | QString pathInInstallDir; | |
|
70 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); | |
|
71 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); | |
|
72 | ||
|
62 | return QString::fromLatin1("%1/../Resources/%2") | |
|
63 | .arg(QCoreApplication::applicationDirPath(), path); | |
|
64 | #elif defined(Q_OS_QNX) | |
|
65 | if (!QDir::isAbsolutePath(path)) | |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
|
67 | #elif !defined(Q_OS_ANDROID) | |
|
68 | QString pathInInstallDir = | |
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |
|
71 | return pathInInstallDir; | |
|
72 | pathInInstallDir = | |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
|
73 | 74 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | 75 | return pathInInstallDir; |
|
75 | #endif | |
|
76 | 76 | #endif |
|
77 | 77 | return path; |
|
78 | 78 | } |
|
79 | 79 | |
|
80 | 80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
81 | 81 | : QDeclarativeView(parent) |
|
82 |
, d(new QmlApplicationViewerPrivate( |
|
|
82 | , d(new QmlApplicationViewerPrivate()) | |
|
83 | 83 | { |
|
84 | 84 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
85 | 85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
86 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
|
87 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
|
88 | #if !defined(NO_JSDEBUGGER) | |
|
89 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); | |
|
90 | #endif | |
|
91 | #if !defined(NO_QMLOBSERVER) | |
|
92 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); | |
|
93 | #endif | |
|
94 | #endif | |
|
95 | } | |
|
96 | 86 | |
|
97 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) | |
|
98 | : QDeclarativeView(parent) | |
|
99 | , d(new QmlApplicationViewerPrivate(view)) | |
|
100 | { | |
|
101 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); | |
|
102 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
|
103 | 87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
104 | 88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
105 | 89 | #if !defined(NO_JSDEBUGGER) |
|
106 |
new QmlJSDebugger::JSDebuggerAgent( |
|
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
|
107 | 91 | #endif |
|
108 | 92 | #if !defined(NO_QMLOBSERVER) |
|
109 |
new QmlJSDebugger::QDeclarativeViewObserver( |
|
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
|
110 | 94 | #endif |
|
111 | 95 | #endif |
|
112 | 96 | } |
|
113 | 97 | |
|
114 | 98 | QmlApplicationViewer::~QmlApplicationViewer() |
|
115 | 99 | { |
|
116 | 100 | delete d; |
|
117 | 101 | } |
|
118 | 102 | |
|
119 | 103 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
120 | 104 | { |
|
121 | #ifdef HARMATTAN_BOOSTER | |
|
122 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); | |
|
123 | #else | |
|
124 | 105 | return new QmlApplicationViewer(); |
|
125 | #endif | |
|
126 | 106 | } |
|
127 | 107 | |
|
128 | 108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
129 | 109 | { |
|
130 |
d->mainQmlFile = |
|
|
131 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
|
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
|
111 | #ifdef Q_OS_ANDROID | |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
|
113 | #else | |
|
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
|
115 | #endif | |
|
132 | 116 | } |
|
133 | 117 | |
|
134 | 118 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
135 | 119 | { |
|
136 |
|
|
|
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
|
137 | 121 | } |
|
138 | 122 | |
|
139 |
|
|
|
140 | //{ | |
|
141 | //#if defined(Q_OS_SYMBIAN) | |
|
142 | // // If the version of Qt on the device is < 4.7.2, that attribute won't work | |
|
143 | // if (orientation != ScreenOrientationAuto) { | |
|
144 | // const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); | |
|
145 | // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { | |
|
146 | // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); | |
|
147 | // return; | |
|
148 |
|
|
|
149 | // } | |
|
150 | //#endif // Q_OS_SYMBIAN | |
|
151 | ||
|
152 | // Qt::WidgetAttribute attribute; | |
|
153 | // switch (orientation) { | |
|
154 | //#if QT_VERSION < 0x040702 | |
|
155 | // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
|
156 | // case ScreenOrientationLockPortrait: | |
|
157 | // attribute = static_cast<Qt::WidgetAttribute>(128); | |
|
158 | // break; | |
|
159 | // case ScreenOrientationLockLandscape: | |
|
160 | // attribute = static_cast<Qt::WidgetAttribute>(129); | |
|
161 | // break; | |
|
162 | // default: | |
|
163 | // case ScreenOrientationAuto: | |
|
164 | // attribute = static_cast<Qt::WidgetAttribute>(130); | |
|
165 | // break; | |
|
166 | //#else // QT_VERSION < 0x040702 | |
|
167 | // case ScreenOrientationLockPortrait: | |
|
168 | // attribute = Qt::WA_LockPortraitOrientation; | |
|
169 | // break; | |
|
170 | // case ScreenOrientationLockLandscape: | |
|
171 | // attribute = Qt::WA_LockLandscapeOrientation; | |
|
172 | // break; | |
|
173 | // default: | |
|
174 | // case ScreenOrientationAuto: | |
|
175 | // attribute = Qt::WA_AutoOrientation; | |
|
176 | // break; | |
|
177 | //#endif // QT_VERSION < 0x040702 | |
|
178 | // }; | |
|
179 | // setAttribute(attribute, true); | |
|
180 | //} | |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
|
124 | { | |
|
125 | #if QT_VERSION < 0x050000 | |
|
126 | Qt::WidgetAttribute attribute; | |
|
127 | switch (orientation) { | |
|
128 | #if QT_VERSION < 0x040702 | |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
|
130 | case ScreenOrientationLockPortrait: | |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
|
132 | break; | |
|
133 | case ScreenOrientationLockLandscape: | |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
|
135 | break; | |
|
136 | default: | |
|
137 | case ScreenOrientationAuto: | |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
|
139 | break; | |
|
140 | #else // QT_VERSION < 0x040702 | |
|
141 | case ScreenOrientationLockPortrait: | |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
|
143 | break; | |
|
144 | case ScreenOrientationLockLandscape: | |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
|
146 | break; | |
|
147 | default: | |
|
148 | case ScreenOrientationAuto: | |
|
149 | attribute = Qt::WA_AutoOrientation; | |
|
150 | break; | |
|
151 | #endif // QT_VERSION < 0x040702 | |
|
152 | }; | |
|
153 | setAttribute(attribute, true); | |
|
154 | #else // QT_VERSION < 0x050000 | |
|
155 | Q_UNUSED(orientation) | |
|
156 | #endif // QT_VERSION < 0x050000 | |
|
157 | } | |
|
181 | 158 | |
|
182 | 159 | void QmlApplicationViewer::showExpanded() |
|
183 | 160 | { |
|
184 |
#if defined( |
|
|
185 |
|
|
|
186 | #elif defined(Q_WS_MAEMO_5) | |
|
187 |
|
|
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
|
162 | showFullScreen(); | |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
|
164 | showMaximized(); | |
|
188 | 165 | #else |
|
189 |
|
|
|
166 | show(); | |
|
190 | 167 | #endif |
|
191 | 168 | } |
|
192 | 169 | |
|
193 | 170 | QApplication *createApplication(int &argc, char **argv) |
|
194 | 171 | { |
|
195 | 172 | #ifdef HARMATTAN_BOOSTER |
|
196 | 173 | return MDeclarativeCache::qApplication(argc, argv); |
|
197 | 174 | #else |
|
198 | 175 | return new QApplication(argc, argv); |
|
199 | 176 | #endif |
|
200 | 177 | } |
@@ -1,47 +1,46 | |||
|
1 |
// checksum 0x |
|
|
1 | // checksum 0xc67a version 0x80016 | |
|
2 | 2 | /* |
|
3 | 3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
4 | 4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
5 | 5 | code such as screen orientation handling. Also QML paths and debugging are |
|
6 | 6 | handled here. |
|
7 | 7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
8 | 8 | may offer an updated version of it. |
|
9 | 9 | */ |
|
10 | 10 | |
|
11 | 11 | #ifndef QMLAPPLICATIONVIEWER_H |
|
12 | 12 | #define QMLAPPLICATIONVIEWER_H |
|
13 | 13 | |
|
14 |
#include <Q |
|
|
14 | #include <QDeclarativeView> | |
|
15 | 15 | |
|
16 | 16 | class QmlApplicationViewer : public QDeclarativeView |
|
17 | 17 | { |
|
18 | 18 | Q_OBJECT |
|
19 | 19 | |
|
20 | 20 | public: |
|
21 | 21 | enum ScreenOrientation { |
|
22 | 22 | ScreenOrientationLockPortrait, |
|
23 | 23 | ScreenOrientationLockLandscape, |
|
24 | 24 | ScreenOrientationAuto |
|
25 | 25 | }; |
|
26 | 26 | |
|
27 | 27 | explicit QmlApplicationViewer(QWidget *parent = 0); |
|
28 | 28 | virtual ~QmlApplicationViewer(); |
|
29 | 29 | |
|
30 | 30 | static QmlApplicationViewer *create(); |
|
31 | 31 | |
|
32 | 32 | void setMainQmlFile(const QString &file); |
|
33 | 33 | void addImportPath(const QString &path); |
|
34 | 34 | |
|
35 |
// Note that this will only have an effect on |
|
|
36 |
|
|
|
35 | // Note that this will only have an effect on Fremantle. | |
|
36 | void setOrientation(ScreenOrientation orientation); | |
|
37 | 37 | |
|
38 | 38 | void showExpanded(); |
|
39 | 39 | |
|
40 | 40 | private: |
|
41 | explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); | |
|
42 | 41 | class QmlApplicationViewerPrivate *d; |
|
43 | 42 | }; |
|
44 | 43 | |
|
45 | 44 | QApplication *createApplication(int &argc, char **argv); |
|
46 | 45 | |
|
47 | 46 | #endif // QMLAPPLICATIONVIEWER_H |
@@ -1,200 +1,177 | |||
|
1 |
// checksum 0x |
|
|
1 | // checksum 0xbd34 version 0x80016 | |
|
2 | 2 | /* |
|
3 | 3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
4 | 4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
5 | 5 | code such as screen orientation handling. Also QML paths and debugging are |
|
6 | 6 | handled here. |
|
7 | 7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
8 | 8 | may offer an updated version of it. |
|
9 | 9 | */ |
|
10 | 10 | |
|
11 | 11 | #include "qmlapplicationviewer.h" |
|
12 | 12 | |
|
13 |
#include <Q |
|
|
14 |
#include <Q |
|
|
15 | #include <QtDeclarative/QDeclarativeComponent> | |
|
16 | #include <QtDeclarative/QDeclarativeEngine> | |
|
17 | #include <QtDeclarative/QDeclarativeContext> | |
|
13 | #include <QDir> | |
|
14 | #include <QFileInfo> | |
|
18 | 15 | #include <QApplication> |
|
16 | #include <QDeclarativeComponent> | |
|
17 | #include <QDeclarativeEngine> | |
|
18 | #include <QDeclarativeContext> | |
|
19 | 19 | |
|
20 | 20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
21 | 21 | |
|
22 | 22 | #ifdef HARMATTAN_BOOSTER |
|
23 | 23 | #include <MDeclarativeCache> |
|
24 | 24 | #endif |
|
25 | 25 | |
|
26 | 26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
27 | 27 | |
|
28 | 28 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
29 | 29 | |
|
30 | 30 | #if !defined(NO_JSDEBUGGER) |
|
31 | 31 | #include <jsdebuggeragent.h> |
|
32 | 32 | #endif |
|
33 | 33 | #if !defined(NO_QMLOBSERVER) |
|
34 | 34 | #include <qdeclarativeviewobserver.h> |
|
35 | 35 | #endif |
|
36 | 36 | |
|
37 | 37 | // Enable debugging before any QDeclarativeEngine is created |
|
38 | 38 | struct QmlJsDebuggingEnabler |
|
39 | 39 | { |
|
40 | 40 | QmlJsDebuggingEnabler() |
|
41 | 41 | { |
|
42 | 42 | QDeclarativeDebugHelper::enableDebugging(); |
|
43 | 43 | } |
|
44 | 44 | }; |
|
45 | 45 | |
|
46 | 46 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
47 | 47 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
48 | 48 | |
|
49 | 49 | #endif // QMLJSDEBUGGER |
|
50 | 50 | |
|
51 | 51 | class QmlApplicationViewerPrivate |
|
52 | 52 | { |
|
53 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} | |
|
54 | ||
|
55 | 53 | QString mainQmlFile; |
|
56 | QDeclarativeView *view; | |
|
57 | 54 | friend class QmlApplicationViewer; |
|
58 | QString adjustPath(const QString &path); | |
|
55 | static QString adjustPath(const QString &path); | |
|
59 | 56 | }; |
|
60 | 57 | |
|
61 | 58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
62 | 59 | { |
|
63 | #ifdef Q_OS_UNIX | |
|
64 | 60 | #ifdef Q_OS_MAC |
|
65 | 61 | if (!QDir::isAbsolutePath(path)) |
|
66 | return QCoreApplication::applicationDirPath() | |
|
67 | + QLatin1String("/../Resources/") + path; | |
|
68 | #else | |
|
69 | QString pathInInstallDir; | |
|
70 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); | |
|
71 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); | |
|
72 | ||
|
62 | return QString::fromLatin1("%1/../Resources/%2") | |
|
63 | .arg(QCoreApplication::applicationDirPath(), path); | |
|
64 | #elif defined(Q_OS_QNX) | |
|
65 | if (!QDir::isAbsolutePath(path)) | |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
|
67 | #elif !defined(Q_OS_ANDROID) | |
|
68 | QString pathInInstallDir = | |
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |
|
71 | return pathInInstallDir; | |
|
72 | pathInInstallDir = | |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
|
73 | 74 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | 75 | return pathInInstallDir; |
|
75 | #endif | |
|
76 | 76 | #endif |
|
77 | 77 | return path; |
|
78 | 78 | } |
|
79 | 79 | |
|
80 | 80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
81 | 81 | : QDeclarativeView(parent) |
|
82 |
, d(new QmlApplicationViewerPrivate( |
|
|
82 | , d(new QmlApplicationViewerPrivate()) | |
|
83 | 83 | { |
|
84 | 84 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
85 | 85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
86 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
|
87 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
|
88 | #if !defined(NO_JSDEBUGGER) | |
|
89 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); | |
|
90 | #endif | |
|
91 | #if !defined(NO_QMLOBSERVER) | |
|
92 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); | |
|
93 | #endif | |
|
94 | #endif | |
|
95 | } | |
|
96 | 86 | |
|
97 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) | |
|
98 | : QDeclarativeView(parent) | |
|
99 | , d(new QmlApplicationViewerPrivate(view)) | |
|
100 | { | |
|
101 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); | |
|
102 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
|
103 | 87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
104 | 88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
105 | 89 | #if !defined(NO_JSDEBUGGER) |
|
106 |
new QmlJSDebugger::JSDebuggerAgent( |
|
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
|
107 | 91 | #endif |
|
108 | 92 | #if !defined(NO_QMLOBSERVER) |
|
109 |
new QmlJSDebugger::QDeclarativeViewObserver( |
|
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
|
110 | 94 | #endif |
|
111 | 95 | #endif |
|
112 | 96 | } |
|
113 | 97 | |
|
114 | 98 | QmlApplicationViewer::~QmlApplicationViewer() |
|
115 | 99 | { |
|
116 | 100 | delete d; |
|
117 | 101 | } |
|
118 | 102 | |
|
119 | 103 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
120 | 104 | { |
|
121 | #ifdef HARMATTAN_BOOSTER | |
|
122 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); | |
|
123 | #else | |
|
124 | 105 | return new QmlApplicationViewer(); |
|
125 | #endif | |
|
126 | 106 | } |
|
127 | 107 | |
|
128 | 108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
129 | 109 | { |
|
130 |
d->mainQmlFile = |
|
|
131 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
|
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
|
111 | #ifdef Q_OS_ANDROID | |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
|
113 | #else | |
|
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
|
115 | #endif | |
|
132 | 116 | } |
|
133 | 117 | |
|
134 | 118 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
135 | 119 | { |
|
136 |
|
|
|
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
|
137 | 121 | } |
|
138 | 122 | |
|
139 |
|
|
|
140 | //{ | |
|
141 | //#if defined(Q_OS_SYMBIAN) | |
|
142 | // // If the version of Qt on the device is < 4.7.2, that attribute won't work | |
|
143 | // if (orientation != ScreenOrientationAuto) { | |
|
144 | // const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); | |
|
145 | // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { | |
|
146 | // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); | |
|
147 | // return; | |
|
148 |
|
|
|
149 | // } | |
|
150 | //#endif // Q_OS_SYMBIAN | |
|
151 | ||
|
152 | // Qt::WidgetAttribute attribute; | |
|
153 | // switch (orientation) { | |
|
154 | //#if QT_VERSION < 0x040702 | |
|
155 | // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
|
156 | // case ScreenOrientationLockPortrait: | |
|
157 | // attribute = static_cast<Qt::WidgetAttribute>(128); | |
|
158 | // break; | |
|
159 | // case ScreenOrientationLockLandscape: | |
|
160 | // attribute = static_cast<Qt::WidgetAttribute>(129); | |
|
161 | // break; | |
|
162 | // default: | |
|
163 | // case ScreenOrientationAuto: | |
|
164 | // attribute = static_cast<Qt::WidgetAttribute>(130); | |
|
165 | // break; | |
|
166 | //#else // QT_VERSION < 0x040702 | |
|
167 | // case ScreenOrientationLockPortrait: | |
|
168 | // attribute = Qt::WA_LockPortraitOrientation; | |
|
169 | // break; | |
|
170 | // case ScreenOrientationLockLandscape: | |
|
171 | // attribute = Qt::WA_LockLandscapeOrientation; | |
|
172 | // break; | |
|
173 | // default: | |
|
174 | // case ScreenOrientationAuto: | |
|
175 | // attribute = Qt::WA_AutoOrientation; | |
|
176 | // break; | |
|
177 | //#endif // QT_VERSION < 0x040702 | |
|
178 | // }; | |
|
179 | // setAttribute(attribute, true); | |
|
180 | //} | |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
|
124 | { | |
|
125 | #if QT_VERSION < 0x050000 | |
|
126 | Qt::WidgetAttribute attribute; | |
|
127 | switch (orientation) { | |
|
128 | #if QT_VERSION < 0x040702 | |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
|
130 | case ScreenOrientationLockPortrait: | |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
|
132 | break; | |
|
133 | case ScreenOrientationLockLandscape: | |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
|
135 | break; | |
|
136 | default: | |
|
137 | case ScreenOrientationAuto: | |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
|
139 | break; | |
|
140 | #else // QT_VERSION < 0x040702 | |
|
141 | case ScreenOrientationLockPortrait: | |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
|
143 | break; | |
|
144 | case ScreenOrientationLockLandscape: | |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
|
146 | break; | |
|
147 | default: | |
|
148 | case ScreenOrientationAuto: | |
|
149 | attribute = Qt::WA_AutoOrientation; | |
|
150 | break; | |
|
151 | #endif // QT_VERSION < 0x040702 | |
|
152 | }; | |
|
153 | setAttribute(attribute, true); | |
|
154 | #else // QT_VERSION < 0x050000 | |
|
155 | Q_UNUSED(orientation) | |
|
156 | #endif // QT_VERSION < 0x050000 | |
|
157 | } | |
|
181 | 158 | |
|
182 | 159 | void QmlApplicationViewer::showExpanded() |
|
183 | 160 | { |
|
184 |
#if defined( |
|
|
185 |
|
|
|
186 | #elif defined(Q_WS_MAEMO_5) | |
|
187 |
|
|
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
|
162 | showFullScreen(); | |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
|
164 | showMaximized(); | |
|
188 | 165 | #else |
|
189 |
|
|
|
166 | show(); | |
|
190 | 167 | #endif |
|
191 | 168 | } |
|
192 | 169 | |
|
193 | 170 | QApplication *createApplication(int &argc, char **argv) |
|
194 | 171 | { |
|
195 | 172 | #ifdef HARMATTAN_BOOSTER |
|
196 | 173 | return MDeclarativeCache::qApplication(argc, argv); |
|
197 | 174 | #else |
|
198 | 175 | return new QApplication(argc, argv); |
|
199 | 176 | #endif |
|
200 | 177 | } |
@@ -1,47 +1,46 | |||
|
1 |
// checksum 0x |
|
|
1 | // checksum 0xc67a version 0x80016 | |
|
2 | 2 | /* |
|
3 | 3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
4 | 4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
5 | 5 | code such as screen orientation handling. Also QML paths and debugging are |
|
6 | 6 | handled here. |
|
7 | 7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
8 | 8 | may offer an updated version of it. |
|
9 | 9 | */ |
|
10 | 10 | |
|
11 | 11 | #ifndef QMLAPPLICATIONVIEWER_H |
|
12 | 12 | #define QMLAPPLICATIONVIEWER_H |
|
13 | 13 | |
|
14 |
#include <Q |
|
|
14 | #include <QDeclarativeView> | |
|
15 | 15 | |
|
16 | 16 | class QmlApplicationViewer : public QDeclarativeView |
|
17 | 17 | { |
|
18 | 18 | Q_OBJECT |
|
19 | 19 | |
|
20 | 20 | public: |
|
21 | 21 | enum ScreenOrientation { |
|
22 | 22 | ScreenOrientationLockPortrait, |
|
23 | 23 | ScreenOrientationLockLandscape, |
|
24 | 24 | ScreenOrientationAuto |
|
25 | 25 | }; |
|
26 | 26 | |
|
27 | 27 | explicit QmlApplicationViewer(QWidget *parent = 0); |
|
28 | 28 | virtual ~QmlApplicationViewer(); |
|
29 | 29 | |
|
30 | 30 | static QmlApplicationViewer *create(); |
|
31 | 31 | |
|
32 | 32 | void setMainQmlFile(const QString &file); |
|
33 | 33 | void addImportPath(const QString &path); |
|
34 | 34 | |
|
35 |
// Note that this will only have an effect on |
|
|
36 |
|
|
|
35 | // Note that this will only have an effect on Fremantle. | |
|
36 | void setOrientation(ScreenOrientation orientation); | |
|
37 | 37 | |
|
38 | 38 | void showExpanded(); |
|
39 | 39 | |
|
40 | 40 | private: |
|
41 | explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); | |
|
42 | 41 | class QmlApplicationViewerPrivate *d; |
|
43 | 42 | }; |
|
44 | 43 | |
|
45 | 44 | QApplication *createApplication(int &argc, char **argv); |
|
46 | 45 | |
|
47 | 46 | #endif // QMLAPPLICATIONVIEWER_H |
@@ -1,200 +1,177 | |||
|
1 |
// checksum 0x |
|
|
2 | /* | |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
|
6 | handled here. | |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
|
8 | may offer an updated version of it. | |
|
9 | */ | |
|
10 | ||
|
11 | #include "qmlapplicationviewer.h" | |
|
12 | ||
|
13 |
#include <Q |
|
|
14 |
#include <Q |
|
|
15 | #include <QtDeclarative/QDeclarativeComponent> | |
|
16 |
#include <Q |
|
|
17 |
#include <Q |
|
|
18 |
#include <Q |
|
|
19 | ||
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |
|
21 | ||
|
22 | #ifdef HARMATTAN_BOOSTER | |
|
23 | #include <MDeclarativeCache> | |
|
24 | #endif | |
|
25 | ||
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
|
27 | ||
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |
|
29 | ||
|
30 | #if !defined(NO_JSDEBUGGER) | |
|
31 | #include <jsdebuggeragent.h> | |
|
32 | #endif | |
|
33 | #if !defined(NO_QMLOBSERVER) | |
|
34 | #include <qdeclarativeviewobserver.h> | |
|
35 | #endif | |
|
36 | ||
|
37 | // Enable debugging before any QDeclarativeEngine is created | |
|
38 | struct QmlJsDebuggingEnabler | |
|
39 | { | |
|
40 | QmlJsDebuggingEnabler() | |
|
41 | { | |
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |
|
43 | } | |
|
44 | }; | |
|
45 | ||
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |
|
48 | ||
|
49 | #endif // QMLJSDEBUGGER | |
|
50 | ||
|
51 | class QmlApplicationViewerPrivate | |
|
52 | { | |
|
53 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} | |
|
54 | ||
|
55 | QString mainQmlFile; | |
|
56 | QDeclarativeView *view; | |
|
57 | friend class QmlApplicationViewer; | |
|
58 |
|
|
|
59 | }; | |
|
60 | ||
|
61 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |
|
62 | { | |
|
63 | #ifdef Q_OS_UNIX | |
|
64 | #ifdef Q_OS_MAC | |
|
65 | if (!QDir::isAbsolutePath(path)) | |
|
66 | return QCoreApplication::applicationDirPath() | |
|
67 | + QLatin1String("/../Resources/") + path; | |
|
68 | #else | |
|
69 | QString pathInInstallDir; | |
|
70 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); | |
|
71 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); | |
|
72 | ||
|
73 | if (QFileInfo(pathInInstallDir).exists()) | |
|
74 | return pathInInstallDir; | |
|
75 | #endif | |
|
76 | #endif | |
|
77 | return path; | |
|
78 | } | |
|
79 | ||
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |
|
81 | : QDeclarativeView(parent) | |
|
82 |
, d(new QmlApplicationViewerPrivate( |
|
|
83 | { | |
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
|
86 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
|
87 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
|
88 | #if !defined(NO_JSDEBUGGER) | |
|
89 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); | |
|
90 | #endif | |
|
91 | #if !defined(NO_QMLOBSERVER) | |
|
92 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); | |
|
93 | #endif | |
|
94 | #endif | |
|
95 | } | |
|
96 | ||
|
97 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) | |
|
98 | : QDeclarativeView(parent) | |
|
99 | , d(new QmlApplicationViewerPrivate(view)) | |
|
100 | { | |
|
101 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); | |
|
102 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
|
103 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
|
104 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
|
105 | #if !defined(NO_JSDEBUGGER) | |
|
106 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); | |
|
107 | #endif | |
|
108 | #if !defined(NO_QMLOBSERVER) | |
|
109 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); | |
|
110 | #endif | |
|
111 | #endif | |
|
112 | } | |
|
113 | ||
|
114 | QmlApplicationViewer::~QmlApplicationViewer() | |
|
115 | { | |
|
116 | delete d; | |
|
117 | } | |
|
118 | ||
|
119 | QmlApplicationViewer *QmlApplicationViewer::create() | |
|
120 | { | |
|
121 | #ifdef HARMATTAN_BOOSTER | |
|
122 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); | |
|
123 | #else | |
|
124 | return new QmlApplicationViewer(); | |
|
125 | #endif | |
|
126 | } | |
|
127 | ||
|
128 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
|
129 | { | |
|
130 | d->mainQmlFile = d->adjustPath(file); | |
|
131 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
|
132 | } | |
|
133 | ||
|
134 | void QmlApplicationViewer::addImportPath(const QString &path) | |
|
135 | { | |
|
136 | d->view->engine()->addImportPath(d->adjustPath(path)); | |
|
137 | } | |
|
138 | ||
|
139 | //void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
|
140 | //{ | |
|
141 | //#if defined(Q_OS_SYMBIAN) | |
|
142 | // // If the version of Qt on the device is < 4.7.2, that attribute won't work | |
|
143 | // if (orientation != ScreenOrientationAuto) { | |
|
144 | // const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); | |
|
145 | // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { | |
|
146 | // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); | |
|
147 | // return; | |
|
148 | // } | |
|
149 | // } | |
|
150 | //#endif // Q_OS_SYMBIAN | |
|
151 | ||
|
152 | // Qt::WidgetAttribute attribute; | |
|
153 | // switch (orientation) { | |
|
154 |
// |
|
|
155 | // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
|
156 | // case ScreenOrientationLockPortrait: | |
|
157 | // attribute = static_cast<Qt::WidgetAttribute>(128); | |
|
158 | // break; | |
|
159 | // case ScreenOrientationLockLandscape: | |
|
160 | // attribute = static_cast<Qt::WidgetAttribute>(129); | |
|
161 | // break; | |
|
162 | // default: | |
|
163 | // case ScreenOrientationAuto: | |
|
164 | // attribute = static_cast<Qt::WidgetAttribute>(130); | |
|
165 | // break; | |
|
166 | //#else // QT_VERSION < 0x040702 | |
|
167 | // case ScreenOrientationLockPortrait: | |
|
168 | // attribute = Qt::WA_LockPortraitOrientation; | |
|
169 | // break; | |
|
170 | // case ScreenOrientationLockLandscape: | |
|
171 | // attribute = Qt::WA_LockLandscapeOrientation; | |
|
172 | // break; | |
|
173 | // default: | |
|
174 | // case ScreenOrientationAuto: | |
|
175 | // attribute = Qt::WA_AutoOrientation; | |
|
176 | // break; | |
|
177 | //#endif // QT_VERSION < 0x040702 | |
|
178 | // }; | |
|
179 | // setAttribute(attribute, true); | |
|
180 | //} | |
|
181 | ||
|
182 | void QmlApplicationViewer::showExpanded() | |
|
183 | { | |
|
184 | #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
|
185 | d->view->showFullScreen(); | |
|
186 | #elif defined(Q_WS_MAEMO_5) | |
|
187 | d->view->showMaximized(); | |
|
188 | #else | |
|
189 | d->view->show(); | |
|
190 | #endif | |
|
191 | } | |
|
192 | ||
|
193 | QApplication *createApplication(int &argc, char **argv) | |
|
194 | { | |
|
195 | #ifdef HARMATTAN_BOOSTER | |
|
196 | return MDeclarativeCache::qApplication(argc, argv); | |
|
197 | #else | |
|
198 | return new QApplication(argc, argv); | |
|
199 | #endif | |
|
200 | } | |
|
1 | // checksum 0xbd34 version 0x80016 | |
|
2 | /* | |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
|
6 | handled here. | |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
|
8 | may offer an updated version of it. | |
|
9 | */ | |
|
10 | ||
|
11 | #include "qmlapplicationviewer.h" | |
|
12 | ||
|
13 | #include <QDir> | |
|
14 | #include <QFileInfo> | |
|
15 | #include <QApplication> | |
|
16 | #include <QDeclarativeComponent> | |
|
17 | #include <QDeclarativeEngine> | |
|
18 | #include <QDeclarativeContext> | |
|
19 | ||
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |
|
21 | ||
|
22 | #ifdef HARMATTAN_BOOSTER | |
|
23 | #include <MDeclarativeCache> | |
|
24 | #endif | |
|
25 | ||
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
|
27 | ||
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |
|
29 | ||
|
30 | #if !defined(NO_JSDEBUGGER) | |
|
31 | #include <jsdebuggeragent.h> | |
|
32 | #endif | |
|
33 | #if !defined(NO_QMLOBSERVER) | |
|
34 | #include <qdeclarativeviewobserver.h> | |
|
35 | #endif | |
|
36 | ||
|
37 | // Enable debugging before any QDeclarativeEngine is created | |
|
38 | struct QmlJsDebuggingEnabler | |
|
39 | { | |
|
40 | QmlJsDebuggingEnabler() | |
|
41 | { | |
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |
|
43 | } | |
|
44 | }; | |
|
45 | ||
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |
|
48 | ||
|
49 | #endif // QMLJSDEBUGGER | |
|
50 | ||
|
51 | class QmlApplicationViewerPrivate | |
|
52 | { | |
|
53 | QString mainQmlFile; | |
|
54 | friend class QmlApplicationViewer; | |
|
55 | static QString adjustPath(const QString &path); | |
|
56 | }; | |
|
57 | ||
|
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |
|
59 | { | |
|
60 | #ifdef Q_OS_MAC | |
|
61 | if (!QDir::isAbsolutePath(path)) | |
|
62 | return QString::fromLatin1("%1/../Resources/%2") | |
|
63 | .arg(QCoreApplication::applicationDirPath(), path); | |
|
64 | #elif defined(Q_OS_QNX) | |
|
65 | if (!QDir::isAbsolutePath(path)) | |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
|
67 | #elif !defined(Q_OS_ANDROID) | |
|
68 | QString pathInInstallDir = | |
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |
|
71 | return pathInInstallDir; | |
|
72 | pathInInstallDir = | |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |
|
75 | return pathInInstallDir; | |
|
76 | #endif | |
|
77 | return path; | |
|
78 | } | |
|
79 | ||
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |
|
81 | : QDeclarativeView(parent) | |
|
82 | , d(new QmlApplicationViewerPrivate()) | |
|
83 | { | |
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
|
86 | ||
|
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
|
89 | #if !defined(NO_JSDEBUGGER) | |
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
|
91 | #endif | |
|
92 | #if !defined(NO_QMLOBSERVER) | |
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
|
94 | #endif | |
|
95 | #endif | |
|
96 | } | |
|
97 | ||
|
98 | QmlApplicationViewer::~QmlApplicationViewer() | |
|
99 | { | |
|
100 | delete d; | |
|
101 | } | |
|
102 | ||
|
103 | QmlApplicationViewer *QmlApplicationViewer::create() | |
|
104 | { | |
|
105 | return new QmlApplicationViewer(); | |
|
106 | } | |
|
107 | ||
|
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
|
109 | { | |
|
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
|
111 | #ifdef Q_OS_ANDROID | |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
|
113 | #else | |
|
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
|
115 | #endif | |
|
116 | } | |
|
117 | ||
|
118 | void QmlApplicationViewer::addImportPath(const QString &path) | |
|
119 | { | |
|
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
|
121 | } | |
|
122 | ||
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
|
124 | { | |
|
125 | #if QT_VERSION < 0x050000 | |
|
126 | Qt::WidgetAttribute attribute; | |
|
127 | switch (orientation) { | |
|
128 | #if QT_VERSION < 0x040702 | |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
|
130 | case ScreenOrientationLockPortrait: | |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
|
132 | break; | |
|
133 | case ScreenOrientationLockLandscape: | |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
|
135 | break; | |
|
136 | default: | |
|
137 | case ScreenOrientationAuto: | |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
|
139 | break; | |
|
140 | #else // QT_VERSION < 0x040702 | |
|
141 | case ScreenOrientationLockPortrait: | |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
|
143 | break; | |
|
144 | case ScreenOrientationLockLandscape: | |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
|
146 | break; | |
|
147 | default: | |
|
148 | case ScreenOrientationAuto: | |
|
149 | attribute = Qt::WA_AutoOrientation; | |
|
150 | break; | |
|
151 | #endif // QT_VERSION < 0x040702 | |
|
152 | }; | |
|
153 | setAttribute(attribute, true); | |
|
154 | #else // QT_VERSION < 0x050000 | |
|
155 | Q_UNUSED(orientation) | |
|
156 | #endif // QT_VERSION < 0x050000 | |
|
157 | } | |
|
158 | ||
|
159 | void QmlApplicationViewer::showExpanded() | |
|
160 | { | |
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
|
162 | showFullScreen(); | |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
|
164 | showMaximized(); | |
|
165 | #else | |
|
166 | show(); | |
|
167 | #endif | |
|
168 | } | |
|
169 | ||
|
170 | QApplication *createApplication(int &argc, char **argv) | |
|
171 | { | |
|
172 | #ifdef HARMATTAN_BOOSTER | |
|
173 | return MDeclarativeCache::qApplication(argc, argv); | |
|
174 | #else | |
|
175 | return new QApplication(argc, argv); | |
|
176 | #endif | |
|
177 | } |
@@ -1,47 +1,46 | |||
|
1 |
// checksum 0x |
|
|
2 | /* | |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
|
6 | handled here. | |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
|
8 | may offer an updated version of it. | |
|
9 | */ | |
|
10 | ||
|
11 | #ifndef QMLAPPLICATIONVIEWER_H | |
|
12 | #define QMLAPPLICATIONVIEWER_H | |
|
13 | ||
|
14 |
#include <Q |
|
|
15 | ||
|
16 | class QmlApplicationViewer : public QDeclarativeView | |
|
17 | { | |
|
18 | Q_OBJECT | |
|
19 | ||
|
20 | public: | |
|
21 | enum ScreenOrientation { | |
|
22 | ScreenOrientationLockPortrait, | |
|
23 | ScreenOrientationLockLandscape, | |
|
24 | ScreenOrientationAuto | |
|
25 | }; | |
|
26 | ||
|
27 | explicit QmlApplicationViewer(QWidget *parent = 0); | |
|
28 | virtual ~QmlApplicationViewer(); | |
|
29 | ||
|
30 | static QmlApplicationViewer *create(); | |
|
31 | ||
|
32 | void setMainQmlFile(const QString &file); | |
|
33 | void addImportPath(const QString &path); | |
|
34 | ||
|
35 |
// Note that this will only have an effect on |
|
|
36 |
|
|
|
37 | ||
|
38 | void showExpanded(); | |
|
39 | ||
|
40 | private: | |
|
41 | explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); | |
|
42 | class QmlApplicationViewerPrivate *d; | |
|
43 | }; | |
|
44 | ||
|
45 | QApplication *createApplication(int &argc, char **argv); | |
|
46 | ||
|
47 | #endif // QMLAPPLICATIONVIEWER_H | |
|
1 | // checksum 0xc67a version 0x80016 | |
|
2 | /* | |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
|
6 | handled here. | |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
|
8 | may offer an updated version of it. | |
|
9 | */ | |
|
10 | ||
|
11 | #ifndef QMLAPPLICATIONVIEWER_H | |
|
12 | #define QMLAPPLICATIONVIEWER_H | |
|
13 | ||
|
14 | #include <QDeclarativeView> | |
|
15 | ||
|
16 | class QmlApplicationViewer : public QDeclarativeView | |
|
17 | { | |
|
18 | Q_OBJECT | |
|
19 | ||
|
20 | public: | |
|
21 | enum ScreenOrientation { | |
|
22 | ScreenOrientationLockPortrait, | |
|
23 | ScreenOrientationLockLandscape, | |
|
24 | ScreenOrientationAuto | |
|
25 | }; | |
|
26 | ||
|
27 | explicit QmlApplicationViewer(QWidget *parent = 0); | |
|
28 | virtual ~QmlApplicationViewer(); | |
|
29 | ||
|
30 | static QmlApplicationViewer *create(); | |
|
31 | ||
|
32 | void setMainQmlFile(const QString &file); | |
|
33 | void addImportPath(const QString &path); | |
|
34 | ||
|
35 | // Note that this will only have an effect on Fremantle. | |
|
36 | void setOrientation(ScreenOrientation orientation); | |
|
37 | ||
|
38 | void showExpanded(); | |
|
39 | ||
|
40 | private: | |
|
41 | class QmlApplicationViewerPrivate *d; | |
|
42 | }; | |
|
43 | ||
|
44 | QApplication *createApplication(int &argc, char **argv); | |
|
45 | ||
|
46 | #endif // QMLAPPLICATIONVIEWER_H |
@@ -1,200 +1,177 | |||
|
1 |
// checksum 0x |
|
|
1 | // checksum 0xbd34 version 0x80016 | |
|
2 | 2 | /* |
|
3 | 3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
4 | 4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
5 | 5 | code such as screen orientation handling. Also QML paths and debugging are |
|
6 | 6 | handled here. |
|
7 | 7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
8 | 8 | may offer an updated version of it. |
|
9 | 9 | */ |
|
10 | 10 | |
|
11 | 11 | #include "qmlapplicationviewer.h" |
|
12 | 12 | |
|
13 |
#include <Q |
|
|
14 |
#include <Q |
|
|
15 | #include <QtDeclarative/QDeclarativeComponent> | |
|
16 | #include <QtDeclarative/QDeclarativeEngine> | |
|
17 | #include <QtDeclarative/QDeclarativeContext> | |
|
13 | #include <QDir> | |
|
14 | #include <QFileInfo> | |
|
18 | 15 | #include <QApplication> |
|
16 | #include <QDeclarativeComponent> | |
|
17 | #include <QDeclarativeEngine> | |
|
18 | #include <QDeclarativeContext> | |
|
19 | 19 | |
|
20 | 20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
21 | 21 | |
|
22 | 22 | #ifdef HARMATTAN_BOOSTER |
|
23 | 23 | #include <MDeclarativeCache> |
|
24 | 24 | #endif |
|
25 | 25 | |
|
26 | 26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
27 | 27 | |
|
28 | 28 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
29 | 29 | |
|
30 | 30 | #if !defined(NO_JSDEBUGGER) |
|
31 | 31 | #include <jsdebuggeragent.h> |
|
32 | 32 | #endif |
|
33 | 33 | #if !defined(NO_QMLOBSERVER) |
|
34 | 34 | #include <qdeclarativeviewobserver.h> |
|
35 | 35 | #endif |
|
36 | 36 | |
|
37 | 37 | // Enable debugging before any QDeclarativeEngine is created |
|
38 | 38 | struct QmlJsDebuggingEnabler |
|
39 | 39 | { |
|
40 | 40 | QmlJsDebuggingEnabler() |
|
41 | 41 | { |
|
42 | 42 | QDeclarativeDebugHelper::enableDebugging(); |
|
43 | 43 | } |
|
44 | 44 | }; |
|
45 | 45 | |
|
46 | 46 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
47 | 47 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
48 | 48 | |
|
49 | 49 | #endif // QMLJSDEBUGGER |
|
50 | 50 | |
|
51 | 51 | class QmlApplicationViewerPrivate |
|
52 | 52 | { |
|
53 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} | |
|
54 | ||
|
55 | 53 | QString mainQmlFile; |
|
56 | QDeclarativeView *view; | |
|
57 | 54 | friend class QmlApplicationViewer; |
|
58 | QString adjustPath(const QString &path); | |
|
55 | static QString adjustPath(const QString &path); | |
|
59 | 56 | }; |
|
60 | 57 | |
|
61 | 58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
62 | 59 | { |
|
63 | #ifdef Q_OS_UNIX | |
|
64 | 60 | #ifdef Q_OS_MAC |
|
65 | 61 | if (!QDir::isAbsolutePath(path)) |
|
66 | return QCoreApplication::applicationDirPath() | |
|
67 | + QLatin1String("/../Resources/") + path; | |
|
68 | #else | |
|
69 | QString pathInInstallDir; | |
|
70 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); | |
|
71 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); | |
|
72 | ||
|
62 | return QString::fromLatin1("%1/../Resources/%2") | |
|
63 | .arg(QCoreApplication::applicationDirPath(), path); | |
|
64 | #elif defined(Q_OS_QNX) | |
|
65 | if (!QDir::isAbsolutePath(path)) | |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
|
67 | #elif !defined(Q_OS_ANDROID) | |
|
68 | QString pathInInstallDir = | |
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |
|
71 | return pathInInstallDir; | |
|
72 | pathInInstallDir = | |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
|
73 | 74 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | 75 | return pathInInstallDir; |
|
75 | #endif | |
|
76 | 76 | #endif |
|
77 | 77 | return path; |
|
78 | 78 | } |
|
79 | 79 | |
|
80 | 80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
81 | 81 | : QDeclarativeView(parent) |
|
82 |
, d(new QmlApplicationViewerPrivate( |
|
|
82 | , d(new QmlApplicationViewerPrivate()) | |
|
83 | 83 | { |
|
84 | 84 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
85 | 85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
86 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
|
87 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
|
88 | #if !defined(NO_JSDEBUGGER) | |
|
89 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); | |
|
90 | #endif | |
|
91 | #if !defined(NO_QMLOBSERVER) | |
|
92 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); | |
|
93 | #endif | |
|
94 | #endif | |
|
95 | } | |
|
96 | 86 | |
|
97 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) | |
|
98 | : QDeclarativeView(parent) | |
|
99 | , d(new QmlApplicationViewerPrivate(view)) | |
|
100 | { | |
|
101 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); | |
|
102 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
|
103 | 87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
104 | 88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
105 | 89 | #if !defined(NO_JSDEBUGGER) |
|
106 |
new QmlJSDebugger::JSDebuggerAgent( |
|
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
|
107 | 91 | #endif |
|
108 | 92 | #if !defined(NO_QMLOBSERVER) |
|
109 |
new QmlJSDebugger::QDeclarativeViewObserver( |
|
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
|
110 | 94 | #endif |
|
111 | 95 | #endif |
|
112 | 96 | } |
|
113 | 97 | |
|
114 | 98 | QmlApplicationViewer::~QmlApplicationViewer() |
|
115 | 99 | { |
|
116 | 100 | delete d; |
|
117 | 101 | } |
|
118 | 102 | |
|
119 | 103 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
120 | 104 | { |
|
121 | #ifdef HARMATTAN_BOOSTER | |
|
122 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); | |
|
123 | #else | |
|
124 | 105 | return new QmlApplicationViewer(); |
|
125 | #endif | |
|
126 | 106 | } |
|
127 | 107 | |
|
128 | 108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
129 | 109 | { |
|
130 |
d->mainQmlFile = |
|
|
131 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
|
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
|
111 | #ifdef Q_OS_ANDROID | |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
|
113 | #else | |
|
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
|
115 | #endif | |
|
132 | 116 | } |
|
133 | 117 | |
|
134 | 118 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
135 | 119 | { |
|
136 |
|
|
|
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
|
137 | 121 | } |
|
138 | 122 | |
|
139 |
|
|
|
140 | //{ | |
|
141 | //#if defined(Q_OS_SYMBIAN) | |
|
142 | // // If the version of Qt on the device is < 4.7.2, that attribute won't work | |
|
143 | // if (orientation != ScreenOrientationAuto) { | |
|
144 | // const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); | |
|
145 | // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { | |
|
146 | // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); | |
|
147 | // return; | |
|
148 |
|
|
|
149 | // } | |
|
150 | //#endif // Q_OS_SYMBIAN | |
|
151 | ||
|
152 | // Qt::WidgetAttribute attribute; | |
|
153 | // switch (orientation) { | |
|
154 | //#if QT_VERSION < 0x040702 | |
|
155 | // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
|
156 | // case ScreenOrientationLockPortrait: | |
|
157 | // attribute = static_cast<Qt::WidgetAttribute>(128); | |
|
158 | // break; | |
|
159 | // case ScreenOrientationLockLandscape: | |
|
160 | // attribute = static_cast<Qt::WidgetAttribute>(129); | |
|
161 | // break; | |
|
162 | // default: | |
|
163 | // case ScreenOrientationAuto: | |
|
164 | // attribute = static_cast<Qt::WidgetAttribute>(130); | |
|
165 | // break; | |
|
166 | //#else // QT_VERSION < 0x040702 | |
|
167 | // case ScreenOrientationLockPortrait: | |
|
168 | // attribute = Qt::WA_LockPortraitOrientation; | |
|
169 | // break; | |
|
170 | // case ScreenOrientationLockLandscape: | |
|
171 | // attribute = Qt::WA_LockLandscapeOrientation; | |
|
172 | // break; | |
|
173 | // default: | |
|
174 | // case ScreenOrientationAuto: | |
|
175 | // attribute = Qt::WA_AutoOrientation; | |
|
176 | // break; | |
|
177 | //#endif // QT_VERSION < 0x040702 | |
|
178 | // }; | |
|
179 | // setAttribute(attribute, true); | |
|
180 | //} | |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
|
124 | { | |
|
125 | #if QT_VERSION < 0x050000 | |
|
126 | Qt::WidgetAttribute attribute; | |
|
127 | switch (orientation) { | |
|
128 | #if QT_VERSION < 0x040702 | |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
|
130 | case ScreenOrientationLockPortrait: | |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
|
132 | break; | |
|
133 | case ScreenOrientationLockLandscape: | |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
|
135 | break; | |
|
136 | default: | |
|
137 | case ScreenOrientationAuto: | |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
|
139 | break; | |
|
140 | #else // QT_VERSION < 0x040702 | |
|
141 | case ScreenOrientationLockPortrait: | |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
|
143 | break; | |
|
144 | case ScreenOrientationLockLandscape: | |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
|
146 | break; | |
|
147 | default: | |
|
148 | case ScreenOrientationAuto: | |
|
149 | attribute = Qt::WA_AutoOrientation; | |
|
150 | break; | |
|
151 | #endif // QT_VERSION < 0x040702 | |
|
152 | }; | |
|
153 | setAttribute(attribute, true); | |
|
154 | #else // QT_VERSION < 0x050000 | |
|
155 | Q_UNUSED(orientation) | |
|
156 | #endif // QT_VERSION < 0x050000 | |
|
157 | } | |
|
181 | 158 | |
|
182 | 159 | void QmlApplicationViewer::showExpanded() |
|
183 | 160 | { |
|
184 |
#if defined( |
|
|
185 |
|
|
|
186 | #elif defined(Q_WS_MAEMO_5) | |
|
187 |
|
|
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
|
162 | showFullScreen(); | |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
|
164 | showMaximized(); | |
|
188 | 165 | #else |
|
189 |
|
|
|
166 | show(); | |
|
190 | 167 | #endif |
|
191 | 168 | } |
|
192 | 169 | |
|
193 | 170 | QApplication *createApplication(int &argc, char **argv) |
|
194 | 171 | { |
|
195 | 172 | #ifdef HARMATTAN_BOOSTER |
|
196 | 173 | return MDeclarativeCache::qApplication(argc, argv); |
|
197 | 174 | #else |
|
198 | 175 | return new QApplication(argc, argv); |
|
199 | 176 | #endif |
|
200 | 177 | } |
@@ -1,47 +1,46 | |||
|
1 |
// checksum 0x |
|
|
1 | // checksum 0xc67a version 0x80016 | |
|
2 | 2 | /* |
|
3 | 3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
4 | 4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
5 | 5 | code such as screen orientation handling. Also QML paths and debugging are |
|
6 | 6 | handled here. |
|
7 | 7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
8 | 8 | may offer an updated version of it. |
|
9 | 9 | */ |
|
10 | 10 | |
|
11 | 11 | #ifndef QMLAPPLICATIONVIEWER_H |
|
12 | 12 | #define QMLAPPLICATIONVIEWER_H |
|
13 | 13 | |
|
14 |
#include <Q |
|
|
14 | #include <QDeclarativeView> | |
|
15 | 15 | |
|
16 | 16 | class QmlApplicationViewer : public QDeclarativeView |
|
17 | 17 | { |
|
18 | 18 | Q_OBJECT |
|
19 | 19 | |
|
20 | 20 | public: |
|
21 | 21 | enum ScreenOrientation { |
|
22 | 22 | ScreenOrientationLockPortrait, |
|
23 | 23 | ScreenOrientationLockLandscape, |
|
24 | 24 | ScreenOrientationAuto |
|
25 | 25 | }; |
|
26 | 26 | |
|
27 | 27 | explicit QmlApplicationViewer(QWidget *parent = 0); |
|
28 | 28 | virtual ~QmlApplicationViewer(); |
|
29 | 29 | |
|
30 | 30 | static QmlApplicationViewer *create(); |
|
31 | 31 | |
|
32 | 32 | void setMainQmlFile(const QString &file); |
|
33 | 33 | void addImportPath(const QString &path); |
|
34 | 34 | |
|
35 |
// Note that this will only have an effect on |
|
|
36 |
|
|
|
35 | // Note that this will only have an effect on Fremantle. | |
|
36 | void setOrientation(ScreenOrientation orientation); | |
|
37 | 37 | |
|
38 | 38 | void showExpanded(); |
|
39 | 39 | |
|
40 | 40 | private: |
|
41 | explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); | |
|
42 | 41 | class QmlApplicationViewerPrivate *d; |
|
43 | 42 | }; |
|
44 | 43 | |
|
45 | 44 | QApplication *createApplication(int &argc, char **argv); |
|
46 | 45 | |
|
47 | 46 | #endif // QMLAPPLICATIONVIEWER_H |
@@ -1,173 +1,177 | |||
|
1 |
// checksum 0x |
|
|
1 | // checksum 0xbd34 version 0x80016 | |
|
2 | 2 | /* |
|
3 | 3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
4 | 4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
5 | 5 | code such as screen orientation handling. Also QML paths and debugging are |
|
6 | 6 | handled here. |
|
7 | 7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
8 | 8 | may offer an updated version of it. |
|
9 | 9 | */ |
|
10 | 10 | |
|
11 | 11 | #include "qmlapplicationviewer.h" |
|
12 | 12 | |
|
13 | 13 | #include <QDir> |
|
14 | 14 | #include <QFileInfo> |
|
15 | 15 | #include <QApplication> |
|
16 |
#include <Q |
|
|
17 |
#include <Q |
|
|
18 |
#include <Q |
|
|
16 | #include <QDeclarativeComponent> | |
|
17 | #include <QDeclarativeEngine> | |
|
18 | #include <QDeclarativeContext> | |
|
19 | ||
|
19 | 20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
20 | 21 | |
|
21 | 22 | #ifdef HARMATTAN_BOOSTER |
|
22 | 23 | #include <MDeclarativeCache> |
|
23 | 24 | #endif |
|
24 | 25 | |
|
25 | 26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
26 | 27 | |
|
27 | 28 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
28 | 29 | |
|
29 | 30 | #if !defined(NO_JSDEBUGGER) |
|
30 | 31 | #include <jsdebuggeragent.h> |
|
31 | 32 | #endif |
|
32 | 33 | #if !defined(NO_QMLOBSERVER) |
|
33 | 34 | #include <qdeclarativeviewobserver.h> |
|
34 | 35 | #endif |
|
35 | 36 | |
|
36 | 37 | // Enable debugging before any QDeclarativeEngine is created |
|
37 | 38 | struct QmlJsDebuggingEnabler |
|
38 | 39 | { |
|
39 | 40 | QmlJsDebuggingEnabler() |
|
40 | 41 | { |
|
41 | 42 | QDeclarativeDebugHelper::enableDebugging(); |
|
42 | 43 | } |
|
43 | 44 | }; |
|
44 | 45 | |
|
45 | 46 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
46 | 47 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
47 | 48 | |
|
48 | 49 | #endif // QMLJSDEBUGGER |
|
49 | 50 | |
|
50 | 51 | class QmlApplicationViewerPrivate |
|
51 | 52 | { |
|
52 | 53 | QString mainQmlFile; |
|
53 | 54 | friend class QmlApplicationViewer; |
|
54 | 55 | static QString adjustPath(const QString &path); |
|
55 | 56 | }; |
|
56 | 57 | |
|
57 | 58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
58 | 59 | { |
|
59 | #ifdef Q_OS_UNIX | |
|
60 | 60 | #ifdef Q_OS_MAC |
|
61 | 61 | if (!QDir::isAbsolutePath(path)) |
|
62 | 62 | return QString::fromLatin1("%1/../Resources/%2") |
|
63 | 63 | .arg(QCoreApplication::applicationDirPath(), path); |
|
64 | #else | |
|
65 | const QString pathInInstallDir = | |
|
64 | #elif defined(Q_OS_QNX) | |
|
65 | if (!QDir::isAbsolutePath(path)) | |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
|
67 | #elif !defined(Q_OS_ANDROID) | |
|
68 | QString pathInInstallDir = | |
|
66 | 69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); |
|
67 | 70 | if (QFileInfo(pathInInstallDir).exists()) |
|
68 | 71 | return pathInInstallDir; |
|
69 | #endif | |
|
72 | pathInInstallDir = | |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |
|
75 | return pathInInstallDir; | |
|
70 | 76 | #endif |
|
71 | 77 | return path; |
|
72 | 78 | } |
|
73 | 79 | |
|
74 | 80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
75 | 81 | : QDeclarativeView(parent) |
|
76 | 82 | , d(new QmlApplicationViewerPrivate()) |
|
77 | 83 | { |
|
78 | 84 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
79 | 85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
86 | ||
|
80 | 87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
81 | 88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
82 | 89 | #if !defined(NO_JSDEBUGGER) |
|
83 | 90 | new QmlJSDebugger::JSDebuggerAgent(engine()); |
|
84 | 91 | #endif |
|
85 | 92 | #if !defined(NO_QMLOBSERVER) |
|
86 | 93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); |
|
87 | 94 | #endif |
|
88 | 95 | #endif |
|
89 | 96 | } |
|
90 | 97 | |
|
91 | 98 | QmlApplicationViewer::~QmlApplicationViewer() |
|
92 | 99 | { |
|
93 | 100 | delete d; |
|
94 | 101 | } |
|
95 | 102 | |
|
96 | 103 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
97 | 104 | { |
|
98 | 105 | return new QmlApplicationViewer(); |
|
99 | 106 | } |
|
100 | 107 | |
|
101 | 108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
102 | 109 | { |
|
103 | 110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); |
|
111 | #ifdef Q_OS_ANDROID | |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
|
113 | #else | |
|
104 | 114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
115 | #endif | |
|
105 | 116 | } |
|
106 | 117 | |
|
107 | 118 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
108 | 119 | { |
|
109 | 120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); |
|
110 | 121 | } |
|
111 | 122 | |
|
112 |
|
|
|
113 | //{ | |
|
114 | //#if defined(Q_OS_SYMBIAN) | |
|
115 | // // If the version of Qt on the device is < 4.7.2, that attribute won't work | |
|
116 | // if (orientation != ScreenOrientationAuto) { | |
|
117 | // const QStringList v = QString::fromLatin1(qVersion()).split(QLatin1Char('.')); | |
|
118 | // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { | |
|
119 | // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); | |
|
120 | // return; | |
|
121 |
|
|
|
122 | // } | |
|
123 | //#endif // Q_OS_SYMBIAN | |
|
124 | ||
|
125 | // Qt::WidgetAttribute attribute; | |
|
126 | // switch (orientation) { | |
|
127 | //#if QT_VERSION < 0x040702 | |
|
128 | // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
|
129 | // case ScreenOrientationLockPortrait: | |
|
130 | // attribute = static_cast<Qt::WidgetAttribute>(128); | |
|
131 | // break; | |
|
132 | // case ScreenOrientationLockLandscape: | |
|
133 | // attribute = static_cast<Qt::WidgetAttribute>(129); | |
|
134 | // break; | |
|
135 | // default: | |
|
136 | // case ScreenOrientationAuto: | |
|
137 | // attribute = static_cast<Qt::WidgetAttribute>(130); | |
|
138 | // break; | |
|
139 | //#else // QT_VERSION < 0x040702 | |
|
140 | // case ScreenOrientationLockPortrait: | |
|
141 | // attribute = Qt::WA_LockPortraitOrientation; | |
|
142 | // break; | |
|
143 | // case ScreenOrientationLockLandscape: | |
|
144 | // attribute = Qt::WA_LockLandscapeOrientation; | |
|
145 | // break; | |
|
146 | // default: | |
|
147 | // case ScreenOrientationAuto: | |
|
148 | // attribute = Qt::WA_AutoOrientation; | |
|
149 | // break; | |
|
150 | //#endif // QT_VERSION < 0x040702 | |
|
151 | // }; | |
|
152 | // setAttribute(attribute, true); | |
|
153 | //} | |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
|
124 | { | |
|
125 | #if QT_VERSION < 0x050000 | |
|
126 | Qt::WidgetAttribute attribute; | |
|
127 | switch (orientation) { | |
|
128 | #if QT_VERSION < 0x040702 | |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
|
130 | case ScreenOrientationLockPortrait: | |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
|
132 | break; | |
|
133 | case ScreenOrientationLockLandscape: | |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
|
135 | break; | |
|
136 | default: | |
|
137 | case ScreenOrientationAuto: | |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
|
139 | break; | |
|
140 | #else // QT_VERSION < 0x040702 | |
|
141 | case ScreenOrientationLockPortrait: | |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
|
143 | break; | |
|
144 | case ScreenOrientationLockLandscape: | |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
|
146 | break; | |
|
147 | default: | |
|
148 | case ScreenOrientationAuto: | |
|
149 | attribute = Qt::WA_AutoOrientation; | |
|
150 | break; | |
|
151 | #endif // QT_VERSION < 0x040702 | |
|
152 | }; | |
|
153 | setAttribute(attribute, true); | |
|
154 | #else // QT_VERSION < 0x050000 | |
|
155 | Q_UNUSED(orientation) | |
|
156 | #endif // QT_VERSION < 0x050000 | |
|
157 | } | |
|
154 | 158 | |
|
155 | 159 | void QmlApplicationViewer::showExpanded() |
|
156 | 160 | { |
|
157 |
#if defined( |
|
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
|
158 | 162 | showFullScreen(); |
|
159 | #elif defined(Q_WS_MAEMO_5) | |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
|
160 | 164 | showMaximized(); |
|
161 | 165 | #else |
|
162 | 166 | show(); |
|
163 | 167 | #endif |
|
164 | 168 | } |
|
165 | 169 | |
|
166 | 170 | QApplication *createApplication(int &argc, char **argv) |
|
167 | 171 | { |
|
168 | 172 | #ifdef HARMATTAN_BOOSTER |
|
169 | 173 | return MDeclarativeCache::qApplication(argc, argv); |
|
170 | 174 | #else |
|
171 | 175 | return new QApplication(argc, argv); |
|
172 | 176 | #endif |
|
173 | 177 | } |
@@ -1,46 +1,46 | |||
|
1 |
// checksum 0x |
|
|
1 | // checksum 0xc67a version 0x80016 | |
|
2 | 2 | /* |
|
3 | 3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
4 | 4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
5 | 5 | code such as screen orientation handling. Also QML paths and debugging are |
|
6 | 6 | handled here. |
|
7 | 7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
8 | 8 | may offer an updated version of it. |
|
9 | 9 | */ |
|
10 | 10 | |
|
11 | 11 | #ifndef QMLAPPLICATIONVIEWER_H |
|
12 | 12 | #define QMLAPPLICATIONVIEWER_H |
|
13 | 13 | |
|
14 |
#include <Q |
|
|
14 | #include <QDeclarativeView> | |
|
15 | 15 | |
|
16 | 16 | class QmlApplicationViewer : public QDeclarativeView |
|
17 | 17 | { |
|
18 | 18 | Q_OBJECT |
|
19 | 19 | |
|
20 | 20 | public: |
|
21 | 21 | enum ScreenOrientation { |
|
22 | 22 | ScreenOrientationLockPortrait, |
|
23 | 23 | ScreenOrientationLockLandscape, |
|
24 | 24 | ScreenOrientationAuto |
|
25 | 25 | }; |
|
26 | 26 | |
|
27 | 27 | explicit QmlApplicationViewer(QWidget *parent = 0); |
|
28 | 28 | virtual ~QmlApplicationViewer(); |
|
29 | 29 | |
|
30 | 30 | static QmlApplicationViewer *create(); |
|
31 | 31 | |
|
32 | 32 | void setMainQmlFile(const QString &file); |
|
33 | 33 | void addImportPath(const QString &path); |
|
34 | 34 | |
|
35 |
// Note that this will only have an effect on |
|
|
36 |
|
|
|
35 | // Note that this will only have an effect on Fremantle. | |
|
36 | void setOrientation(ScreenOrientation orientation); | |
|
37 | 37 | |
|
38 | 38 | void showExpanded(); |
|
39 | 39 | |
|
40 | 40 | private: |
|
41 | 41 | class QmlApplicationViewerPrivate *d; |
|
42 | 42 | }; |
|
43 | 43 | |
|
44 | 44 | QApplication *createApplication(int &argc, char **argv); |
|
45 | 45 | |
|
46 | 46 | #endif // QMLAPPLICATIONVIEWER_H |
@@ -1,148 +1,169 | |||
|
1 |
# checksum 0x |
|
|
1 | # checksum 0x77b version 0x80016 | |
|
2 | 2 | # This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | 3 | # The code below adds the QmlApplicationViewer to the project and handles the |
|
4 | 4 | # activation of QML debugging. |
|
5 | 5 | # It is recommended not to modify this file, since newer versions of Qt Creator |
|
6 | 6 | # may offer an updated version of it. |
|
7 | 7 | |
|
8 | 8 | QT += declarative |
|
9 | 9 | |
|
10 | 10 | SOURCES += $$PWD/qmlapplicationviewer.cpp |
|
11 | 11 | HEADERS += $$PWD/qmlapplicationviewer.h |
|
12 | 12 | INCLUDEPATH += $$PWD |
|
13 | 13 | |
|
14 | 14 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set |
|
15 | 15 | !isEmpty(QMLJSDEBUGGER_PATH) { |
|
16 | 16 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) |
|
17 | 17 | } else { |
|
18 | 18 | DEFINES -= QMLJSDEBUGGER |
|
19 | 19 | } |
|
20 | 20 | |
|
21 | 21 | contains(CONFIG,qdeclarative-boostable):contains(MEEGO_EDITION,harmattan) { |
|
22 | 22 | DEFINES += HARMATTAN_BOOSTER |
|
23 | 23 | } |
|
24 | 24 | # This file was generated by an application wizard of Qt Creator. |
|
25 |
# The code below handles deployment to |
|
|
25 | # The code below handles deployment to Android and Maemo, aswell as copying | |
|
26 | 26 | # of the application data to shadow build directories on desktop. |
|
27 | 27 | # It is recommended not to modify this file, since newer versions of Qt Creator |
|
28 | 28 | # may offer an updated version of it. |
|
29 | 29 | |
|
30 | 30 | defineTest(qtcAddDeployment) { |
|
31 | 31 | for(deploymentfolder, DEPLOYMENTFOLDERS) { |
|
32 | 32 | item = item$${deploymentfolder} |
|
33 | itemsources = $${item}.sources | |
|
33 | greaterThan(QT_MAJOR_VERSION, 4) { | |
|
34 | itemsources = $${item}.files | |
|
35 | } else { | |
|
36 | itemsources = $${item}.sources | |
|
37 | } | |
|
34 | 38 | $$itemsources = $$eval($${deploymentfolder}.source) |
|
35 | 39 | itempath = $${item}.path |
|
36 | 40 | $$itempath= $$eval($${deploymentfolder}.target) |
|
37 | 41 | export($$itemsources) |
|
38 | 42 | export($$itempath) |
|
39 | 43 | DEPLOYMENT += $$item |
|
40 | 44 | } |
|
41 | 45 | |
|
42 | 46 | MAINPROFILEPWD = $$PWD |
|
43 | 47 | |
|
44 | symbian { | |
|
45 | isEmpty(ICON):exists($${TARGET}.svg):ICON = $${TARGET}.svg | |
|
46 | isEmpty(TARGET.EPOCHEAPSIZE):TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 | |
|
48 | android { | |
|
49 | for(deploymentfolder, DEPLOYMENTFOLDERS) { | |
|
50 | item = item$${deploymentfolder} | |
|
51 | itemfiles = $${item}.files | |
|
52 | $$itemfiles = $$eval($${deploymentfolder}.source) | |
|
53 | itempath = $${item}.path | |
|
54 | $$itempath = /assets/$$eval($${deploymentfolder}.target) | |
|
55 | export($$itemfiles) | |
|
56 | export($$itempath) | |
|
57 | INSTALLS += $$item | |
|
58 | } | |
|
59 | ||
|
60 | x86 { | |
|
61 | target.path = /libs/x86 | |
|
62 | } else: armeabi-v7a { | |
|
63 | target.path = /libs/armeabi-v7a | |
|
64 | } else { | |
|
65 | target.path = /libs/armeabi | |
|
66 | } | |
|
67 | ||
|
68 | export(target.path) | |
|
69 | INSTALLS += target | |
|
47 | 70 | } else:win32 { |
|
48 | 71 | copyCommand = |
|
49 | 72 | for(deploymentfolder, DEPLOYMENTFOLDERS) { |
|
50 | 73 | source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source) |
|
51 | 74 | source = $$replace(source, /, \\) |
|
52 | 75 | sourcePathSegments = $$split(source, \\) |
|
53 | 76 | target = $$OUT_PWD/$$eval($${deploymentfolder}.target)/$$last(sourcePathSegments) |
|
54 | 77 | target = $$replace(target, /, \\) |
|
55 | 78 | target ~= s,\\\\\\.?\\\\,\\, |
|
56 | 79 | !isEqual(source,$$target) { |
|
57 | 80 | !isEmpty(copyCommand):copyCommand += && |
|
58 | 81 | isEqual(QMAKE_DIR_SEP, \\) { |
|
59 | 82 | copyCommand += $(COPY_DIR) \"$$source\" \"$$target\" |
|
60 | 83 | } else { |
|
61 | 84 | source = $$replace(source, \\\\, /) |
|
62 | 85 | target = $$OUT_PWD/$$eval($${deploymentfolder}.target) |
|
63 | 86 | target = $$replace(target, \\\\, /) |
|
64 | 87 | copyCommand += test -d \"$$target\" || mkdir -p \"$$target\" && cp -r \"$$source\" \"$$target\" |
|
65 | 88 | } |
|
66 | 89 | } |
|
67 | 90 | } |
|
68 | 91 | !isEmpty(copyCommand) { |
|
69 | 92 | copyCommand = @echo Copying application data... && $$copyCommand |
|
70 | 93 | copydeploymentfolders.commands = $$copyCommand |
|
71 | 94 | first.depends = $(first) copydeploymentfolders |
|
72 | 95 | export(first.depends) |
|
73 | 96 | export(copydeploymentfolders.commands) |
|
74 | 97 | QMAKE_EXTRA_TARGETS += first copydeploymentfolders |
|
75 | 98 | } |
|
76 | 99 | } else:unix { |
|
77 | 100 | maemo5 { |
|
78 | 101 | desktopfile.files = $${TARGET}.desktop |
|
79 | 102 | desktopfile.path = /usr/share/applications/hildon |
|
80 | 103 | icon.files = $${TARGET}64.png |
|
81 | 104 | icon.path = /usr/share/icons/hicolor/64x64/apps |
|
82 | 105 | } else:!isEmpty(MEEGO_VERSION_MAJOR) { |
|
83 | 106 | desktopfile.files = $${TARGET}_harmattan.desktop |
|
84 | 107 | desktopfile.path = /usr/share/applications |
|
85 | 108 | icon.files = $${TARGET}80.png |
|
86 | 109 | icon.path = /usr/share/icons/hicolor/80x80/apps |
|
87 | 110 | } else { # Assumed to be a Desktop Unix |
|
88 | 111 | copyCommand = |
|
89 | 112 | for(deploymentfolder, DEPLOYMENTFOLDERS) { |
|
90 | 113 | source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source) |
|
91 | 114 | source = $$replace(source, \\\\, /) |
|
92 | 115 | macx { |
|
93 | 116 | target = $$OUT_PWD/$${TARGET}.app/Contents/Resources/$$eval($${deploymentfolder}.target) |
|
94 | 117 | } else { |
|
95 | 118 | target = $$OUT_PWD/$$eval($${deploymentfolder}.target) |
|
96 | 119 | } |
|
97 | 120 | target = $$replace(target, \\\\, /) |
|
98 | 121 | sourcePathSegments = $$split(source, /) |
|
99 | 122 | targetFullPath = $$target/$$last(sourcePathSegments) |
|
100 | 123 | targetFullPath ~= s,/\\.?/,/, |
|
101 | 124 | !isEqual(source,$$targetFullPath) { |
|
102 | 125 | !isEmpty(copyCommand):copyCommand += && |
|
103 | 126 | copyCommand += $(MKDIR) \"$$target\" |
|
104 | 127 | copyCommand += && $(COPY_DIR) \"$$source\" \"$$target\" |
|
105 | 128 | } |
|
106 | 129 | } |
|
107 | 130 | !isEmpty(copyCommand) { |
|
108 | 131 | copyCommand = @echo Copying application data... && $$copyCommand |
|
109 | 132 | copydeploymentfolders.commands = $$copyCommand |
|
110 | 133 | first.depends = $(first) copydeploymentfolders |
|
111 | 134 | export(first.depends) |
|
112 | 135 | export(copydeploymentfolders.commands) |
|
113 | 136 | QMAKE_EXTRA_TARGETS += first copydeploymentfolders |
|
114 | 137 | } |
|
115 | 138 | } |
|
116 | 139 | installPrefix = /opt/$${TARGET} |
|
117 | 140 | for(deploymentfolder, DEPLOYMENTFOLDERS) { |
|
118 | 141 | item = item$${deploymentfolder} |
|
119 | 142 | itemfiles = $${item}.files |
|
120 | 143 | $$itemfiles = $$eval($${deploymentfolder}.source) |
|
121 | 144 | itempath = $${item}.path |
|
122 | 145 | $$itempath = $${installPrefix}/$$eval($${deploymentfolder}.target) |
|
123 | 146 | export($$itemfiles) |
|
124 | 147 | export($$itempath) |
|
125 | 148 | INSTALLS += $$item |
|
126 | 149 | } |
|
127 | 150 | |
|
128 | 151 | !isEmpty(desktopfile.path) { |
|
129 | 152 | export(icon.files) |
|
130 | 153 | export(icon.path) |
|
131 | 154 | export(desktopfile.files) |
|
132 | 155 | export(desktopfile.path) |
|
133 | 156 | INSTALLS += icon desktopfile |
|
134 | 157 | } |
|
135 | 158 | |
|
136 | 159 | target.path = $${installPrefix}/bin |
|
137 | 160 | export(target.path) |
|
138 | 161 | INSTALLS += target |
|
139 | 162 | } |
|
140 | 163 | |
|
141 | 164 | export (ICON) |
|
142 | 165 | export (INSTALLS) |
|
143 | 166 | export (DEPLOYMENT) |
|
144 | export (TARGET.EPOCHEAPSIZE) | |
|
145 | export (TARGET.CAPABILITY) | |
|
146 | 167 | export (LIBS) |
|
147 | 168 | export (QMAKE_EXTRA_TARGETS) |
|
148 | 169 | } |
@@ -1,200 +1,177 | |||
|
1 |
// checksum 0x |
|
|
1 | // checksum 0xbd34 version 0x80016 | |
|
2 | 2 | /* |
|
3 | 3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
4 | 4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
5 | 5 | code such as screen orientation handling. Also QML paths and debugging are |
|
6 | 6 | handled here. |
|
7 | 7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
8 | 8 | may offer an updated version of it. |
|
9 | 9 | */ |
|
10 | 10 | |
|
11 | 11 | #include "qmlapplicationviewer.h" |
|
12 | 12 | |
|
13 |
#include <Q |
|
|
14 |
#include <Q |
|
|
15 | #include <QtDeclarative/QDeclarativeComponent> | |
|
16 | #include <QtDeclarative/QDeclarativeEngine> | |
|
17 | #include <QtDeclarative/QDeclarativeContext> | |
|
13 | #include <QDir> | |
|
14 | #include <QFileInfo> | |
|
18 | 15 | #include <QApplication> |
|
16 | #include <QDeclarativeComponent> | |
|
17 | #include <QDeclarativeEngine> | |
|
18 | #include <QDeclarativeContext> | |
|
19 | 19 | |
|
20 | 20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
21 | 21 | |
|
22 | 22 | #ifdef HARMATTAN_BOOSTER |
|
23 | 23 | #include <MDeclarativeCache> |
|
24 | 24 | #endif |
|
25 | 25 | |
|
26 | 26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
27 | 27 | |
|
28 | 28 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
29 | 29 | |
|
30 | 30 | #if !defined(NO_JSDEBUGGER) |
|
31 | 31 | #include <jsdebuggeragent.h> |
|
32 | 32 | #endif |
|
33 | 33 | #if !defined(NO_QMLOBSERVER) |
|
34 | 34 | #include <qdeclarativeviewobserver.h> |
|
35 | 35 | #endif |
|
36 | 36 | |
|
37 | 37 | // Enable debugging before any QDeclarativeEngine is created |
|
38 | 38 | struct QmlJsDebuggingEnabler |
|
39 | 39 | { |
|
40 | 40 | QmlJsDebuggingEnabler() |
|
41 | 41 | { |
|
42 | 42 | QDeclarativeDebugHelper::enableDebugging(); |
|
43 | 43 | } |
|
44 | 44 | }; |
|
45 | 45 | |
|
46 | 46 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
47 | 47 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
48 | 48 | |
|
49 | 49 | #endif // QMLJSDEBUGGER |
|
50 | 50 | |
|
51 | 51 | class QmlApplicationViewerPrivate |
|
52 | 52 | { |
|
53 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} | |
|
54 | ||
|
55 | 53 | QString mainQmlFile; |
|
56 | QDeclarativeView *view; | |
|
57 | 54 | friend class QmlApplicationViewer; |
|
58 | QString adjustPath(const QString &path); | |
|
55 | static QString adjustPath(const QString &path); | |
|
59 | 56 | }; |
|
60 | 57 | |
|
61 | 58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
62 | 59 | { |
|
63 | #ifdef Q_OS_UNIX | |
|
64 | 60 | #ifdef Q_OS_MAC |
|
65 | 61 | if (!QDir::isAbsolutePath(path)) |
|
66 | return QCoreApplication::applicationDirPath() | |
|
67 | + QLatin1String("/../Resources/") + path; | |
|
68 | #else | |
|
69 | QString pathInInstallDir; | |
|
70 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); | |
|
71 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); | |
|
72 | ||
|
62 | return QString::fromLatin1("%1/../Resources/%2") | |
|
63 | .arg(QCoreApplication::applicationDirPath(), path); | |
|
64 | #elif defined(Q_OS_QNX) | |
|
65 | if (!QDir::isAbsolutePath(path)) | |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
|
67 | #elif !defined(Q_OS_ANDROID) | |
|
68 | QString pathInInstallDir = | |
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |
|
71 | return pathInInstallDir; | |
|
72 | pathInInstallDir = | |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
|
73 | 74 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | 75 | return pathInInstallDir; |
|
75 | #endif | |
|
76 | 76 | #endif |
|
77 | 77 | return path; |
|
78 | 78 | } |
|
79 | 79 | |
|
80 | 80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
81 | 81 | : QDeclarativeView(parent) |
|
82 |
, d(new QmlApplicationViewerPrivate( |
|
|
82 | , d(new QmlApplicationViewerPrivate()) | |
|
83 | 83 | { |
|
84 | 84 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
85 | 85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
86 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
|
87 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
|
88 | #if !defined(NO_JSDEBUGGER) | |
|
89 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); | |
|
90 | #endif | |
|
91 | #if !defined(NO_QMLOBSERVER) | |
|
92 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); | |
|
93 | #endif | |
|
94 | #endif | |
|
95 | } | |
|
96 | 86 | |
|
97 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) | |
|
98 | : QDeclarativeView(parent) | |
|
99 | , d(new QmlApplicationViewerPrivate(view)) | |
|
100 | { | |
|
101 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); | |
|
102 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
|
103 | 87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
104 | 88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
105 | 89 | #if !defined(NO_JSDEBUGGER) |
|
106 |
new QmlJSDebugger::JSDebuggerAgent( |
|
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
|
107 | 91 | #endif |
|
108 | 92 | #if !defined(NO_QMLOBSERVER) |
|
109 |
new QmlJSDebugger::QDeclarativeViewObserver( |
|
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
|
110 | 94 | #endif |
|
111 | 95 | #endif |
|
112 | 96 | } |
|
113 | 97 | |
|
114 | 98 | QmlApplicationViewer::~QmlApplicationViewer() |
|
115 | 99 | { |
|
116 | 100 | delete d; |
|
117 | 101 | } |
|
118 | 102 | |
|
119 | 103 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
120 | 104 | { |
|
121 | #ifdef HARMATTAN_BOOSTER | |
|
122 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); | |
|
123 | #else | |
|
124 | 105 | return new QmlApplicationViewer(); |
|
125 | #endif | |
|
126 | 106 | } |
|
127 | 107 | |
|
128 | 108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
129 | 109 | { |
|
130 |
d->mainQmlFile = |
|
|
131 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
|
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
|
111 | #ifdef Q_OS_ANDROID | |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
|
113 | #else | |
|
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
|
115 | #endif | |
|
132 | 116 | } |
|
133 | 117 | |
|
134 | 118 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
135 | 119 | { |
|
136 |
|
|
|
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
|
137 | 121 | } |
|
138 | 122 | |
|
139 |
|
|
|
140 | //{ | |
|
141 | //#if defined(Q_OS_SYMBIAN) | |
|
142 | // // If the version of Qt on the device is < 4.7.2, that attribute won't work | |
|
143 | // if (orientation != ScreenOrientationAuto) { | |
|
144 | // const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); | |
|
145 | // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { | |
|
146 | // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); | |
|
147 | // return; | |
|
148 |
|
|
|
149 | // } | |
|
150 | //#endif // Q_OS_SYMBIAN | |
|
151 | ||
|
152 | // Qt::WidgetAttribute attribute; | |
|
153 | // switch (orientation) { | |
|
154 | //#if QT_VERSION < 0x040702 | |
|
155 | // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
|
156 | // case ScreenOrientationLockPortrait: | |
|
157 | // attribute = static_cast<Qt::WidgetAttribute>(128); | |
|
158 | // break; | |
|
159 | // case ScreenOrientationLockLandscape: | |
|
160 | // attribute = static_cast<Qt::WidgetAttribute>(129); | |
|
161 | // break; | |
|
162 | // default: | |
|
163 | // case ScreenOrientationAuto: | |
|
164 | // attribute = static_cast<Qt::WidgetAttribute>(130); | |
|
165 | // break; | |
|
166 | //#else // QT_VERSION < 0x040702 | |
|
167 | // case ScreenOrientationLockPortrait: | |
|
168 | // attribute = Qt::WA_LockPortraitOrientation; | |
|
169 | // break; | |
|
170 | // case ScreenOrientationLockLandscape: | |
|
171 | // attribute = Qt::WA_LockLandscapeOrientation; | |
|
172 | // break; | |
|
173 | // default: | |
|
174 | // case ScreenOrientationAuto: | |
|
175 | // attribute = Qt::WA_AutoOrientation; | |
|
176 | // break; | |
|
177 | //#endif // QT_VERSION < 0x040702 | |
|
178 | // }; | |
|
179 | // setAttribute(attribute, true); | |
|
180 | //} | |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
|
124 | { | |
|
125 | #if QT_VERSION < 0x050000 | |
|
126 | Qt::WidgetAttribute attribute; | |
|
127 | switch (orientation) { | |
|
128 | #if QT_VERSION < 0x040702 | |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
|
130 | case ScreenOrientationLockPortrait: | |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
|
132 | break; | |
|
133 | case ScreenOrientationLockLandscape: | |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
|
135 | break; | |
|
136 | default: | |
|
137 | case ScreenOrientationAuto: | |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
|
139 | break; | |
|
140 | #else // QT_VERSION < 0x040702 | |
|
141 | case ScreenOrientationLockPortrait: | |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
|
143 | break; | |
|
144 | case ScreenOrientationLockLandscape: | |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
|
146 | break; | |
|
147 | default: | |
|
148 | case ScreenOrientationAuto: | |
|
149 | attribute = Qt::WA_AutoOrientation; | |
|
150 | break; | |
|
151 | #endif // QT_VERSION < 0x040702 | |
|
152 | }; | |
|
153 | setAttribute(attribute, true); | |
|
154 | #else // QT_VERSION < 0x050000 | |
|
155 | Q_UNUSED(orientation) | |
|
156 | #endif // QT_VERSION < 0x050000 | |
|
157 | } | |
|
181 | 158 | |
|
182 | 159 | void QmlApplicationViewer::showExpanded() |
|
183 | 160 | { |
|
184 |
#if defined( |
|
|
185 |
|
|
|
186 | #elif defined(Q_WS_MAEMO_5) | |
|
187 |
|
|
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
|
162 | showFullScreen(); | |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
|
164 | showMaximized(); | |
|
188 | 165 | #else |
|
189 |
|
|
|
166 | show(); | |
|
190 | 167 | #endif |
|
191 | 168 | } |
|
192 | 169 | |
|
193 | 170 | QApplication *createApplication(int &argc, char **argv) |
|
194 | 171 | { |
|
195 | 172 | #ifdef HARMATTAN_BOOSTER |
|
196 | 173 | return MDeclarativeCache::qApplication(argc, argv); |
|
197 | 174 | #else |
|
198 | 175 | return new QApplication(argc, argv); |
|
199 | 176 | #endif |
|
200 | 177 | } |
@@ -1,47 +1,46 | |||
|
1 |
// checksum 0x |
|
|
1 | // checksum 0xc67a version 0x80016 | |
|
2 | 2 | /* |
|
3 | 3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
4 | 4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
5 | 5 | code such as screen orientation handling. Also QML paths and debugging are |
|
6 | 6 | handled here. |
|
7 | 7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
8 | 8 | may offer an updated version of it. |
|
9 | 9 | */ |
|
10 | 10 | |
|
11 | 11 | #ifndef QMLAPPLICATIONVIEWER_H |
|
12 | 12 | #define QMLAPPLICATIONVIEWER_H |
|
13 | 13 | |
|
14 |
#include <Q |
|
|
14 | #include <QDeclarativeView> | |
|
15 | 15 | |
|
16 | 16 | class QmlApplicationViewer : public QDeclarativeView |
|
17 | 17 | { |
|
18 | 18 | Q_OBJECT |
|
19 | 19 | |
|
20 | 20 | public: |
|
21 | 21 | enum ScreenOrientation { |
|
22 | 22 | ScreenOrientationLockPortrait, |
|
23 | 23 | ScreenOrientationLockLandscape, |
|
24 | 24 | ScreenOrientationAuto |
|
25 | 25 | }; |
|
26 | 26 | |
|
27 | 27 | explicit QmlApplicationViewer(QWidget *parent = 0); |
|
28 | 28 | virtual ~QmlApplicationViewer(); |
|
29 | 29 | |
|
30 | 30 | static QmlApplicationViewer *create(); |
|
31 | 31 | |
|
32 | 32 | void setMainQmlFile(const QString &file); |
|
33 | 33 | void addImportPath(const QString &path); |
|
34 | 34 | |
|
35 |
// Note that this will only have an effect on |
|
|
36 |
|
|
|
35 | // Note that this will only have an effect on Fremantle. | |
|
36 | void setOrientation(ScreenOrientation orientation); | |
|
37 | 37 | |
|
38 | 38 | void showExpanded(); |
|
39 | 39 | |
|
40 | 40 | private: |
|
41 | explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); | |
|
42 | 41 | class QmlApplicationViewerPrivate *d; |
|
43 | 42 | }; |
|
44 | 43 | |
|
45 | 44 | QApplication *createApplication(int &argc, char **argv); |
|
46 | 45 | |
|
47 | 46 | #endif // QMLAPPLICATIONVIEWER_H |
@@ -1,174 +1,177 | |||
|
1 |
// checksum 0x |
|
|
1 | // checksum 0xbd34 version 0x80016 | |
|
2 | 2 | /* |
|
3 | 3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
4 | 4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
5 | 5 | code such as screen orientation handling. Also QML paths and debugging are |
|
6 | 6 | handled here. |
|
7 | 7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
8 | 8 | may offer an updated version of it. |
|
9 | 9 | */ |
|
10 | 10 | |
|
11 | 11 | #include "qmlapplicationviewer.h" |
|
12 | 12 | |
|
13 | 13 | #include <QDir> |
|
14 | 14 | #include <QFileInfo> |
|
15 | #include <QtDeclarative/QDeclarativeComponent> | |
|
16 | #include <QtDeclarative/QDeclarativeEngine> | |
|
17 | #include <QtDeclarative/QDeclarativeContext> | |
|
18 | 15 | #include <QApplication> |
|
16 | #include <QDeclarativeComponent> | |
|
17 | #include <QDeclarativeEngine> | |
|
18 | #include <QDeclarativeContext> | |
|
19 | 19 | |
|
20 | 20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
21 | 21 | |
|
22 | 22 | #ifdef HARMATTAN_BOOSTER |
|
23 | 23 | #include <MDeclarativeCache> |
|
24 | 24 | #endif |
|
25 | 25 | |
|
26 | 26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
27 | 27 | |
|
28 | 28 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
29 | 29 | |
|
30 | 30 | #if !defined(NO_JSDEBUGGER) |
|
31 | 31 | #include <jsdebuggeragent.h> |
|
32 | 32 | #endif |
|
33 | 33 | #if !defined(NO_QMLOBSERVER) |
|
34 | 34 | #include <qdeclarativeviewobserver.h> |
|
35 | 35 | #endif |
|
36 | 36 | |
|
37 | 37 | // Enable debugging before any QDeclarativeEngine is created |
|
38 | 38 | struct QmlJsDebuggingEnabler |
|
39 | 39 | { |
|
40 | 40 | QmlJsDebuggingEnabler() |
|
41 | 41 | { |
|
42 | 42 | QDeclarativeDebugHelper::enableDebugging(); |
|
43 | 43 | } |
|
44 | 44 | }; |
|
45 | 45 | |
|
46 | 46 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
47 | 47 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
48 | 48 | |
|
49 | 49 | #endif // QMLJSDEBUGGER |
|
50 | 50 | |
|
51 | 51 | class QmlApplicationViewerPrivate |
|
52 | 52 | { |
|
53 | 53 | QString mainQmlFile; |
|
54 | 54 | friend class QmlApplicationViewer; |
|
55 | 55 | static QString adjustPath(const QString &path); |
|
56 | 56 | }; |
|
57 | 57 | |
|
58 | 58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
59 | 59 | { |
|
60 | #ifdef Q_OS_UNIX | |
|
61 | 60 | #ifdef Q_OS_MAC |
|
62 | 61 | if (!QDir::isAbsolutePath(path)) |
|
63 | 62 | return QString::fromLatin1("%1/../Resources/%2") |
|
64 | 63 | .arg(QCoreApplication::applicationDirPath(), path); |
|
65 | #else | |
|
66 | const QString pathInInstallDir = | |
|
64 | #elif defined(Q_OS_QNX) | |
|
65 | if (!QDir::isAbsolutePath(path)) | |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
|
67 | #elif !defined(Q_OS_ANDROID) | |
|
68 | QString pathInInstallDir = | |
|
67 | 69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); |
|
68 | 70 | if (QFileInfo(pathInInstallDir).exists()) |
|
69 | 71 | return pathInInstallDir; |
|
70 | #endif | |
|
72 | pathInInstallDir = | |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |
|
75 | return pathInInstallDir; | |
|
71 | 76 | #endif |
|
72 | 77 | return path; |
|
73 | 78 | } |
|
74 | 79 | |
|
75 | 80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
76 | 81 | : QDeclarativeView(parent) |
|
77 | 82 | , d(new QmlApplicationViewerPrivate()) |
|
78 | 83 | { |
|
79 | 84 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
80 | 85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
86 | ||
|
81 | 87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
82 | 88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
83 | 89 | #if !defined(NO_JSDEBUGGER) |
|
84 | 90 | new QmlJSDebugger::JSDebuggerAgent(engine()); |
|
85 | 91 | #endif |
|
86 | 92 | #if !defined(NO_QMLOBSERVER) |
|
87 | 93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); |
|
88 | 94 | #endif |
|
89 | 95 | #endif |
|
90 | 96 | } |
|
91 | 97 | |
|
92 | 98 | QmlApplicationViewer::~QmlApplicationViewer() |
|
93 | 99 | { |
|
94 | 100 | delete d; |
|
95 | 101 | } |
|
96 | 102 | |
|
97 | 103 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
98 | 104 | { |
|
99 | 105 | return new QmlApplicationViewer(); |
|
100 | 106 | } |
|
101 | 107 | |
|
102 | 108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
103 | 109 | { |
|
104 | 110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); |
|
111 | #ifdef Q_OS_ANDROID | |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
|
113 | #else | |
|
105 | 114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
115 | #endif | |
|
106 | 116 | } |
|
107 | 117 | |
|
108 | 118 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
109 | 119 | { |
|
110 | 120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); |
|
111 | 121 | } |
|
112 | 122 | |
|
113 |
|
|
|
114 | //{ | |
|
115 | //#if defined(Q_OS_SYMBIAN) | |
|
116 | // // If the version of Qt on the device is < 4.7.2, that attribute won't work | |
|
117 | // if (orientation != ScreenOrientationAuto) { | |
|
118 | // const QStringList v = QString::fromLatin1(qVersion()).split(QLatin1Char('.')); | |
|
119 | // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { | |
|
120 | // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); | |
|
121 | // return; | |
|
122 |
|
|
|
123 | // } | |
|
124 | //#endif // Q_OS_SYMBIAN | |
|
125 | ||
|
126 | // Qt::WidgetAttribute attribute; | |
|
127 | // switch (orientation) { | |
|
128 | //#if QT_VERSION < 0x040702 | |
|
129 | // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
|
130 | // case ScreenOrientationLockPortrait: | |
|
131 | // attribute = static_cast<Qt::WidgetAttribute>(128); | |
|
132 | // break; | |
|
133 | // case ScreenOrientationLockLandscape: | |
|
134 | // attribute = static_cast<Qt::WidgetAttribute>(129); | |
|
135 | // break; | |
|
136 | // default: | |
|
137 | // case ScreenOrientationAuto: | |
|
138 | // attribute = static_cast<Qt::WidgetAttribute>(130); | |
|
139 | // break; | |
|
140 | //#else // QT_VERSION < 0x040702 | |
|
141 | // case ScreenOrientationLockPortrait: | |
|
142 | // attribute = Qt::WA_LockPortraitOrientation; | |
|
143 | // break; | |
|
144 | // case ScreenOrientationLockLandscape: | |
|
145 | // attribute = Qt::WA_LockLandscapeOrientation; | |
|
146 | // break; | |
|
147 | // default: | |
|
148 | // case ScreenOrientationAuto: | |
|
149 | // attribute = Qt::WA_AutoOrientation; | |
|
150 | // break; | |
|
151 | //#endif // QT_VERSION < 0x040702 | |
|
152 | // }; | |
|
153 | // setAttribute(attribute, true); | |
|
154 | //} | |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
|
124 | { | |
|
125 | #if QT_VERSION < 0x050000 | |
|
126 | Qt::WidgetAttribute attribute; | |
|
127 | switch (orientation) { | |
|
128 | #if QT_VERSION < 0x040702 | |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
|
130 | case ScreenOrientationLockPortrait: | |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
|
132 | break; | |
|
133 | case ScreenOrientationLockLandscape: | |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
|
135 | break; | |
|
136 | default: | |
|
137 | case ScreenOrientationAuto: | |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
|
139 | break; | |
|
140 | #else // QT_VERSION < 0x040702 | |
|
141 | case ScreenOrientationLockPortrait: | |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
|
143 | break; | |
|
144 | case ScreenOrientationLockLandscape: | |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
|
146 | break; | |
|
147 | default: | |
|
148 | case ScreenOrientationAuto: | |
|
149 | attribute = Qt::WA_AutoOrientation; | |
|
150 | break; | |
|
151 | #endif // QT_VERSION < 0x040702 | |
|
152 | }; | |
|
153 | setAttribute(attribute, true); | |
|
154 | #else // QT_VERSION < 0x050000 | |
|
155 | Q_UNUSED(orientation) | |
|
156 | #endif // QT_VERSION < 0x050000 | |
|
157 | } | |
|
155 | 158 | |
|
156 | 159 | void QmlApplicationViewer::showExpanded() |
|
157 | 160 | { |
|
158 |
#if defined( |
|
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
|
159 | 162 | showFullScreen(); |
|
160 | #elif defined(Q_WS_MAEMO_5) | |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
|
161 | 164 | showMaximized(); |
|
162 | 165 | #else |
|
163 | 166 | show(); |
|
164 | 167 | #endif |
|
165 | 168 | } |
|
166 | 169 | |
|
167 | 170 | QApplication *createApplication(int &argc, char **argv) |
|
168 | 171 | { |
|
169 | 172 | #ifdef HARMATTAN_BOOSTER |
|
170 | 173 | return MDeclarativeCache::qApplication(argc, argv); |
|
171 | 174 | #else |
|
172 | 175 | return new QApplication(argc, argv); |
|
173 | 176 | #endif |
|
174 | 177 | } |
@@ -1,46 +1,46 | |||
|
1 |
// checksum 0x |
|
|
1 | // checksum 0xc67a version 0x80016 | |
|
2 | 2 | /* |
|
3 | 3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
4 | 4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
5 | 5 | code such as screen orientation handling. Also QML paths and debugging are |
|
6 | 6 | handled here. |
|
7 | 7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
8 | 8 | may offer an updated version of it. |
|
9 | 9 | */ |
|
10 | 10 | |
|
11 | 11 | #ifndef QMLAPPLICATIONVIEWER_H |
|
12 | 12 | #define QMLAPPLICATIONVIEWER_H |
|
13 | 13 | |
|
14 | 14 | #include <QDeclarativeView> |
|
15 | 15 | |
|
16 | 16 | class QmlApplicationViewer : public QDeclarativeView |
|
17 | 17 | { |
|
18 | 18 | Q_OBJECT |
|
19 | 19 | |
|
20 | 20 | public: |
|
21 | 21 | enum ScreenOrientation { |
|
22 | 22 | ScreenOrientationLockPortrait, |
|
23 | 23 | ScreenOrientationLockLandscape, |
|
24 | 24 | ScreenOrientationAuto |
|
25 | 25 | }; |
|
26 | 26 | |
|
27 | 27 | explicit QmlApplicationViewer(QWidget *parent = 0); |
|
28 | 28 | virtual ~QmlApplicationViewer(); |
|
29 | 29 | |
|
30 | 30 | static QmlApplicationViewer *create(); |
|
31 | 31 | |
|
32 | 32 | void setMainQmlFile(const QString &file); |
|
33 | 33 | void addImportPath(const QString &path); |
|
34 | 34 | |
|
35 |
// Note that this will only have an effect on |
|
|
36 |
|
|
|
35 | // Note that this will only have an effect on Fremantle. | |
|
36 | void setOrientation(ScreenOrientation orientation); | |
|
37 | 37 | |
|
38 | 38 | void showExpanded(); |
|
39 | 39 | |
|
40 | 40 | private: |
|
41 | 41 | class QmlApplicationViewerPrivate *d; |
|
42 | 42 | }; |
|
43 | 43 | |
|
44 | 44 | QApplication *createApplication(int &argc, char **argv); |
|
45 | 45 | |
|
46 | 46 | #endif // QMLAPPLICATIONVIEWER_H |
@@ -1,148 +1,169 | |||
|
1 |
# checksum 0x |
|
|
1 | # checksum 0x77b version 0x80016 | |
|
2 | 2 | # This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | 3 | # The code below adds the QmlApplicationViewer to the project and handles the |
|
4 | 4 | # activation of QML debugging. |
|
5 | 5 | # It is recommended not to modify this file, since newer versions of Qt Creator |
|
6 | 6 | # may offer an updated version of it. |
|
7 | 7 | |
|
8 | 8 | QT += declarative |
|
9 | 9 | |
|
10 | 10 | SOURCES += $$PWD/qmlapplicationviewer.cpp |
|
11 | 11 | HEADERS += $$PWD/qmlapplicationviewer.h |
|
12 | 12 | INCLUDEPATH += $$PWD |
|
13 | 13 | |
|
14 | 14 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set |
|
15 | 15 | !isEmpty(QMLJSDEBUGGER_PATH) { |
|
16 | 16 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) |
|
17 | 17 | } else { |
|
18 | 18 | DEFINES -= QMLJSDEBUGGER |
|
19 | 19 | } |
|
20 | 20 | |
|
21 | 21 | contains(CONFIG,qdeclarative-boostable):contains(MEEGO_EDITION,harmattan) { |
|
22 | 22 | DEFINES += HARMATTAN_BOOSTER |
|
23 | 23 | } |
|
24 | 24 | # This file was generated by an application wizard of Qt Creator. |
|
25 |
# The code below handles deployment to |
|
|
25 | # The code below handles deployment to Android and Maemo, aswell as copying | |
|
26 | 26 | # of the application data to shadow build directories on desktop. |
|
27 | 27 | # It is recommended not to modify this file, since newer versions of Qt Creator |
|
28 | 28 | # may offer an updated version of it. |
|
29 | 29 | |
|
30 | 30 | defineTest(qtcAddDeployment) { |
|
31 | 31 | for(deploymentfolder, DEPLOYMENTFOLDERS) { |
|
32 | 32 | item = item$${deploymentfolder} |
|
33 | itemsources = $${item}.sources | |
|
33 | greaterThan(QT_MAJOR_VERSION, 4) { | |
|
34 | itemsources = $${item}.files | |
|
35 | } else { | |
|
36 | itemsources = $${item}.sources | |
|
37 | } | |
|
34 | 38 | $$itemsources = $$eval($${deploymentfolder}.source) |
|
35 | 39 | itempath = $${item}.path |
|
36 | 40 | $$itempath= $$eval($${deploymentfolder}.target) |
|
37 | 41 | export($$itemsources) |
|
38 | 42 | export($$itempath) |
|
39 | 43 | DEPLOYMENT += $$item |
|
40 | 44 | } |
|
41 | 45 | |
|
42 | 46 | MAINPROFILEPWD = $$PWD |
|
43 | 47 | |
|
44 | symbian { | |
|
45 | isEmpty(ICON):exists($${TARGET}.svg):ICON = $${TARGET}.svg | |
|
46 | isEmpty(TARGET.EPOCHEAPSIZE):TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 | |
|
48 | android { | |
|
49 | for(deploymentfolder, DEPLOYMENTFOLDERS) { | |
|
50 | item = item$${deploymentfolder} | |
|
51 | itemfiles = $${item}.files | |
|
52 | $$itemfiles = $$eval($${deploymentfolder}.source) | |
|
53 | itempath = $${item}.path | |
|
54 | $$itempath = /assets/$$eval($${deploymentfolder}.target) | |
|
55 | export($$itemfiles) | |
|
56 | export($$itempath) | |
|
57 | INSTALLS += $$item | |
|
58 | } | |
|
59 | ||
|
60 | x86 { | |
|
61 | target.path = /libs/x86 | |
|
62 | } else: armeabi-v7a { | |
|
63 | target.path = /libs/armeabi-v7a | |
|
64 | } else { | |
|
65 | target.path = /libs/armeabi | |
|
66 | } | |
|
67 | ||
|
68 | export(target.path) | |
|
69 | INSTALLS += target | |
|
47 | 70 | } else:win32 { |
|
48 | 71 | copyCommand = |
|
49 | 72 | for(deploymentfolder, DEPLOYMENTFOLDERS) { |
|
50 | 73 | source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source) |
|
51 | 74 | source = $$replace(source, /, \\) |
|
52 | 75 | sourcePathSegments = $$split(source, \\) |
|
53 | 76 | target = $$OUT_PWD/$$eval($${deploymentfolder}.target)/$$last(sourcePathSegments) |
|
54 | 77 | target = $$replace(target, /, \\) |
|
55 | 78 | target ~= s,\\\\\\.?\\\\,\\, |
|
56 | 79 | !isEqual(source,$$target) { |
|
57 | 80 | !isEmpty(copyCommand):copyCommand += && |
|
58 | 81 | isEqual(QMAKE_DIR_SEP, \\) { |
|
59 | 82 | copyCommand += $(COPY_DIR) \"$$source\" \"$$target\" |
|
60 | 83 | } else { |
|
61 | 84 | source = $$replace(source, \\\\, /) |
|
62 | 85 | target = $$OUT_PWD/$$eval($${deploymentfolder}.target) |
|
63 | 86 | target = $$replace(target, \\\\, /) |
|
64 | 87 | copyCommand += test -d \"$$target\" || mkdir -p \"$$target\" && cp -r \"$$source\" \"$$target\" |
|
65 | 88 | } |
|
66 | 89 | } |
|
67 | 90 | } |
|
68 | 91 | !isEmpty(copyCommand) { |
|
69 | 92 | copyCommand = @echo Copying application data... && $$copyCommand |
|
70 | 93 | copydeploymentfolders.commands = $$copyCommand |
|
71 | 94 | first.depends = $(first) copydeploymentfolders |
|
72 | 95 | export(first.depends) |
|
73 | 96 | export(copydeploymentfolders.commands) |
|
74 | 97 | QMAKE_EXTRA_TARGETS += first copydeploymentfolders |
|
75 | 98 | } |
|
76 | 99 | } else:unix { |
|
77 | 100 | maemo5 { |
|
78 | 101 | desktopfile.files = $${TARGET}.desktop |
|
79 | 102 | desktopfile.path = /usr/share/applications/hildon |
|
80 | 103 | icon.files = $${TARGET}64.png |
|
81 | 104 | icon.path = /usr/share/icons/hicolor/64x64/apps |
|
82 | 105 | } else:!isEmpty(MEEGO_VERSION_MAJOR) { |
|
83 | 106 | desktopfile.files = $${TARGET}_harmattan.desktop |
|
84 | 107 | desktopfile.path = /usr/share/applications |
|
85 | 108 | icon.files = $${TARGET}80.png |
|
86 | 109 | icon.path = /usr/share/icons/hicolor/80x80/apps |
|
87 | 110 | } else { # Assumed to be a Desktop Unix |
|
88 | 111 | copyCommand = |
|
89 | 112 | for(deploymentfolder, DEPLOYMENTFOLDERS) { |
|
90 | 113 | source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source) |
|
91 | 114 | source = $$replace(source, \\\\, /) |
|
92 | 115 | macx { |
|
93 | 116 | target = $$OUT_PWD/$${TARGET}.app/Contents/Resources/$$eval($${deploymentfolder}.target) |
|
94 | 117 | } else { |
|
95 | 118 | target = $$OUT_PWD/$$eval($${deploymentfolder}.target) |
|
96 | 119 | } |
|
97 | 120 | target = $$replace(target, \\\\, /) |
|
98 | 121 | sourcePathSegments = $$split(source, /) |
|
99 | 122 | targetFullPath = $$target/$$last(sourcePathSegments) |
|
100 | 123 | targetFullPath ~= s,/\\.?/,/, |
|
101 | 124 | !isEqual(source,$$targetFullPath) { |
|
102 | 125 | !isEmpty(copyCommand):copyCommand += && |
|
103 | 126 | copyCommand += $(MKDIR) \"$$target\" |
|
104 | 127 | copyCommand += && $(COPY_DIR) \"$$source\" \"$$target\" |
|
105 | 128 | } |
|
106 | 129 | } |
|
107 | 130 | !isEmpty(copyCommand) { |
|
108 | 131 | copyCommand = @echo Copying application data... && $$copyCommand |
|
109 | 132 | copydeploymentfolders.commands = $$copyCommand |
|
110 | 133 | first.depends = $(first) copydeploymentfolders |
|
111 | 134 | export(first.depends) |
|
112 | 135 | export(copydeploymentfolders.commands) |
|
113 | 136 | QMAKE_EXTRA_TARGETS += first copydeploymentfolders |
|
114 | 137 | } |
|
115 | 138 | } |
|
116 | 139 | installPrefix = /opt/$${TARGET} |
|
117 | 140 | for(deploymentfolder, DEPLOYMENTFOLDERS) { |
|
118 | 141 | item = item$${deploymentfolder} |
|
119 | 142 | itemfiles = $${item}.files |
|
120 | 143 | $$itemfiles = $$eval($${deploymentfolder}.source) |
|
121 | 144 | itempath = $${item}.path |
|
122 | 145 | $$itempath = $${installPrefix}/$$eval($${deploymentfolder}.target) |
|
123 | 146 | export($$itemfiles) |
|
124 | 147 | export($$itempath) |
|
125 | 148 | INSTALLS += $$item |
|
126 | 149 | } |
|
127 | 150 | |
|
128 | 151 | !isEmpty(desktopfile.path) { |
|
129 | 152 | export(icon.files) |
|
130 | 153 | export(icon.path) |
|
131 | 154 | export(desktopfile.files) |
|
132 | 155 | export(desktopfile.path) |
|
133 | 156 | INSTALLS += icon desktopfile |
|
134 | 157 | } |
|
135 | 158 | |
|
136 | 159 | target.path = $${installPrefix}/bin |
|
137 | 160 | export(target.path) |
|
138 | 161 | INSTALLS += target |
|
139 | 162 | } |
|
140 | 163 | |
|
141 | 164 | export (ICON) |
|
142 | 165 | export (INSTALLS) |
|
143 | 166 | export (DEPLOYMENT) |
|
144 | export (TARGET.EPOCHEAPSIZE) | |
|
145 | export (TARGET.CAPABILITY) | |
|
146 | 167 | export (LIBS) |
|
147 | 168 | export (QMAKE_EXTRA_TARGETS) |
|
148 | 169 | } |
@@ -1,200 +1,177 | |||
|
1 |
// checksum 0x |
|
|
1 | // checksum 0xbd34 version 0x80016 | |
|
2 | 2 | /* |
|
3 | 3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
4 | 4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
5 | 5 | code such as screen orientation handling. Also QML paths and debugging are |
|
6 | 6 | handled here. |
|
7 | 7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
8 | 8 | may offer an updated version of it. |
|
9 | 9 | */ |
|
10 | 10 | |
|
11 | 11 | #include "qmlapplicationviewer.h" |
|
12 | 12 | |
|
13 |
#include <Q |
|
|
14 |
#include <Q |
|
|
15 | #include <QtDeclarative/QDeclarativeComponent> | |
|
16 | #include <QtDeclarative/QDeclarativeEngine> | |
|
17 | #include <QtDeclarative/QDeclarativeContext> | |
|
13 | #include <QDir> | |
|
14 | #include <QFileInfo> | |
|
18 | 15 | #include <QApplication> |
|
16 | #include <QDeclarativeComponent> | |
|
17 | #include <QDeclarativeEngine> | |
|
18 | #include <QDeclarativeContext> | |
|
19 | 19 | |
|
20 | 20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
21 | 21 | |
|
22 | 22 | #ifdef HARMATTAN_BOOSTER |
|
23 | 23 | #include <MDeclarativeCache> |
|
24 | 24 | #endif |
|
25 | 25 | |
|
26 | 26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
27 | 27 | |
|
28 | 28 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
29 | 29 | |
|
30 | 30 | #if !defined(NO_JSDEBUGGER) |
|
31 | 31 | #include <jsdebuggeragent.h> |
|
32 | 32 | #endif |
|
33 | 33 | #if !defined(NO_QMLOBSERVER) |
|
34 | 34 | #include <qdeclarativeviewobserver.h> |
|
35 | 35 | #endif |
|
36 | 36 | |
|
37 | 37 | // Enable debugging before any QDeclarativeEngine is created |
|
38 | 38 | struct QmlJsDebuggingEnabler |
|
39 | 39 | { |
|
40 | 40 | QmlJsDebuggingEnabler() |
|
41 | 41 | { |
|
42 | 42 | QDeclarativeDebugHelper::enableDebugging(); |
|
43 | 43 | } |
|
44 | 44 | }; |
|
45 | 45 | |
|
46 | 46 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
47 | 47 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
48 | 48 | |
|
49 | 49 | #endif // QMLJSDEBUGGER |
|
50 | 50 | |
|
51 | 51 | class QmlApplicationViewerPrivate |
|
52 | 52 | { |
|
53 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} | |
|
54 | ||
|
55 | 53 | QString mainQmlFile; |
|
56 | QDeclarativeView *view; | |
|
57 | 54 | friend class QmlApplicationViewer; |
|
58 | QString adjustPath(const QString &path); | |
|
55 | static QString adjustPath(const QString &path); | |
|
59 | 56 | }; |
|
60 | 57 | |
|
61 | 58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
62 | 59 | { |
|
63 | #ifdef Q_OS_UNIX | |
|
64 | 60 | #ifdef Q_OS_MAC |
|
65 | 61 | if (!QDir::isAbsolutePath(path)) |
|
66 | return QCoreApplication::applicationDirPath() | |
|
67 | + QLatin1String("/../Resources/") + path; | |
|
68 | #else | |
|
69 | QString pathInInstallDir; | |
|
70 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); | |
|
71 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); | |
|
72 | ||
|
62 | return QString::fromLatin1("%1/../Resources/%2") | |
|
63 | .arg(QCoreApplication::applicationDirPath(), path); | |
|
64 | #elif defined(Q_OS_QNX) | |
|
65 | if (!QDir::isAbsolutePath(path)) | |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
|
67 | #elif !defined(Q_OS_ANDROID) | |
|
68 | QString pathInInstallDir = | |
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |
|
71 | return pathInInstallDir; | |
|
72 | pathInInstallDir = | |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
|
73 | 74 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | 75 | return pathInInstallDir; |
|
75 | #endif | |
|
76 | 76 | #endif |
|
77 | 77 | return path; |
|
78 | 78 | } |
|
79 | 79 | |
|
80 | 80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
81 | 81 | : QDeclarativeView(parent) |
|
82 |
, d(new QmlApplicationViewerPrivate( |
|
|
82 | , d(new QmlApplicationViewerPrivate()) | |
|
83 | 83 | { |
|
84 | 84 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
85 | 85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
86 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
|
87 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
|
88 | #if !defined(NO_JSDEBUGGER) | |
|
89 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); | |
|
90 | #endif | |
|
91 | #if !defined(NO_QMLOBSERVER) | |
|
92 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); | |
|
93 | #endif | |
|
94 | #endif | |
|
95 | } | |
|
96 | 86 | |
|
97 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) | |
|
98 | : QDeclarativeView(parent) | |
|
99 | , d(new QmlApplicationViewerPrivate(view)) | |
|
100 | { | |
|
101 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); | |
|
102 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
|
103 | 87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
104 | 88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
105 | 89 | #if !defined(NO_JSDEBUGGER) |
|
106 |
new QmlJSDebugger::JSDebuggerAgent( |
|
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
|
107 | 91 | #endif |
|
108 | 92 | #if !defined(NO_QMLOBSERVER) |
|
109 |
new QmlJSDebugger::QDeclarativeViewObserver( |
|
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
|
110 | 94 | #endif |
|
111 | 95 | #endif |
|
112 | 96 | } |
|
113 | 97 | |
|
114 | 98 | QmlApplicationViewer::~QmlApplicationViewer() |
|
115 | 99 | { |
|
116 | 100 | delete d; |
|
117 | 101 | } |
|
118 | 102 | |
|
119 | 103 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
120 | 104 | { |
|
121 | #ifdef HARMATTAN_BOOSTER | |
|
122 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); | |
|
123 | #else | |
|
124 | 105 | return new QmlApplicationViewer(); |
|
125 | #endif | |
|
126 | 106 | } |
|
127 | 107 | |
|
128 | 108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
129 | 109 | { |
|
130 |
d->mainQmlFile = |
|
|
131 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
|
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
|
111 | #ifdef Q_OS_ANDROID | |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
|
113 | #else | |
|
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
|
115 | #endif | |
|
132 | 116 | } |
|
133 | 117 | |
|
134 | 118 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
135 | 119 | { |
|
136 |
|
|
|
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
|
137 | 121 | } |
|
138 | 122 | |
|
139 |
|
|
|
140 | //{ | |
|
141 | //#if defined(Q_OS_SYMBIAN) | |
|
142 | // // If the version of Qt on the device is < 4.7.2, that attribute won't work | |
|
143 | // if (orientation != ScreenOrientationAuto) { | |
|
144 | // const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); | |
|
145 | // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { | |
|
146 | // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); | |
|
147 | // return; | |
|
148 |
|
|
|
149 | // } | |
|
150 | //#endif // Q_OS_SYMBIAN | |
|
151 | ||
|
152 | // Qt::WidgetAttribute attribute; | |
|
153 | // switch (orientation) { | |
|
154 | //#if QT_VERSION < 0x040702 | |
|
155 | // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
|
156 | // case ScreenOrientationLockPortrait: | |
|
157 | // attribute = static_cast<Qt::WidgetAttribute>(128); | |
|
158 | // break; | |
|
159 | // case ScreenOrientationLockLandscape: | |
|
160 | // attribute = static_cast<Qt::WidgetAttribute>(129); | |
|
161 | // break; | |
|
162 | // default: | |
|
163 | // case ScreenOrientationAuto: | |
|
164 | // attribute = static_cast<Qt::WidgetAttribute>(130); | |
|
165 | // break; | |
|
166 | //#else // QT_VERSION < 0x040702 | |
|
167 | // case ScreenOrientationLockPortrait: | |
|
168 | // attribute = Qt::WA_LockPortraitOrientation; | |
|
169 | // break; | |
|
170 | // case ScreenOrientationLockLandscape: | |
|
171 | // attribute = Qt::WA_LockLandscapeOrientation; | |
|
172 | // break; | |
|
173 | // default: | |
|
174 | // case ScreenOrientationAuto: | |
|
175 | // attribute = Qt::WA_AutoOrientation; | |
|
176 | // break; | |
|
177 | //#endif // QT_VERSION < 0x040702 | |
|
178 | // }; | |
|
179 | // setAttribute(attribute, true); | |
|
180 | //} | |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
|
124 | { | |
|
125 | #if QT_VERSION < 0x050000 | |
|
126 | Qt::WidgetAttribute attribute; | |
|
127 | switch (orientation) { | |
|
128 | #if QT_VERSION < 0x040702 | |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
|
130 | case ScreenOrientationLockPortrait: | |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
|
132 | break; | |
|
133 | case ScreenOrientationLockLandscape: | |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
|
135 | break; | |
|
136 | default: | |
|
137 | case ScreenOrientationAuto: | |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
|
139 | break; | |
|
140 | #else // QT_VERSION < 0x040702 | |
|
141 | case ScreenOrientationLockPortrait: | |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
|
143 | break; | |
|
144 | case ScreenOrientationLockLandscape: | |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
|
146 | break; | |
|
147 | default: | |
|
148 | case ScreenOrientationAuto: | |
|
149 | attribute = Qt::WA_AutoOrientation; | |
|
150 | break; | |
|
151 | #endif // QT_VERSION < 0x040702 | |
|
152 | }; | |
|
153 | setAttribute(attribute, true); | |
|
154 | #else // QT_VERSION < 0x050000 | |
|
155 | Q_UNUSED(orientation) | |
|
156 | #endif // QT_VERSION < 0x050000 | |
|
157 | } | |
|
181 | 158 | |
|
182 | 159 | void QmlApplicationViewer::showExpanded() |
|
183 | 160 | { |
|
184 |
#if defined( |
|
|
185 |
|
|
|
186 | #elif defined(Q_WS_MAEMO_5) | |
|
187 |
|
|
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
|
162 | showFullScreen(); | |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
|
164 | showMaximized(); | |
|
188 | 165 | #else |
|
189 |
|
|
|
166 | show(); | |
|
190 | 167 | #endif |
|
191 | 168 | } |
|
192 | 169 | |
|
193 | 170 | QApplication *createApplication(int &argc, char **argv) |
|
194 | 171 | { |
|
195 | 172 | #ifdef HARMATTAN_BOOSTER |
|
196 | 173 | return MDeclarativeCache::qApplication(argc, argv); |
|
197 | 174 | #else |
|
198 | 175 | return new QApplication(argc, argv); |
|
199 | 176 | #endif |
|
200 | 177 | } |
@@ -1,47 +1,46 | |||
|
1 |
// checksum 0x |
|
|
1 | // checksum 0xc67a version 0x80016 | |
|
2 | 2 | /* |
|
3 | 3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
4 | 4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
5 | 5 | code such as screen orientation handling. Also QML paths and debugging are |
|
6 | 6 | handled here. |
|
7 | 7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
8 | 8 | may offer an updated version of it. |
|
9 | 9 | */ |
|
10 | 10 | |
|
11 | 11 | #ifndef QMLAPPLICATIONVIEWER_H |
|
12 | 12 | #define QMLAPPLICATIONVIEWER_H |
|
13 | 13 | |
|
14 |
#include <Q |
|
|
14 | #include <QDeclarativeView> | |
|
15 | 15 | |
|
16 | 16 | class QmlApplicationViewer : public QDeclarativeView |
|
17 | 17 | { |
|
18 | 18 | Q_OBJECT |
|
19 | 19 | |
|
20 | 20 | public: |
|
21 | 21 | enum ScreenOrientation { |
|
22 | 22 | ScreenOrientationLockPortrait, |
|
23 | 23 | ScreenOrientationLockLandscape, |
|
24 | 24 | ScreenOrientationAuto |
|
25 | 25 | }; |
|
26 | 26 | |
|
27 | 27 | explicit QmlApplicationViewer(QWidget *parent = 0); |
|
28 | 28 | virtual ~QmlApplicationViewer(); |
|
29 | 29 | |
|
30 | 30 | static QmlApplicationViewer *create(); |
|
31 | 31 | |
|
32 | 32 | void setMainQmlFile(const QString &file); |
|
33 | 33 | void addImportPath(const QString &path); |
|
34 | 34 | |
|
35 |
// Note that this will only have an effect on |
|
|
36 |
|
|
|
35 | // Note that this will only have an effect on Fremantle. | |
|
36 | void setOrientation(ScreenOrientation orientation); | |
|
37 | 37 | |
|
38 | 38 | void showExpanded(); |
|
39 | 39 | |
|
40 | 40 | private: |
|
41 | explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); | |
|
42 | 41 | class QmlApplicationViewerPrivate *d; |
|
43 | 42 | }; |
|
44 | 43 | |
|
45 | 44 | QApplication *createApplication(int &argc, char **argv); |
|
46 | 45 | |
|
47 | 46 | #endif // QMLAPPLICATIONVIEWER_H |
@@ -1,200 +1,177 | |||
|
1 |
// checksum 0x |
|
|
1 | // checksum 0xbd34 version 0x80016 | |
|
2 | 2 | /* |
|
3 | 3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
4 | 4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
5 | 5 | code such as screen orientation handling. Also QML paths and debugging are |
|
6 | 6 | handled here. |
|
7 | 7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
8 | 8 | may offer an updated version of it. |
|
9 | 9 | */ |
|
10 | 10 | |
|
11 | 11 | #include "qmlapplicationviewer.h" |
|
12 | 12 | |
|
13 |
#include <Q |
|
|
14 |
#include <Q |
|
|
15 | #include <QtDeclarative/QDeclarativeComponent> | |
|
16 | #include <QtDeclarative/QDeclarativeEngine> | |
|
17 | #include <QtDeclarative/QDeclarativeContext> | |
|
13 | #include <QDir> | |
|
14 | #include <QFileInfo> | |
|
18 | 15 | #include <QApplication> |
|
16 | #include <QDeclarativeComponent> | |
|
17 | #include <QDeclarativeEngine> | |
|
18 | #include <QDeclarativeContext> | |
|
19 | 19 | |
|
20 | 20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
21 | 21 | |
|
22 | 22 | #ifdef HARMATTAN_BOOSTER |
|
23 | 23 | #include <MDeclarativeCache> |
|
24 | 24 | #endif |
|
25 | 25 | |
|
26 | 26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
27 | 27 | |
|
28 | 28 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
29 | 29 | |
|
30 | 30 | #if !defined(NO_JSDEBUGGER) |
|
31 | 31 | #include <jsdebuggeragent.h> |
|
32 | 32 | #endif |
|
33 | 33 | #if !defined(NO_QMLOBSERVER) |
|
34 | 34 | #include <qdeclarativeviewobserver.h> |
|
35 | 35 | #endif |
|
36 | 36 | |
|
37 | 37 | // Enable debugging before any QDeclarativeEngine is created |
|
38 | 38 | struct QmlJsDebuggingEnabler |
|
39 | 39 | { |
|
40 | 40 | QmlJsDebuggingEnabler() |
|
41 | 41 | { |
|
42 | 42 | QDeclarativeDebugHelper::enableDebugging(); |
|
43 | 43 | } |
|
44 | 44 | }; |
|
45 | 45 | |
|
46 | 46 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
47 | 47 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
48 | 48 | |
|
49 | 49 | #endif // QMLJSDEBUGGER |
|
50 | 50 | |
|
51 | 51 | class QmlApplicationViewerPrivate |
|
52 | 52 | { |
|
53 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} | |
|
54 | ||
|
55 | 53 | QString mainQmlFile; |
|
56 | QDeclarativeView *view; | |
|
57 | 54 | friend class QmlApplicationViewer; |
|
58 | QString adjustPath(const QString &path); | |
|
55 | static QString adjustPath(const QString &path); | |
|
59 | 56 | }; |
|
60 | 57 | |
|
61 | 58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
62 | 59 | { |
|
63 | #ifdef Q_OS_UNIX | |
|
64 | 60 | #ifdef Q_OS_MAC |
|
65 | 61 | if (!QDir::isAbsolutePath(path)) |
|
66 | return QCoreApplication::applicationDirPath() | |
|
67 | + QLatin1String("/../Resources/") + path; | |
|
68 | #else | |
|
69 | QString pathInInstallDir; | |
|
70 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); | |
|
71 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); | |
|
72 | ||
|
62 | return QString::fromLatin1("%1/../Resources/%2") | |
|
63 | .arg(QCoreApplication::applicationDirPath(), path); | |
|
64 | #elif defined(Q_OS_QNX) | |
|
65 | if (!QDir::isAbsolutePath(path)) | |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
|
67 | #elif !defined(Q_OS_ANDROID) | |
|
68 | QString pathInInstallDir = | |
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |
|
71 | return pathInInstallDir; | |
|
72 | pathInInstallDir = | |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
|
73 | 74 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | 75 | return pathInInstallDir; |
|
75 | #endif | |
|
76 | 76 | #endif |
|
77 | 77 | return path; |
|
78 | 78 | } |
|
79 | 79 | |
|
80 | 80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
81 | 81 | : QDeclarativeView(parent) |
|
82 |
, d(new QmlApplicationViewerPrivate( |
|
|
82 | , d(new QmlApplicationViewerPrivate()) | |
|
83 | 83 | { |
|
84 | 84 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
85 | 85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
86 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
|
87 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
|
88 | #if !defined(NO_JSDEBUGGER) | |
|
89 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); | |
|
90 | #endif | |
|
91 | #if !defined(NO_QMLOBSERVER) | |
|
92 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); | |
|
93 | #endif | |
|
94 | #endif | |
|
95 | } | |
|
96 | 86 | |
|
97 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) | |
|
98 | : QDeclarativeView(parent) | |
|
99 | , d(new QmlApplicationViewerPrivate(view)) | |
|
100 | { | |
|
101 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); | |
|
102 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
|
103 | 87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
104 | 88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
105 | 89 | #if !defined(NO_JSDEBUGGER) |
|
106 |
new QmlJSDebugger::JSDebuggerAgent( |
|
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
|
107 | 91 | #endif |
|
108 | 92 | #if !defined(NO_QMLOBSERVER) |
|
109 |
new QmlJSDebugger::QDeclarativeViewObserver( |
|
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
|
110 | 94 | #endif |
|
111 | 95 | #endif |
|
112 | 96 | } |
|
113 | 97 | |
|
114 | 98 | QmlApplicationViewer::~QmlApplicationViewer() |
|
115 | 99 | { |
|
116 | 100 | delete d; |
|
117 | 101 | } |
|
118 | 102 | |
|
119 | 103 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
120 | 104 | { |
|
121 | #ifdef HARMATTAN_BOOSTER | |
|
122 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); | |
|
123 | #else | |
|
124 | 105 | return new QmlApplicationViewer(); |
|
125 | #endif | |
|
126 | 106 | } |
|
127 | 107 | |
|
128 | 108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
129 | 109 | { |
|
130 |
d->mainQmlFile = |
|
|
131 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
|
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
|
111 | #ifdef Q_OS_ANDROID | |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
|
113 | #else | |
|
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
|
115 | #endif | |
|
132 | 116 | } |
|
133 | 117 | |
|
134 | 118 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
135 | 119 | { |
|
136 |
|
|
|
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
|
137 | 121 | } |
|
138 | 122 | |
|
139 |
|
|
|
140 | //{ | |
|
141 | //#if defined(Q_OS_SYMBIAN) | |
|
142 | // // If the version of Qt on the device is < 4.7.2, that attribute won't work | |
|
143 | // if (orientation != ScreenOrientationAuto) { | |
|
144 | // const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); | |
|
145 | // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { | |
|
146 | // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); | |
|
147 | // return; | |
|
148 |
|
|
|
149 | // } | |
|
150 | //#endif // Q_OS_SYMBIAN | |
|
151 | ||
|
152 | // Qt::WidgetAttribute attribute; | |
|
153 | // switch (orientation) { | |
|
154 | //#if QT_VERSION < 0x040702 | |
|
155 | // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
|
156 | // case ScreenOrientationLockPortrait: | |
|
157 | // attribute = static_cast<Qt::WidgetAttribute>(128); | |
|
158 | // break; | |
|
159 | // case ScreenOrientationLockLandscape: | |
|
160 | // attribute = static_cast<Qt::WidgetAttribute>(129); | |
|
161 | // break; | |
|
162 | // default: | |
|
163 | // case ScreenOrientationAuto: | |
|
164 | // attribute = static_cast<Qt::WidgetAttribute>(130); | |
|
165 | // break; | |
|
166 | //#else // QT_VERSION < 0x040702 | |
|
167 | // case ScreenOrientationLockPortrait: | |
|
168 | // attribute = Qt::WA_LockPortraitOrientation; | |
|
169 | // break; | |
|
170 | // case ScreenOrientationLockLandscape: | |
|
171 | // attribute = Qt::WA_LockLandscapeOrientation; | |
|
172 | // break; | |
|
173 | // default: | |
|
174 | // case ScreenOrientationAuto: | |
|
175 | // attribute = Qt::WA_AutoOrientation; | |
|
176 | // break; | |
|
177 | //#endif // QT_VERSION < 0x040702 | |
|
178 | // }; | |
|
179 | // setAttribute(attribute, true); | |
|
180 | //} | |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
|
124 | { | |
|
125 | #if QT_VERSION < 0x050000 | |
|
126 | Qt::WidgetAttribute attribute; | |
|
127 | switch (orientation) { | |
|
128 | #if QT_VERSION < 0x040702 | |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
|
130 | case ScreenOrientationLockPortrait: | |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
|
132 | break; | |
|
133 | case ScreenOrientationLockLandscape: | |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
|
135 | break; | |
|
136 | default: | |
|
137 | case ScreenOrientationAuto: | |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
|
139 | break; | |
|
140 | #else // QT_VERSION < 0x040702 | |
|
141 | case ScreenOrientationLockPortrait: | |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
|
143 | break; | |
|
144 | case ScreenOrientationLockLandscape: | |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
|
146 | break; | |
|
147 | default: | |
|
148 | case ScreenOrientationAuto: | |
|
149 | attribute = Qt::WA_AutoOrientation; | |
|
150 | break; | |
|
151 | #endif // QT_VERSION < 0x040702 | |
|
152 | }; | |
|
153 | setAttribute(attribute, true); | |
|
154 | #else // QT_VERSION < 0x050000 | |
|
155 | Q_UNUSED(orientation) | |
|
156 | #endif // QT_VERSION < 0x050000 | |
|
157 | } | |
|
181 | 158 | |
|
182 | 159 | void QmlApplicationViewer::showExpanded() |
|
183 | 160 | { |
|
184 |
#if defined( |
|
|
185 |
|
|
|
186 | #elif defined(Q_WS_MAEMO_5) | |
|
187 |
|
|
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
|
162 | showFullScreen(); | |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
|
164 | showMaximized(); | |
|
188 | 165 | #else |
|
189 |
|
|
|
166 | show(); | |
|
190 | 167 | #endif |
|
191 | 168 | } |
|
192 | 169 | |
|
193 | 170 | QApplication *createApplication(int &argc, char **argv) |
|
194 | 171 | { |
|
195 | 172 | #ifdef HARMATTAN_BOOSTER |
|
196 | 173 | return MDeclarativeCache::qApplication(argc, argv); |
|
197 | 174 | #else |
|
198 | 175 | return new QApplication(argc, argv); |
|
199 | 176 | #endif |
|
200 | 177 | } |
@@ -1,47 +1,46 | |||
|
1 |
// checksum 0x |
|
|
1 | // checksum 0xc67a version 0x80016 | |
|
2 | 2 | /* |
|
3 | 3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
4 | 4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
5 | 5 | code such as screen orientation handling. Also QML paths and debugging are |
|
6 | 6 | handled here. |
|
7 | 7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
8 | 8 | may offer an updated version of it. |
|
9 | 9 | */ |
|
10 | 10 | |
|
11 | 11 | #ifndef QMLAPPLICATIONVIEWER_H |
|
12 | 12 | #define QMLAPPLICATIONVIEWER_H |
|
13 | 13 | |
|
14 |
#include <Q |
|
|
14 | #include <QDeclarativeView> | |
|
15 | 15 | |
|
16 | 16 | class QmlApplicationViewer : public QDeclarativeView |
|
17 | 17 | { |
|
18 | 18 | Q_OBJECT |
|
19 | 19 | |
|
20 | 20 | public: |
|
21 | 21 | enum ScreenOrientation { |
|
22 | 22 | ScreenOrientationLockPortrait, |
|
23 | 23 | ScreenOrientationLockLandscape, |
|
24 | 24 | ScreenOrientationAuto |
|
25 | 25 | }; |
|
26 | 26 | |
|
27 | 27 | explicit QmlApplicationViewer(QWidget *parent = 0); |
|
28 | 28 | virtual ~QmlApplicationViewer(); |
|
29 | 29 | |
|
30 | 30 | static QmlApplicationViewer *create(); |
|
31 | 31 | |
|
32 | 32 | void setMainQmlFile(const QString &file); |
|
33 | 33 | void addImportPath(const QString &path); |
|
34 | 34 | |
|
35 |
// Note that this will only have an effect on |
|
|
36 |
|
|
|
35 | // Note that this will only have an effect on Fremantle. | |
|
36 | void setOrientation(ScreenOrientation orientation); | |
|
37 | 37 | |
|
38 | 38 | void showExpanded(); |
|
39 | 39 | |
|
40 | 40 | private: |
|
41 | explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); | |
|
42 | 41 | class QmlApplicationViewerPrivate *d; |
|
43 | 42 | }; |
|
44 | 43 | |
|
45 | 44 | QApplication *createApplication(int &argc, char **argv); |
|
46 | 45 | |
|
47 | 46 | #endif // QMLAPPLICATIONVIEWER_H |
@@ -1,200 +1,177 | |||
|
1 |
// checksum 0x |
|
|
1 | // checksum 0xbd34 version 0x80016 | |
|
2 | 2 | /* |
|
3 | 3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
4 | 4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
5 | 5 | code such as screen orientation handling. Also QML paths and debugging are |
|
6 | 6 | handled here. |
|
7 | 7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
8 | 8 | may offer an updated version of it. |
|
9 | 9 | */ |
|
10 | 10 | |
|
11 | 11 | #include "qmlapplicationviewer.h" |
|
12 | 12 | |
|
13 |
#include <Q |
|
|
14 |
#include <Q |
|
|
15 | #include <QtDeclarative/QDeclarativeComponent> | |
|
16 | #include <QtDeclarative/QDeclarativeEngine> | |
|
17 | #include <QtDeclarative/QDeclarativeContext> | |
|
13 | #include <QDir> | |
|
14 | #include <QFileInfo> | |
|
18 | 15 | #include <QApplication> |
|
16 | #include <QDeclarativeComponent> | |
|
17 | #include <QDeclarativeEngine> | |
|
18 | #include <QDeclarativeContext> | |
|
19 | 19 | |
|
20 | 20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
21 | 21 | |
|
22 | 22 | #ifdef HARMATTAN_BOOSTER |
|
23 | 23 | #include <MDeclarativeCache> |
|
24 | 24 | #endif |
|
25 | 25 | |
|
26 | 26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
27 | 27 | |
|
28 | 28 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
29 | 29 | |
|
30 | 30 | #if !defined(NO_JSDEBUGGER) |
|
31 | 31 | #include <jsdebuggeragent.h> |
|
32 | 32 | #endif |
|
33 | 33 | #if !defined(NO_QMLOBSERVER) |
|
34 | 34 | #include <qdeclarativeviewobserver.h> |
|
35 | 35 | #endif |
|
36 | 36 | |
|
37 | 37 | // Enable debugging before any QDeclarativeEngine is created |
|
38 | 38 | struct QmlJsDebuggingEnabler |
|
39 | 39 | { |
|
40 | 40 | QmlJsDebuggingEnabler() |
|
41 | 41 | { |
|
42 | 42 | QDeclarativeDebugHelper::enableDebugging(); |
|
43 | 43 | } |
|
44 | 44 | }; |
|
45 | 45 | |
|
46 | 46 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
47 | 47 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
48 | 48 | |
|
49 | 49 | #endif // QMLJSDEBUGGER |
|
50 | 50 | |
|
51 | 51 | class QmlApplicationViewerPrivate |
|
52 | 52 | { |
|
53 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} | |
|
54 | ||
|
55 | 53 | QString mainQmlFile; |
|
56 | QDeclarativeView *view; | |
|
57 | 54 | friend class QmlApplicationViewer; |
|
58 | QString adjustPath(const QString &path); | |
|
55 | static QString adjustPath(const QString &path); | |
|
59 | 56 | }; |
|
60 | 57 | |
|
61 | 58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
62 | 59 | { |
|
63 | #ifdef Q_OS_UNIX | |
|
64 | 60 | #ifdef Q_OS_MAC |
|
65 | 61 | if (!QDir::isAbsolutePath(path)) |
|
66 | return QCoreApplication::applicationDirPath() | |
|
67 | + QLatin1String("/../Resources/") + path; | |
|
68 | #else | |
|
69 | QString pathInInstallDir; | |
|
70 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); | |
|
71 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); | |
|
72 | ||
|
62 | return QString::fromLatin1("%1/../Resources/%2") | |
|
63 | .arg(QCoreApplication::applicationDirPath(), path); | |
|
64 | #elif defined(Q_OS_QNX) | |
|
65 | if (!QDir::isAbsolutePath(path)) | |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
|
67 | #elif !defined(Q_OS_ANDROID) | |
|
68 | QString pathInInstallDir = | |
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |
|
71 | return pathInInstallDir; | |
|
72 | pathInInstallDir = | |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
|
73 | 74 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | 75 | return pathInInstallDir; |
|
75 | #endif | |
|
76 | 76 | #endif |
|
77 | 77 | return path; |
|
78 | 78 | } |
|
79 | 79 | |
|
80 | 80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
81 | 81 | : QDeclarativeView(parent) |
|
82 |
, d(new QmlApplicationViewerPrivate( |
|
|
82 | , d(new QmlApplicationViewerPrivate()) | |
|
83 | 83 | { |
|
84 | 84 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
85 | 85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
86 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
|
87 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
|
88 | #if !defined(NO_JSDEBUGGER) | |
|
89 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); | |
|
90 | #endif | |
|
91 | #if !defined(NO_QMLOBSERVER) | |
|
92 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); | |
|
93 | #endif | |
|
94 | #endif | |
|
95 | } | |
|
96 | 86 | |
|
97 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) | |
|
98 | : QDeclarativeView(parent) | |
|
99 | , d(new QmlApplicationViewerPrivate(view)) | |
|
100 | { | |
|
101 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); | |
|
102 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
|
103 | 87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
104 | 88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
105 | 89 | #if !defined(NO_JSDEBUGGER) |
|
106 |
new QmlJSDebugger::JSDebuggerAgent( |
|
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
|
107 | 91 | #endif |
|
108 | 92 | #if !defined(NO_QMLOBSERVER) |
|
109 |
new QmlJSDebugger::QDeclarativeViewObserver( |
|
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
|
110 | 94 | #endif |
|
111 | 95 | #endif |
|
112 | 96 | } |
|
113 | 97 | |
|
114 | 98 | QmlApplicationViewer::~QmlApplicationViewer() |
|
115 | 99 | { |
|
116 | 100 | delete d; |
|
117 | 101 | } |
|
118 | 102 | |
|
119 | 103 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
120 | 104 | { |
|
121 | #ifdef HARMATTAN_BOOSTER | |
|
122 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); | |
|
123 | #else | |
|
124 | 105 | return new QmlApplicationViewer(); |
|
125 | #endif | |
|
126 | 106 | } |
|
127 | 107 | |
|
128 | 108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
129 | 109 | { |
|
130 |
d->mainQmlFile = |
|
|
131 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
|
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
|
111 | #ifdef Q_OS_ANDROID | |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
|
113 | #else | |
|
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
|
115 | #endif | |
|
132 | 116 | } |
|
133 | 117 | |
|
134 | 118 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
135 | 119 | { |
|
136 |
|
|
|
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
|
137 | 121 | } |
|
138 | 122 | |
|
139 |
|
|
|
140 | //{ | |
|
141 | //#if defined(Q_OS_SYMBIAN) | |
|
142 | // // If the version of Qt on the device is < 4.7.2, that attribute won't work | |
|
143 | // if (orientation != ScreenOrientationAuto) { | |
|
144 | // const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); | |
|
145 | // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { | |
|
146 | // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); | |
|
147 | // return; | |
|
148 |
|
|
|
149 | // } | |
|
150 | //#endif // Q_OS_SYMBIAN | |
|
151 | ||
|
152 | // Qt::WidgetAttribute attribute; | |
|
153 | // switch (orientation) { | |
|
154 | //#if QT_VERSION < 0x040702 | |
|
155 | // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
|
156 | // case ScreenOrientationLockPortrait: | |
|
157 | // attribute = static_cast<Qt::WidgetAttribute>(128); | |
|
158 | // break; | |
|
159 | // case ScreenOrientationLockLandscape: | |
|
160 | // attribute = static_cast<Qt::WidgetAttribute>(129); | |
|
161 | // break; | |
|
162 | // default: | |
|
163 | // case ScreenOrientationAuto: | |
|
164 | // attribute = static_cast<Qt::WidgetAttribute>(130); | |
|
165 | // break; | |
|
166 | //#else // QT_VERSION < 0x040702 | |
|
167 | // case ScreenOrientationLockPortrait: | |
|
168 | // attribute = Qt::WA_LockPortraitOrientation; | |
|
169 | // break; | |
|
170 | // case ScreenOrientationLockLandscape: | |
|
171 | // attribute = Qt::WA_LockLandscapeOrientation; | |
|
172 | // break; | |
|
173 | // default: | |
|
174 | // case ScreenOrientationAuto: | |
|
175 | // attribute = Qt::WA_AutoOrientation; | |
|
176 | // break; | |
|
177 | //#endif // QT_VERSION < 0x040702 | |
|
178 | // }; | |
|
179 | // setAttribute(attribute, true); | |
|
180 | //} | |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
|
124 | { | |
|
125 | #if QT_VERSION < 0x050000 | |
|
126 | Qt::WidgetAttribute attribute; | |
|
127 | switch (orientation) { | |
|
128 | #if QT_VERSION < 0x040702 | |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
|
130 | case ScreenOrientationLockPortrait: | |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
|
132 | break; | |
|
133 | case ScreenOrientationLockLandscape: | |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
|
135 | break; | |
|
136 | default: | |
|
137 | case ScreenOrientationAuto: | |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
|
139 | break; | |
|
140 | #else // QT_VERSION < 0x040702 | |
|
141 | case ScreenOrientationLockPortrait: | |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
|
143 | break; | |
|
144 | case ScreenOrientationLockLandscape: | |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
|
146 | break; | |
|
147 | default: | |
|
148 | case ScreenOrientationAuto: | |
|
149 | attribute = Qt::WA_AutoOrientation; | |
|
150 | break; | |
|
151 | #endif // QT_VERSION < 0x040702 | |
|
152 | }; | |
|
153 | setAttribute(attribute, true); | |
|
154 | #else // QT_VERSION < 0x050000 | |
|
155 | Q_UNUSED(orientation) | |
|
156 | #endif // QT_VERSION < 0x050000 | |
|
157 | } | |
|
181 | 158 | |
|
182 | 159 | void QmlApplicationViewer::showExpanded() |
|
183 | 160 | { |
|
184 |
#if defined( |
|
|
185 |
|
|
|
186 | #elif defined(Q_WS_MAEMO_5) | |
|
187 |
|
|
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
|
162 | showFullScreen(); | |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
|
164 | showMaximized(); | |
|
188 | 165 | #else |
|
189 |
|
|
|
166 | show(); | |
|
190 | 167 | #endif |
|
191 | 168 | } |
|
192 | 169 | |
|
193 | 170 | QApplication *createApplication(int &argc, char **argv) |
|
194 | 171 | { |
|
195 | 172 | #ifdef HARMATTAN_BOOSTER |
|
196 | 173 | return MDeclarativeCache::qApplication(argc, argv); |
|
197 | 174 | #else |
|
198 | 175 | return new QApplication(argc, argv); |
|
199 | 176 | #endif |
|
200 | 177 | } |
@@ -1,47 +1,46 | |||
|
1 |
// checksum 0x |
|
|
1 | // checksum 0xc67a version 0x80016 | |
|
2 | 2 | /* |
|
3 | 3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
4 | 4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
5 | 5 | code such as screen orientation handling. Also QML paths and debugging are |
|
6 | 6 | handled here. |
|
7 | 7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
8 | 8 | may offer an updated version of it. |
|
9 | 9 | */ |
|
10 | 10 | |
|
11 | 11 | #ifndef QMLAPPLICATIONVIEWER_H |
|
12 | 12 | #define QMLAPPLICATIONVIEWER_H |
|
13 | 13 | |
|
14 |
#include <Q |
|
|
14 | #include <QDeclarativeView> | |
|
15 | 15 | |
|
16 | 16 | class QmlApplicationViewer : public QDeclarativeView |
|
17 | 17 | { |
|
18 | 18 | Q_OBJECT |
|
19 | 19 | |
|
20 | 20 | public: |
|
21 | 21 | enum ScreenOrientation { |
|
22 | 22 | ScreenOrientationLockPortrait, |
|
23 | 23 | ScreenOrientationLockLandscape, |
|
24 | 24 | ScreenOrientationAuto |
|
25 | 25 | }; |
|
26 | 26 | |
|
27 | 27 | explicit QmlApplicationViewer(QWidget *parent = 0); |
|
28 | 28 | virtual ~QmlApplicationViewer(); |
|
29 | 29 | |
|
30 | 30 | static QmlApplicationViewer *create(); |
|
31 | 31 | |
|
32 | 32 | void setMainQmlFile(const QString &file); |
|
33 | 33 | void addImportPath(const QString &path); |
|
34 | 34 | |
|
35 |
// Note that this will only have an effect on |
|
|
36 |
|
|
|
35 | // Note that this will only have an effect on Fremantle. | |
|
36 | void setOrientation(ScreenOrientation orientation); | |
|
37 | 37 | |
|
38 | 38 | void showExpanded(); |
|
39 | 39 | |
|
40 | 40 | private: |
|
41 | explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); | |
|
42 | 41 | class QmlApplicationViewerPrivate *d; |
|
43 | 42 | }; |
|
44 | 43 | |
|
45 | 44 | QApplication *createApplication(int &argc, char **argv); |
|
46 | 45 | |
|
47 | 46 | #endif // QMLAPPLICATIONVIEWER_H |
General Comments 0
You need to be logged in to leave comments.
Login now