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