@@ -1,177 +1,177 | |||||
1 |
// checksum 0x |
|
1 | // checksum 0xaa72 version 0x90018 | |
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 <QDeclarativeComponent> |
|
16 | #include <QDeclarativeComponent> | |
17 | #include <QDeclarativeEngine> |
|
17 | #include <QDeclarativeEngine> | |
18 | #include <QDeclarativeContext> |
|
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_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 |
#elif defined(Q_OS_ |
|
64 | #elif defined(Q_OS_BLACKBERRY) | |
65 | if (!QDir::isAbsolutePath(path)) |
|
65 | if (!QDir::isAbsolutePath(path)) | |
66 | return QString::fromLatin1("app/native/%1").arg(path); |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
67 | #elif !defined(Q_OS_ANDROID) |
|
67 | #elif !defined(Q_OS_ANDROID) | |
68 | QString pathInInstallDir = |
|
68 | QString pathInInstallDir = | |
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); |
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
70 | if (QFileInfo(pathInInstallDir).exists()) |
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |
71 | return pathInInstallDir; |
|
71 | return pathInInstallDir; | |
72 | pathInInstallDir = |
|
72 | pathInInstallDir = | |
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
74 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |
75 | return pathInInstallDir; |
|
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 |
|
86 | |||
87 | // 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 | |
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
89 | #if !defined(NO_JSDEBUGGER) |
|
89 | #if !defined(NO_JSDEBUGGER) | |
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); |
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
91 | #endif |
|
91 | #endif | |
92 | #if !defined(NO_QMLOBSERVER) |
|
92 | #if !defined(NO_QMLOBSERVER) | |
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); |
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
94 | #endif |
|
94 | #endif | |
95 | #endif |
|
95 | #endif | |
96 | } |
|
96 | } | |
97 |
|
97 | |||
98 | QmlApplicationViewer::~QmlApplicationViewer() |
|
98 | QmlApplicationViewer::~QmlApplicationViewer() | |
99 | { |
|
99 | { | |
100 | delete d; |
|
100 | delete d; | |
101 | } |
|
101 | } | |
102 |
|
102 | |||
103 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
103 | QmlApplicationViewer *QmlApplicationViewer::create() | |
104 | { |
|
104 | { | |
105 | return new QmlApplicationViewer(); |
|
105 | return new QmlApplicationViewer(); | |
106 | } |
|
106 | } | |
107 |
|
107 | |||
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
109 | { |
|
109 | { | |
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); |
|
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
111 | #ifdef Q_OS_ANDROID |
|
111 | #ifdef Q_OS_ANDROID | |
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
113 | #else |
|
113 | #else | |
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
115 | #endif |
|
115 | #endif | |
116 | } |
|
116 | } | |
117 |
|
117 | |||
118 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
118 | void QmlApplicationViewer::addImportPath(const QString &path) | |
119 | { |
|
119 | { | |
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); |
|
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
121 | } |
|
121 | } | |
122 |
|
122 | |||
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
124 | { |
|
124 | { | |
125 | #if QT_VERSION < 0x050000 |
|
125 | #if QT_VERSION < 0x050000 | |
126 | Qt::WidgetAttribute attribute; |
|
126 | Qt::WidgetAttribute attribute; | |
127 | switch (orientation) { |
|
127 | switch (orientation) { | |
128 | #if QT_VERSION < 0x040702 |
|
128 | #if QT_VERSION < 0x040702 | |
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
130 | case ScreenOrientationLockPortrait: |
|
130 | case ScreenOrientationLockPortrait: | |
131 | attribute = static_cast<Qt::WidgetAttribute>(128); |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
132 | break; |
|
132 | break; | |
133 | case ScreenOrientationLockLandscape: |
|
133 | case ScreenOrientationLockLandscape: | |
134 | attribute = static_cast<Qt::WidgetAttribute>(129); |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
135 | break; |
|
135 | break; | |
136 | default: |
|
136 | default: | |
137 | case ScreenOrientationAuto: |
|
137 | case ScreenOrientationAuto: | |
138 | attribute = static_cast<Qt::WidgetAttribute>(130); |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
139 | break; |
|
139 | break; | |
140 | #else // QT_VERSION < 0x040702 |
|
140 | #else // QT_VERSION < 0x040702 | |
141 | case ScreenOrientationLockPortrait: |
|
141 | case ScreenOrientationLockPortrait: | |
142 | attribute = Qt::WA_LockPortraitOrientation; |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
143 | break; |
|
143 | break; | |
144 | case ScreenOrientationLockLandscape: |
|
144 | case ScreenOrientationLockLandscape: | |
145 | attribute = Qt::WA_LockLandscapeOrientation; |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
146 | break; |
|
146 | break; | |
147 | default: |
|
147 | default: | |
148 | case ScreenOrientationAuto: |
|
148 | case ScreenOrientationAuto: | |
149 | attribute = Qt::WA_AutoOrientation; |
|
149 | attribute = Qt::WA_AutoOrientation; | |
150 | break; |
|
150 | break; | |
151 | #endif // QT_VERSION < 0x040702 |
|
151 | #endif // QT_VERSION < 0x040702 | |
152 | }; |
|
152 | }; | |
153 | setAttribute(attribute, true); |
|
153 | setAttribute(attribute, true); | |
154 | #else // QT_VERSION < 0x050000 |
|
154 | #else // QT_VERSION < 0x050000 | |
155 | Q_UNUSED(orientation) |
|
155 | Q_UNUSED(orientation) | |
156 | #endif // QT_VERSION < 0x050000 |
|
156 | #endif // QT_VERSION < 0x050000 | |
157 | } |
|
157 | } | |
158 |
|
158 | |||
159 | void QmlApplicationViewer::showExpanded() |
|
159 | void QmlApplicationViewer::showExpanded() | |
160 | { |
|
160 | { | |
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
162 | showFullScreen(); |
|
162 | showFullScreen(); | |
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
164 | showMaximized(); |
|
164 | showMaximized(); | |
165 | #else |
|
165 | #else | |
166 | show(); |
|
166 | show(); | |
167 | #endif |
|
167 | #endif | |
168 | } |
|
168 | } | |
169 |
|
169 | |||
170 | QApplication *createApplication(int &argc, char **argv) |
|
170 | QApplication *createApplication(int &argc, char **argv) | |
171 | { |
|
171 | { | |
172 | #ifdef HARMATTAN_BOOSTER |
|
172 | #ifdef HARMATTAN_BOOSTER | |
173 | return MDeclarativeCache::qApplication(argc, argv); |
|
173 | return MDeclarativeCache::qApplication(argc, argv); | |
174 | #else |
|
174 | #else | |
175 | return new QApplication(argc, argv); |
|
175 | return new QApplication(argc, argv); | |
176 | #endif |
|
176 | #endif | |
177 | } |
|
177 | } |
@@ -1,46 +1,46 | |||||
1 |
// checksum 0xc67a version 0x |
|
1 | // checksum 0xc67a version 0x90018 | |
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 Fremantle. |
|
35 | // Note that this will only have an effect on Fremantle. | |
36 | void setOrientation(ScreenOrientation orientation); |
|
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,177 +1,177 | |||||
1 |
// checksum 0x |
|
1 | // checksum 0xaa72 version 0x90018 | |
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 <QDeclarativeComponent> |
|
16 | #include <QDeclarativeComponent> | |
17 | #include <QDeclarativeEngine> |
|
17 | #include <QDeclarativeEngine> | |
18 | #include <QDeclarativeContext> |
|
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_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 |
#elif defined(Q_OS_ |
|
64 | #elif defined(Q_OS_BLACKBERRY) | |
65 | if (!QDir::isAbsolutePath(path)) |
|
65 | if (!QDir::isAbsolutePath(path)) | |
66 | return QString::fromLatin1("app/native/%1").arg(path); |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
67 | #elif !defined(Q_OS_ANDROID) |
|
67 | #elif !defined(Q_OS_ANDROID) | |
68 | QString pathInInstallDir = |
|
68 | QString pathInInstallDir = | |
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); |
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
70 | if (QFileInfo(pathInInstallDir).exists()) |
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |
71 | return pathInInstallDir; |
|
71 | return pathInInstallDir; | |
72 | pathInInstallDir = |
|
72 | pathInInstallDir = | |
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
74 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |
75 | return pathInInstallDir; |
|
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 |
|
86 | |||
87 | // 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 | |
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
89 | #if !defined(NO_JSDEBUGGER) |
|
89 | #if !defined(NO_JSDEBUGGER) | |
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); |
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
91 | #endif |
|
91 | #endif | |
92 | #if !defined(NO_QMLOBSERVER) |
|
92 | #if !defined(NO_QMLOBSERVER) | |
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); |
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
94 | #endif |
|
94 | #endif | |
95 | #endif |
|
95 | #endif | |
96 | } |
|
96 | } | |
97 |
|
97 | |||
98 | QmlApplicationViewer::~QmlApplicationViewer() |
|
98 | QmlApplicationViewer::~QmlApplicationViewer() | |
99 | { |
|
99 | { | |
100 | delete d; |
|
100 | delete d; | |
101 | } |
|
101 | } | |
102 |
|
102 | |||
103 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
103 | QmlApplicationViewer *QmlApplicationViewer::create() | |
104 | { |
|
104 | { | |
105 | return new QmlApplicationViewer(); |
|
105 | return new QmlApplicationViewer(); | |
106 | } |
|
106 | } | |
107 |
|
107 | |||
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
109 | { |
|
109 | { | |
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); |
|
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
111 | #ifdef Q_OS_ANDROID |
|
111 | #ifdef Q_OS_ANDROID | |
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
113 | #else |
|
113 | #else | |
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
115 | #endif |
|
115 | #endif | |
116 | } |
|
116 | } | |
117 |
|
117 | |||
118 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
118 | void QmlApplicationViewer::addImportPath(const QString &path) | |
119 | { |
|
119 | { | |
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); |
|
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
121 | } |
|
121 | } | |
122 |
|
122 | |||
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
124 | { |
|
124 | { | |
125 | #if QT_VERSION < 0x050000 |
|
125 | #if QT_VERSION < 0x050000 | |
126 | Qt::WidgetAttribute attribute; |
|
126 | Qt::WidgetAttribute attribute; | |
127 | switch (orientation) { |
|
127 | switch (orientation) { | |
128 | #if QT_VERSION < 0x040702 |
|
128 | #if QT_VERSION < 0x040702 | |
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
130 | case ScreenOrientationLockPortrait: |
|
130 | case ScreenOrientationLockPortrait: | |
131 | attribute = static_cast<Qt::WidgetAttribute>(128); |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
132 | break; |
|
132 | break; | |
133 | case ScreenOrientationLockLandscape: |
|
133 | case ScreenOrientationLockLandscape: | |
134 | attribute = static_cast<Qt::WidgetAttribute>(129); |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
135 | break; |
|
135 | break; | |
136 | default: |
|
136 | default: | |
137 | case ScreenOrientationAuto: |
|
137 | case ScreenOrientationAuto: | |
138 | attribute = static_cast<Qt::WidgetAttribute>(130); |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
139 | break; |
|
139 | break; | |
140 | #else // QT_VERSION < 0x040702 |
|
140 | #else // QT_VERSION < 0x040702 | |
141 | case ScreenOrientationLockPortrait: |
|
141 | case ScreenOrientationLockPortrait: | |
142 | attribute = Qt::WA_LockPortraitOrientation; |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
143 | break; |
|
143 | break; | |
144 | case ScreenOrientationLockLandscape: |
|
144 | case ScreenOrientationLockLandscape: | |
145 | attribute = Qt::WA_LockLandscapeOrientation; |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
146 | break; |
|
146 | break; | |
147 | default: |
|
147 | default: | |
148 | case ScreenOrientationAuto: |
|
148 | case ScreenOrientationAuto: | |
149 | attribute = Qt::WA_AutoOrientation; |
|
149 | attribute = Qt::WA_AutoOrientation; | |
150 | break; |
|
150 | break; | |
151 | #endif // QT_VERSION < 0x040702 |
|
151 | #endif // QT_VERSION < 0x040702 | |
152 | }; |
|
152 | }; | |
153 | setAttribute(attribute, true); |
|
153 | setAttribute(attribute, true); | |
154 | #else // QT_VERSION < 0x050000 |
|
154 | #else // QT_VERSION < 0x050000 | |
155 | Q_UNUSED(orientation) |
|
155 | Q_UNUSED(orientation) | |
156 | #endif // QT_VERSION < 0x050000 |
|
156 | #endif // QT_VERSION < 0x050000 | |
157 | } |
|
157 | } | |
158 |
|
158 | |||
159 | void QmlApplicationViewer::showExpanded() |
|
159 | void QmlApplicationViewer::showExpanded() | |
160 | { |
|
160 | { | |
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
162 | showFullScreen(); |
|
162 | showFullScreen(); | |
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
164 | showMaximized(); |
|
164 | showMaximized(); | |
165 | #else |
|
165 | #else | |
166 | show(); |
|
166 | show(); | |
167 | #endif |
|
167 | #endif | |
168 | } |
|
168 | } | |
169 |
|
169 | |||
170 | QApplication *createApplication(int &argc, char **argv) |
|
170 | QApplication *createApplication(int &argc, char **argv) | |
171 | { |
|
171 | { | |
172 | #ifdef HARMATTAN_BOOSTER |
|
172 | #ifdef HARMATTAN_BOOSTER | |
173 | return MDeclarativeCache::qApplication(argc, argv); |
|
173 | return MDeclarativeCache::qApplication(argc, argv); | |
174 | #else |
|
174 | #else | |
175 | return new QApplication(argc, argv); |
|
175 | return new QApplication(argc, argv); | |
176 | #endif |
|
176 | #endif | |
177 | } |
|
177 | } |
@@ -1,46 +1,46 | |||||
1 |
// checksum 0xc67a version 0x |
|
1 | // checksum 0xc67a version 0x90018 | |
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 Fremantle. |
|
35 | // Note that this will only have an effect on Fremantle. | |
36 | void setOrientation(ScreenOrientation orientation); |
|
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,177 +1,177 | |||||
1 |
// checksum 0x |
|
1 | // checksum 0xaa72 version 0x90018 | |
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 <QDeclarativeComponent> |
|
16 | #include <QDeclarativeComponent> | |
17 | #include <QDeclarativeEngine> |
|
17 | #include <QDeclarativeEngine> | |
18 | #include <QDeclarativeContext> |
|
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_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 |
#elif defined(Q_OS_ |
|
64 | #elif defined(Q_OS_BLACKBERRY) | |
65 | if (!QDir::isAbsolutePath(path)) |
|
65 | if (!QDir::isAbsolutePath(path)) | |
66 | return QString::fromLatin1("app/native/%1").arg(path); |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
67 | #elif !defined(Q_OS_ANDROID) |
|
67 | #elif !defined(Q_OS_ANDROID) | |
68 | QString pathInInstallDir = |
|
68 | QString pathInInstallDir = | |
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); |
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
70 | if (QFileInfo(pathInInstallDir).exists()) |
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |
71 | return pathInInstallDir; |
|
71 | return pathInInstallDir; | |
72 | pathInInstallDir = |
|
72 | pathInInstallDir = | |
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
74 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |
75 | return pathInInstallDir; |
|
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 |
|
86 | |||
87 | // 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 | |
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
89 | #if !defined(NO_JSDEBUGGER) |
|
89 | #if !defined(NO_JSDEBUGGER) | |
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); |
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
91 | #endif |
|
91 | #endif | |
92 | #if !defined(NO_QMLOBSERVER) |
|
92 | #if !defined(NO_QMLOBSERVER) | |
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); |
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
94 | #endif |
|
94 | #endif | |
95 | #endif |
|
95 | #endif | |
96 | } |
|
96 | } | |
97 |
|
97 | |||
98 | QmlApplicationViewer::~QmlApplicationViewer() |
|
98 | QmlApplicationViewer::~QmlApplicationViewer() | |
99 | { |
|
99 | { | |
100 | delete d; |
|
100 | delete d; | |
101 | } |
|
101 | } | |
102 |
|
102 | |||
103 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
103 | QmlApplicationViewer *QmlApplicationViewer::create() | |
104 | { |
|
104 | { | |
105 | return new QmlApplicationViewer(); |
|
105 | return new QmlApplicationViewer(); | |
106 | } |
|
106 | } | |
107 |
|
107 | |||
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
109 | { |
|
109 | { | |
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); |
|
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
111 | #ifdef Q_OS_ANDROID |
|
111 | #ifdef Q_OS_ANDROID | |
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
113 | #else |
|
113 | #else | |
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
115 | #endif |
|
115 | #endif | |
116 | } |
|
116 | } | |
117 |
|
117 | |||
118 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
118 | void QmlApplicationViewer::addImportPath(const QString &path) | |
119 | { |
|
119 | { | |
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); |
|
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
121 | } |
|
121 | } | |
122 |
|
122 | |||
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
124 | { |
|
124 | { | |
125 | #if QT_VERSION < 0x050000 |
|
125 | #if QT_VERSION < 0x050000 | |
126 | Qt::WidgetAttribute attribute; |
|
126 | Qt::WidgetAttribute attribute; | |
127 | switch (orientation) { |
|
127 | switch (orientation) { | |
128 | #if QT_VERSION < 0x040702 |
|
128 | #if QT_VERSION < 0x040702 | |
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
130 | case ScreenOrientationLockPortrait: |
|
130 | case ScreenOrientationLockPortrait: | |
131 | attribute = static_cast<Qt::WidgetAttribute>(128); |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
132 | break; |
|
132 | break; | |
133 | case ScreenOrientationLockLandscape: |
|
133 | case ScreenOrientationLockLandscape: | |
134 | attribute = static_cast<Qt::WidgetAttribute>(129); |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
135 | break; |
|
135 | break; | |
136 | default: |
|
136 | default: | |
137 | case ScreenOrientationAuto: |
|
137 | case ScreenOrientationAuto: | |
138 | attribute = static_cast<Qt::WidgetAttribute>(130); |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
139 | break; |
|
139 | break; | |
140 | #else // QT_VERSION < 0x040702 |
|
140 | #else // QT_VERSION < 0x040702 | |
141 | case ScreenOrientationLockPortrait: |
|
141 | case ScreenOrientationLockPortrait: | |
142 | attribute = Qt::WA_LockPortraitOrientation; |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
143 | break; |
|
143 | break; | |
144 | case ScreenOrientationLockLandscape: |
|
144 | case ScreenOrientationLockLandscape: | |
145 | attribute = Qt::WA_LockLandscapeOrientation; |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
146 | break; |
|
146 | break; | |
147 | default: |
|
147 | default: | |
148 | case ScreenOrientationAuto: |
|
148 | case ScreenOrientationAuto: | |
149 | attribute = Qt::WA_AutoOrientation; |
|
149 | attribute = Qt::WA_AutoOrientation; | |
150 | break; |
|
150 | break; | |
151 | #endif // QT_VERSION < 0x040702 |
|
151 | #endif // QT_VERSION < 0x040702 | |
152 | }; |
|
152 | }; | |
153 | setAttribute(attribute, true); |
|
153 | setAttribute(attribute, true); | |
154 | #else // QT_VERSION < 0x050000 |
|
154 | #else // QT_VERSION < 0x050000 | |
155 | Q_UNUSED(orientation) |
|
155 | Q_UNUSED(orientation) | |
156 | #endif // QT_VERSION < 0x050000 |
|
156 | #endif // QT_VERSION < 0x050000 | |
157 | } |
|
157 | } | |
158 |
|
158 | |||
159 | void QmlApplicationViewer::showExpanded() |
|
159 | void QmlApplicationViewer::showExpanded() | |
160 | { |
|
160 | { | |
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
162 | showFullScreen(); |
|
162 | showFullScreen(); | |
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
164 | showMaximized(); |
|
164 | showMaximized(); | |
165 | #else |
|
165 | #else | |
166 | show(); |
|
166 | show(); | |
167 | #endif |
|
167 | #endif | |
168 | } |
|
168 | } | |
169 |
|
169 | |||
170 | QApplication *createApplication(int &argc, char **argv) |
|
170 | QApplication *createApplication(int &argc, char **argv) | |
171 | { |
|
171 | { | |
172 | #ifdef HARMATTAN_BOOSTER |
|
172 | #ifdef HARMATTAN_BOOSTER | |
173 | return MDeclarativeCache::qApplication(argc, argv); |
|
173 | return MDeclarativeCache::qApplication(argc, argv); | |
174 | #else |
|
174 | #else | |
175 | return new QApplication(argc, argv); |
|
175 | return new QApplication(argc, argv); | |
176 | #endif |
|
176 | #endif | |
177 | } |
|
177 | } |
@@ -1,46 +1,46 | |||||
1 |
// checksum 0xc67a version 0x |
|
1 | // checksum 0xc67a version 0x90018 | |
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 Fremantle. |
|
35 | // Note that this will only have an effect on Fremantle. | |
36 | void setOrientation(ScreenOrientation orientation); |
|
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,177 +1,177 | |||||
1 |
// checksum 0x |
|
1 | // checksum 0xaa72 version 0x90018 | |
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 <QDeclarativeComponent> |
|
16 | #include <QDeclarativeComponent> | |
17 | #include <QDeclarativeEngine> |
|
17 | #include <QDeclarativeEngine> | |
18 | #include <QDeclarativeContext> |
|
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_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 |
#elif defined(Q_OS_ |
|
64 | #elif defined(Q_OS_BLACKBERRY) | |
65 | if (!QDir::isAbsolutePath(path)) |
|
65 | if (!QDir::isAbsolutePath(path)) | |
66 | return QString::fromLatin1("app/native/%1").arg(path); |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
67 | #elif !defined(Q_OS_ANDROID) |
|
67 | #elif !defined(Q_OS_ANDROID) | |
68 | QString pathInInstallDir = |
|
68 | QString pathInInstallDir = | |
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); |
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
70 | if (QFileInfo(pathInInstallDir).exists()) |
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |
71 | return pathInInstallDir; |
|
71 | return pathInInstallDir; | |
72 | pathInInstallDir = |
|
72 | pathInInstallDir = | |
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
74 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |
75 | return pathInInstallDir; |
|
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 |
|
86 | |||
87 | // 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 | |
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
89 | #if !defined(NO_JSDEBUGGER) |
|
89 | #if !defined(NO_JSDEBUGGER) | |
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); |
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
91 | #endif |
|
91 | #endif | |
92 | #if !defined(NO_QMLOBSERVER) |
|
92 | #if !defined(NO_QMLOBSERVER) | |
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); |
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
94 | #endif |
|
94 | #endif | |
95 | #endif |
|
95 | #endif | |
96 | } |
|
96 | } | |
97 |
|
97 | |||
98 | QmlApplicationViewer::~QmlApplicationViewer() |
|
98 | QmlApplicationViewer::~QmlApplicationViewer() | |
99 | { |
|
99 | { | |
100 | delete d; |
|
100 | delete d; | |
101 | } |
|
101 | } | |
102 |
|
102 | |||
103 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
103 | QmlApplicationViewer *QmlApplicationViewer::create() | |
104 | { |
|
104 | { | |
105 | return new QmlApplicationViewer(); |
|
105 | return new QmlApplicationViewer(); | |
106 | } |
|
106 | } | |
107 |
|
107 | |||
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
109 | { |
|
109 | { | |
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); |
|
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
111 | #ifdef Q_OS_ANDROID |
|
111 | #ifdef Q_OS_ANDROID | |
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
113 | #else |
|
113 | #else | |
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
115 | #endif |
|
115 | #endif | |
116 | } |
|
116 | } | |
117 |
|
117 | |||
118 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
118 | void QmlApplicationViewer::addImportPath(const QString &path) | |
119 | { |
|
119 | { | |
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); |
|
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
121 | } |
|
121 | } | |
122 |
|
122 | |||
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
124 | { |
|
124 | { | |
125 | #if QT_VERSION < 0x050000 |
|
125 | #if QT_VERSION < 0x050000 | |
126 | Qt::WidgetAttribute attribute; |
|
126 | Qt::WidgetAttribute attribute; | |
127 | switch (orientation) { |
|
127 | switch (orientation) { | |
128 | #if QT_VERSION < 0x040702 |
|
128 | #if QT_VERSION < 0x040702 | |
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
130 | case ScreenOrientationLockPortrait: |
|
130 | case ScreenOrientationLockPortrait: | |
131 | attribute = static_cast<Qt::WidgetAttribute>(128); |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
132 | break; |
|
132 | break; | |
133 | case ScreenOrientationLockLandscape: |
|
133 | case ScreenOrientationLockLandscape: | |
134 | attribute = static_cast<Qt::WidgetAttribute>(129); |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
135 | break; |
|
135 | break; | |
136 | default: |
|
136 | default: | |
137 | case ScreenOrientationAuto: |
|
137 | case ScreenOrientationAuto: | |
138 | attribute = static_cast<Qt::WidgetAttribute>(130); |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
139 | break; |
|
139 | break; | |
140 | #else // QT_VERSION < 0x040702 |
|
140 | #else // QT_VERSION < 0x040702 | |
141 | case ScreenOrientationLockPortrait: |
|
141 | case ScreenOrientationLockPortrait: | |
142 | attribute = Qt::WA_LockPortraitOrientation; |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
143 | break; |
|
143 | break; | |
144 | case ScreenOrientationLockLandscape: |
|
144 | case ScreenOrientationLockLandscape: | |
145 | attribute = Qt::WA_LockLandscapeOrientation; |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
146 | break; |
|
146 | break; | |
147 | default: |
|
147 | default: | |
148 | case ScreenOrientationAuto: |
|
148 | case ScreenOrientationAuto: | |
149 | attribute = Qt::WA_AutoOrientation; |
|
149 | attribute = Qt::WA_AutoOrientation; | |
150 | break; |
|
150 | break; | |
151 | #endif // QT_VERSION < 0x040702 |
|
151 | #endif // QT_VERSION < 0x040702 | |
152 | }; |
|
152 | }; | |
153 | setAttribute(attribute, true); |
|
153 | setAttribute(attribute, true); | |
154 | #else // QT_VERSION < 0x050000 |
|
154 | #else // QT_VERSION < 0x050000 | |
155 | Q_UNUSED(orientation) |
|
155 | Q_UNUSED(orientation) | |
156 | #endif // QT_VERSION < 0x050000 |
|
156 | #endif // QT_VERSION < 0x050000 | |
157 | } |
|
157 | } | |
158 |
|
158 | |||
159 | void QmlApplicationViewer::showExpanded() |
|
159 | void QmlApplicationViewer::showExpanded() | |
160 | { |
|
160 | { | |
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
162 | showFullScreen(); |
|
162 | showFullScreen(); | |
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
164 | showMaximized(); |
|
164 | showMaximized(); | |
165 | #else |
|
165 | #else | |
166 | show(); |
|
166 | show(); | |
167 | #endif |
|
167 | #endif | |
168 | } |
|
168 | } | |
169 |
|
169 | |||
170 | QApplication *createApplication(int &argc, char **argv) |
|
170 | QApplication *createApplication(int &argc, char **argv) | |
171 | { |
|
171 | { | |
172 | #ifdef HARMATTAN_BOOSTER |
|
172 | #ifdef HARMATTAN_BOOSTER | |
173 | return MDeclarativeCache::qApplication(argc, argv); |
|
173 | return MDeclarativeCache::qApplication(argc, argv); | |
174 | #else |
|
174 | #else | |
175 | return new QApplication(argc, argv); |
|
175 | return new QApplication(argc, argv); | |
176 | #endif |
|
176 | #endif | |
177 | } |
|
177 | } |
@@ -1,46 +1,46 | |||||
1 |
// checksum 0xc67a version 0x |
|
1 | // checksum 0xc67a version 0x90018 | |
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 Fremantle. |
|
35 | // Note that this will only have an effect on Fremantle. | |
36 | void setOrientation(ScreenOrientation orientation); |
|
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,177 +1,177 | |||||
1 |
// checksum 0x |
|
1 | // checksum 0xaa72 version 0x90018 | |
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 <QDeclarativeComponent> |
|
16 | #include <QDeclarativeComponent> | |
17 | #include <QDeclarativeEngine> |
|
17 | #include <QDeclarativeEngine> | |
18 | #include <QDeclarativeContext> |
|
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_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 |
#elif defined(Q_OS_ |
|
64 | #elif defined(Q_OS_BLACKBERRY) | |
65 | if (!QDir::isAbsolutePath(path)) |
|
65 | if (!QDir::isAbsolutePath(path)) | |
66 | return QString::fromLatin1("app/native/%1").arg(path); |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
67 | #elif !defined(Q_OS_ANDROID) |
|
67 | #elif !defined(Q_OS_ANDROID) | |
68 | QString pathInInstallDir = |
|
68 | QString pathInInstallDir = | |
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); |
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
70 | if (QFileInfo(pathInInstallDir).exists()) |
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |
71 | return pathInInstallDir; |
|
71 | return pathInInstallDir; | |
72 | pathInInstallDir = |
|
72 | pathInInstallDir = | |
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
74 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |
75 | return pathInInstallDir; |
|
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 |
|
86 | |||
87 | // 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 | |
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
89 | #if !defined(NO_JSDEBUGGER) |
|
89 | #if !defined(NO_JSDEBUGGER) | |
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); |
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
91 | #endif |
|
91 | #endif | |
92 | #if !defined(NO_QMLOBSERVER) |
|
92 | #if !defined(NO_QMLOBSERVER) | |
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); |
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
94 | #endif |
|
94 | #endif | |
95 | #endif |
|
95 | #endif | |
96 | } |
|
96 | } | |
97 |
|
97 | |||
98 | QmlApplicationViewer::~QmlApplicationViewer() |
|
98 | QmlApplicationViewer::~QmlApplicationViewer() | |
99 | { |
|
99 | { | |
100 | delete d; |
|
100 | delete d; | |
101 | } |
|
101 | } | |
102 |
|
102 | |||
103 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
103 | QmlApplicationViewer *QmlApplicationViewer::create() | |
104 | { |
|
104 | { | |
105 | return new QmlApplicationViewer(); |
|
105 | return new QmlApplicationViewer(); | |
106 | } |
|
106 | } | |
107 |
|
107 | |||
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
109 | { |
|
109 | { | |
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); |
|
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
111 | #ifdef Q_OS_ANDROID |
|
111 | #ifdef Q_OS_ANDROID | |
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
113 | #else |
|
113 | #else | |
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
115 | #endif |
|
115 | #endif | |
116 | } |
|
116 | } | |
117 |
|
117 | |||
118 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
118 | void QmlApplicationViewer::addImportPath(const QString &path) | |
119 | { |
|
119 | { | |
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); |
|
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
121 | } |
|
121 | } | |
122 |
|
122 | |||
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
124 | { |
|
124 | { | |
125 | #if QT_VERSION < 0x050000 |
|
125 | #if QT_VERSION < 0x050000 | |
126 | Qt::WidgetAttribute attribute; |
|
126 | Qt::WidgetAttribute attribute; | |
127 | switch (orientation) { |
|
127 | switch (orientation) { | |
128 | #if QT_VERSION < 0x040702 |
|
128 | #if QT_VERSION < 0x040702 | |
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
130 | case ScreenOrientationLockPortrait: |
|
130 | case ScreenOrientationLockPortrait: | |
131 | attribute = static_cast<Qt::WidgetAttribute>(128); |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
132 | break; |
|
132 | break; | |
133 | case ScreenOrientationLockLandscape: |
|
133 | case ScreenOrientationLockLandscape: | |
134 | attribute = static_cast<Qt::WidgetAttribute>(129); |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
135 | break; |
|
135 | break; | |
136 | default: |
|
136 | default: | |
137 | case ScreenOrientationAuto: |
|
137 | case ScreenOrientationAuto: | |
138 | attribute = static_cast<Qt::WidgetAttribute>(130); |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
139 | break; |
|
139 | break; | |
140 | #else // QT_VERSION < 0x040702 |
|
140 | #else // QT_VERSION < 0x040702 | |
141 | case ScreenOrientationLockPortrait: |
|
141 | case ScreenOrientationLockPortrait: | |
142 | attribute = Qt::WA_LockPortraitOrientation; |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
143 | break; |
|
143 | break; | |
144 | case ScreenOrientationLockLandscape: |
|
144 | case ScreenOrientationLockLandscape: | |
145 | attribute = Qt::WA_LockLandscapeOrientation; |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
146 | break; |
|
146 | break; | |
147 | default: |
|
147 | default: | |
148 | case ScreenOrientationAuto: |
|
148 | case ScreenOrientationAuto: | |
149 | attribute = Qt::WA_AutoOrientation; |
|
149 | attribute = Qt::WA_AutoOrientation; | |
150 | break; |
|
150 | break; | |
151 | #endif // QT_VERSION < 0x040702 |
|
151 | #endif // QT_VERSION < 0x040702 | |
152 | }; |
|
152 | }; | |
153 | setAttribute(attribute, true); |
|
153 | setAttribute(attribute, true); | |
154 | #else // QT_VERSION < 0x050000 |
|
154 | #else // QT_VERSION < 0x050000 | |
155 | Q_UNUSED(orientation) |
|
155 | Q_UNUSED(orientation) | |
156 | #endif // QT_VERSION < 0x050000 |
|
156 | #endif // QT_VERSION < 0x050000 | |
157 | } |
|
157 | } | |
158 |
|
158 | |||
159 | void QmlApplicationViewer::showExpanded() |
|
159 | void QmlApplicationViewer::showExpanded() | |
160 | { |
|
160 | { | |
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
162 | showFullScreen(); |
|
162 | showFullScreen(); | |
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
164 | showMaximized(); |
|
164 | showMaximized(); | |
165 | #else |
|
165 | #else | |
166 | show(); |
|
166 | show(); | |
167 | #endif |
|
167 | #endif | |
168 | } |
|
168 | } | |
169 |
|
169 | |||
170 | QApplication *createApplication(int &argc, char **argv) |
|
170 | QApplication *createApplication(int &argc, char **argv) | |
171 | { |
|
171 | { | |
172 | #ifdef HARMATTAN_BOOSTER |
|
172 | #ifdef HARMATTAN_BOOSTER | |
173 | return MDeclarativeCache::qApplication(argc, argv); |
|
173 | return MDeclarativeCache::qApplication(argc, argv); | |
174 | #else |
|
174 | #else | |
175 | return new QApplication(argc, argv); |
|
175 | return new QApplication(argc, argv); | |
176 | #endif |
|
176 | #endif | |
177 | } |
|
177 | } |
@@ -1,46 +1,46 | |||||
1 |
// checksum 0xc67a version 0x |
|
1 | // checksum 0xc67a version 0x90018 | |
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 Fremantle. |
|
35 | // Note that this will only have an effect on Fremantle. | |
36 | void setOrientation(ScreenOrientation orientation); |
|
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,177 +1,177 | |||||
1 |
// checksum 0x |
|
1 | // checksum 0xaa72 version 0x90018 | |
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 <QDeclarativeComponent> |
|
16 | #include <QDeclarativeComponent> | |
17 | #include <QDeclarativeEngine> |
|
17 | #include <QDeclarativeEngine> | |
18 | #include <QDeclarativeContext> |
|
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_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 |
#elif defined(Q_OS_ |
|
64 | #elif defined(Q_OS_BLACKBERRY) | |
65 | if (!QDir::isAbsolutePath(path)) |
|
65 | if (!QDir::isAbsolutePath(path)) | |
66 | return QString::fromLatin1("app/native/%1").arg(path); |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
67 | #elif !defined(Q_OS_ANDROID) |
|
67 | #elif !defined(Q_OS_ANDROID) | |
68 | QString pathInInstallDir = |
|
68 | QString pathInInstallDir = | |
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); |
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
70 | if (QFileInfo(pathInInstallDir).exists()) |
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |
71 | return pathInInstallDir; |
|
71 | return pathInInstallDir; | |
72 | pathInInstallDir = |
|
72 | pathInInstallDir = | |
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
74 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |
75 | return pathInInstallDir; |
|
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 |
|
86 | |||
87 | // 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 | |
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
89 | #if !defined(NO_JSDEBUGGER) |
|
89 | #if !defined(NO_JSDEBUGGER) | |
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); |
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
91 | #endif |
|
91 | #endif | |
92 | #if !defined(NO_QMLOBSERVER) |
|
92 | #if !defined(NO_QMLOBSERVER) | |
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); |
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
94 | #endif |
|
94 | #endif | |
95 | #endif |
|
95 | #endif | |
96 | } |
|
96 | } | |
97 |
|
97 | |||
98 | QmlApplicationViewer::~QmlApplicationViewer() |
|
98 | QmlApplicationViewer::~QmlApplicationViewer() | |
99 | { |
|
99 | { | |
100 | delete d; |
|
100 | delete d; | |
101 | } |
|
101 | } | |
102 |
|
102 | |||
103 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
103 | QmlApplicationViewer *QmlApplicationViewer::create() | |
104 | { |
|
104 | { | |
105 | return new QmlApplicationViewer(); |
|
105 | return new QmlApplicationViewer(); | |
106 | } |
|
106 | } | |
107 |
|
107 | |||
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
109 | { |
|
109 | { | |
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); |
|
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
111 | #ifdef Q_OS_ANDROID |
|
111 | #ifdef Q_OS_ANDROID | |
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
113 | #else |
|
113 | #else | |
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
115 | #endif |
|
115 | #endif | |
116 | } |
|
116 | } | |
117 |
|
117 | |||
118 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
118 | void QmlApplicationViewer::addImportPath(const QString &path) | |
119 | { |
|
119 | { | |
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); |
|
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
121 | } |
|
121 | } | |
122 |
|
122 | |||
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
124 | { |
|
124 | { | |
125 | #if QT_VERSION < 0x050000 |
|
125 | #if QT_VERSION < 0x050000 | |
126 | Qt::WidgetAttribute attribute; |
|
126 | Qt::WidgetAttribute attribute; | |
127 | switch (orientation) { |
|
127 | switch (orientation) { | |
128 | #if QT_VERSION < 0x040702 |
|
128 | #if QT_VERSION < 0x040702 | |
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
130 | case ScreenOrientationLockPortrait: |
|
130 | case ScreenOrientationLockPortrait: | |
131 | attribute = static_cast<Qt::WidgetAttribute>(128); |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
132 | break; |
|
132 | break; | |
133 | case ScreenOrientationLockLandscape: |
|
133 | case ScreenOrientationLockLandscape: | |
134 | attribute = static_cast<Qt::WidgetAttribute>(129); |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
135 | break; |
|
135 | break; | |
136 | default: |
|
136 | default: | |
137 | case ScreenOrientationAuto: |
|
137 | case ScreenOrientationAuto: | |
138 | attribute = static_cast<Qt::WidgetAttribute>(130); |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
139 | break; |
|
139 | break; | |
140 | #else // QT_VERSION < 0x040702 |
|
140 | #else // QT_VERSION < 0x040702 | |
141 | case ScreenOrientationLockPortrait: |
|
141 | case ScreenOrientationLockPortrait: | |
142 | attribute = Qt::WA_LockPortraitOrientation; |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
143 | break; |
|
143 | break; | |
144 | case ScreenOrientationLockLandscape: |
|
144 | case ScreenOrientationLockLandscape: | |
145 | attribute = Qt::WA_LockLandscapeOrientation; |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
146 | break; |
|
146 | break; | |
147 | default: |
|
147 | default: | |
148 | case ScreenOrientationAuto: |
|
148 | case ScreenOrientationAuto: | |
149 | attribute = Qt::WA_AutoOrientation; |
|
149 | attribute = Qt::WA_AutoOrientation; | |
150 | break; |
|
150 | break; | |
151 | #endif // QT_VERSION < 0x040702 |
|
151 | #endif // QT_VERSION < 0x040702 | |
152 | }; |
|
152 | }; | |
153 | setAttribute(attribute, true); |
|
153 | setAttribute(attribute, true); | |
154 | #else // QT_VERSION < 0x050000 |
|
154 | #else // QT_VERSION < 0x050000 | |
155 | Q_UNUSED(orientation) |
|
155 | Q_UNUSED(orientation) | |
156 | #endif // QT_VERSION < 0x050000 |
|
156 | #endif // QT_VERSION < 0x050000 | |
157 | } |
|
157 | } | |
158 |
|
158 | |||
159 | void QmlApplicationViewer::showExpanded() |
|
159 | void QmlApplicationViewer::showExpanded() | |
160 | { |
|
160 | { | |
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
162 | showFullScreen(); |
|
162 | showFullScreen(); | |
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
164 | showMaximized(); |
|
164 | showMaximized(); | |
165 | #else |
|
165 | #else | |
166 | show(); |
|
166 | show(); | |
167 | #endif |
|
167 | #endif | |
168 | } |
|
168 | } | |
169 |
|
169 | |||
170 | QApplication *createApplication(int &argc, char **argv) |
|
170 | QApplication *createApplication(int &argc, char **argv) | |
171 | { |
|
171 | { | |
172 | #ifdef HARMATTAN_BOOSTER |
|
172 | #ifdef HARMATTAN_BOOSTER | |
173 | return MDeclarativeCache::qApplication(argc, argv); |
|
173 | return MDeclarativeCache::qApplication(argc, argv); | |
174 | #else |
|
174 | #else | |
175 | return new QApplication(argc, argv); |
|
175 | return new QApplication(argc, argv); | |
176 | #endif |
|
176 | #endif | |
177 | } |
|
177 | } |
@@ -1,46 +1,46 | |||||
1 |
// checksum 0xc67a version 0x |
|
1 | // checksum 0xc67a version 0x90018 | |
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 Fremantle. |
|
35 | // Note that this will only have an effect on Fremantle. | |
36 | void setOrientation(ScreenOrientation orientation); |
|
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,177 +1,177 | |||||
1 |
// checksum 0x |
|
1 | // checksum 0xaa72 version 0x90018 | |
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 <QDeclarativeComponent> |
|
16 | #include <QDeclarativeComponent> | |
17 | #include <QDeclarativeEngine> |
|
17 | #include <QDeclarativeEngine> | |
18 | #include <QDeclarativeContext> |
|
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_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 |
#elif defined(Q_OS_ |
|
64 | #elif defined(Q_OS_BLACKBERRY) | |
65 | if (!QDir::isAbsolutePath(path)) |
|
65 | if (!QDir::isAbsolutePath(path)) | |
66 | return QString::fromLatin1("app/native/%1").arg(path); |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
67 | #elif !defined(Q_OS_ANDROID) |
|
67 | #elif !defined(Q_OS_ANDROID) | |
68 | QString pathInInstallDir = |
|
68 | QString pathInInstallDir = | |
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); |
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
70 | if (QFileInfo(pathInInstallDir).exists()) |
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |
71 | return pathInInstallDir; |
|
71 | return pathInInstallDir; | |
72 | pathInInstallDir = |
|
72 | pathInInstallDir = | |
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
74 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |
75 | return pathInInstallDir; |
|
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 |
|
86 | |||
87 | // 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 | |
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
89 | #if !defined(NO_JSDEBUGGER) |
|
89 | #if !defined(NO_JSDEBUGGER) | |
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); |
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
91 | #endif |
|
91 | #endif | |
92 | #if !defined(NO_QMLOBSERVER) |
|
92 | #if !defined(NO_QMLOBSERVER) | |
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); |
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
94 | #endif |
|
94 | #endif | |
95 | #endif |
|
95 | #endif | |
96 | } |
|
96 | } | |
97 |
|
97 | |||
98 | QmlApplicationViewer::~QmlApplicationViewer() |
|
98 | QmlApplicationViewer::~QmlApplicationViewer() | |
99 | { |
|
99 | { | |
100 | delete d; |
|
100 | delete d; | |
101 | } |
|
101 | } | |
102 |
|
102 | |||
103 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
103 | QmlApplicationViewer *QmlApplicationViewer::create() | |
104 | { |
|
104 | { | |
105 | return new QmlApplicationViewer(); |
|
105 | return new QmlApplicationViewer(); | |
106 | } |
|
106 | } | |
107 |
|
107 | |||
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
109 | { |
|
109 | { | |
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); |
|
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
111 | #ifdef Q_OS_ANDROID |
|
111 | #ifdef Q_OS_ANDROID | |
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
113 | #else |
|
113 | #else | |
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
115 | #endif |
|
115 | #endif | |
116 | } |
|
116 | } | |
117 |
|
117 | |||
118 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
118 | void QmlApplicationViewer::addImportPath(const QString &path) | |
119 | { |
|
119 | { | |
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); |
|
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
121 | } |
|
121 | } | |
122 |
|
122 | |||
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
124 | { |
|
124 | { | |
125 | #if QT_VERSION < 0x050000 |
|
125 | #if QT_VERSION < 0x050000 | |
126 | Qt::WidgetAttribute attribute; |
|
126 | Qt::WidgetAttribute attribute; | |
127 | switch (orientation) { |
|
127 | switch (orientation) { | |
128 | #if QT_VERSION < 0x040702 |
|
128 | #if QT_VERSION < 0x040702 | |
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
130 | case ScreenOrientationLockPortrait: |
|
130 | case ScreenOrientationLockPortrait: | |
131 | attribute = static_cast<Qt::WidgetAttribute>(128); |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
132 | break; |
|
132 | break; | |
133 | case ScreenOrientationLockLandscape: |
|
133 | case ScreenOrientationLockLandscape: | |
134 | attribute = static_cast<Qt::WidgetAttribute>(129); |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
135 | break; |
|
135 | break; | |
136 | default: |
|
136 | default: | |
137 | case ScreenOrientationAuto: |
|
137 | case ScreenOrientationAuto: | |
138 | attribute = static_cast<Qt::WidgetAttribute>(130); |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
139 | break; |
|
139 | break; | |
140 | #else // QT_VERSION < 0x040702 |
|
140 | #else // QT_VERSION < 0x040702 | |
141 | case ScreenOrientationLockPortrait: |
|
141 | case ScreenOrientationLockPortrait: | |
142 | attribute = Qt::WA_LockPortraitOrientation; |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
143 | break; |
|
143 | break; | |
144 | case ScreenOrientationLockLandscape: |
|
144 | case ScreenOrientationLockLandscape: | |
145 | attribute = Qt::WA_LockLandscapeOrientation; |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
146 | break; |
|
146 | break; | |
147 | default: |
|
147 | default: | |
148 | case ScreenOrientationAuto: |
|
148 | case ScreenOrientationAuto: | |
149 | attribute = Qt::WA_AutoOrientation; |
|
149 | attribute = Qt::WA_AutoOrientation; | |
150 | break; |
|
150 | break; | |
151 | #endif // QT_VERSION < 0x040702 |
|
151 | #endif // QT_VERSION < 0x040702 | |
152 | }; |
|
152 | }; | |
153 | setAttribute(attribute, true); |
|
153 | setAttribute(attribute, true); | |
154 | #else // QT_VERSION < 0x050000 |
|
154 | #else // QT_VERSION < 0x050000 | |
155 | Q_UNUSED(orientation) |
|
155 | Q_UNUSED(orientation) | |
156 | #endif // QT_VERSION < 0x050000 |
|
156 | #endif // QT_VERSION < 0x050000 | |
157 | } |
|
157 | } | |
158 |
|
158 | |||
159 | void QmlApplicationViewer::showExpanded() |
|
159 | void QmlApplicationViewer::showExpanded() | |
160 | { |
|
160 | { | |
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
162 | showFullScreen(); |
|
162 | showFullScreen(); | |
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
164 | showMaximized(); |
|
164 | showMaximized(); | |
165 | #else |
|
165 | #else | |
166 | show(); |
|
166 | show(); | |
167 | #endif |
|
167 | #endif | |
168 | } |
|
168 | } | |
169 |
|
169 | |||
170 | QApplication *createApplication(int &argc, char **argv) |
|
170 | QApplication *createApplication(int &argc, char **argv) | |
171 | { |
|
171 | { | |
172 | #ifdef HARMATTAN_BOOSTER |
|
172 | #ifdef HARMATTAN_BOOSTER | |
173 | return MDeclarativeCache::qApplication(argc, argv); |
|
173 | return MDeclarativeCache::qApplication(argc, argv); | |
174 | #else |
|
174 | #else | |
175 | return new QApplication(argc, argv); |
|
175 | return new QApplication(argc, argv); | |
176 | #endif |
|
176 | #endif | |
177 | } |
|
177 | } |
@@ -1,46 +1,46 | |||||
1 |
// checksum 0xc67a version 0x |
|
1 | // checksum 0xc67a version 0x90018 | |
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 Fremantle. |
|
35 | // Note that this will only have an effect on Fremantle. | |
36 | void setOrientation(ScreenOrientation orientation); |
|
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,177 +1,177 | |||||
1 |
// checksum 0x |
|
1 | // checksum 0xaa72 version 0x90018 | |
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 <QDeclarativeComponent> |
|
16 | #include <QDeclarativeComponent> | |
17 | #include <QDeclarativeEngine> |
|
17 | #include <QDeclarativeEngine> | |
18 | #include <QDeclarativeContext> |
|
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_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 |
#elif defined(Q_OS_ |
|
64 | #elif defined(Q_OS_BLACKBERRY) | |
65 | if (!QDir::isAbsolutePath(path)) |
|
65 | if (!QDir::isAbsolutePath(path)) | |
66 | return QString::fromLatin1("app/native/%1").arg(path); |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
67 | #elif !defined(Q_OS_ANDROID) |
|
67 | #elif !defined(Q_OS_ANDROID) | |
68 | QString pathInInstallDir = |
|
68 | QString pathInInstallDir = | |
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); |
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
70 | if (QFileInfo(pathInInstallDir).exists()) |
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |
71 | return pathInInstallDir; |
|
71 | return pathInInstallDir; | |
72 | pathInInstallDir = |
|
72 | pathInInstallDir = | |
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
74 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |
75 | return pathInInstallDir; |
|
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 |
|
86 | |||
87 | // 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 | |
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
89 | #if !defined(NO_JSDEBUGGER) |
|
89 | #if !defined(NO_JSDEBUGGER) | |
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); |
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
91 | #endif |
|
91 | #endif | |
92 | #if !defined(NO_QMLOBSERVER) |
|
92 | #if !defined(NO_QMLOBSERVER) | |
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); |
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
94 | #endif |
|
94 | #endif | |
95 | #endif |
|
95 | #endif | |
96 | } |
|
96 | } | |
97 |
|
97 | |||
98 | QmlApplicationViewer::~QmlApplicationViewer() |
|
98 | QmlApplicationViewer::~QmlApplicationViewer() | |
99 | { |
|
99 | { | |
100 | delete d; |
|
100 | delete d; | |
101 | } |
|
101 | } | |
102 |
|
102 | |||
103 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
103 | QmlApplicationViewer *QmlApplicationViewer::create() | |
104 | { |
|
104 | { | |
105 | return new QmlApplicationViewer(); |
|
105 | return new QmlApplicationViewer(); | |
106 | } |
|
106 | } | |
107 |
|
107 | |||
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
109 | { |
|
109 | { | |
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); |
|
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
111 | #ifdef Q_OS_ANDROID |
|
111 | #ifdef Q_OS_ANDROID | |
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
113 | #else |
|
113 | #else | |
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
115 | #endif |
|
115 | #endif | |
116 | } |
|
116 | } | |
117 |
|
117 | |||
118 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
118 | void QmlApplicationViewer::addImportPath(const QString &path) | |
119 | { |
|
119 | { | |
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); |
|
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
121 | } |
|
121 | } | |
122 |
|
122 | |||
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
124 | { |
|
124 | { | |
125 | #if QT_VERSION < 0x050000 |
|
125 | #if QT_VERSION < 0x050000 | |
126 | Qt::WidgetAttribute attribute; |
|
126 | Qt::WidgetAttribute attribute; | |
127 | switch (orientation) { |
|
127 | switch (orientation) { | |
128 | #if QT_VERSION < 0x040702 |
|
128 | #if QT_VERSION < 0x040702 | |
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
130 | case ScreenOrientationLockPortrait: |
|
130 | case ScreenOrientationLockPortrait: | |
131 | attribute = static_cast<Qt::WidgetAttribute>(128); |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
132 | break; |
|
132 | break; | |
133 | case ScreenOrientationLockLandscape: |
|
133 | case ScreenOrientationLockLandscape: | |
134 | attribute = static_cast<Qt::WidgetAttribute>(129); |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
135 | break; |
|
135 | break; | |
136 | default: |
|
136 | default: | |
137 | case ScreenOrientationAuto: |
|
137 | case ScreenOrientationAuto: | |
138 | attribute = static_cast<Qt::WidgetAttribute>(130); |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
139 | break; |
|
139 | break; | |
140 | #else // QT_VERSION < 0x040702 |
|
140 | #else // QT_VERSION < 0x040702 | |
141 | case ScreenOrientationLockPortrait: |
|
141 | case ScreenOrientationLockPortrait: | |
142 | attribute = Qt::WA_LockPortraitOrientation; |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
143 | break; |
|
143 | break; | |
144 | case ScreenOrientationLockLandscape: |
|
144 | case ScreenOrientationLockLandscape: | |
145 | attribute = Qt::WA_LockLandscapeOrientation; |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
146 | break; |
|
146 | break; | |
147 | default: |
|
147 | default: | |
148 | case ScreenOrientationAuto: |
|
148 | case ScreenOrientationAuto: | |
149 | attribute = Qt::WA_AutoOrientation; |
|
149 | attribute = Qt::WA_AutoOrientation; | |
150 | break; |
|
150 | break; | |
151 | #endif // QT_VERSION < 0x040702 |
|
151 | #endif // QT_VERSION < 0x040702 | |
152 | }; |
|
152 | }; | |
153 | setAttribute(attribute, true); |
|
153 | setAttribute(attribute, true); | |
154 | #else // QT_VERSION < 0x050000 |
|
154 | #else // QT_VERSION < 0x050000 | |
155 | Q_UNUSED(orientation) |
|
155 | Q_UNUSED(orientation) | |
156 | #endif // QT_VERSION < 0x050000 |
|
156 | #endif // QT_VERSION < 0x050000 | |
157 | } |
|
157 | } | |
158 |
|
158 | |||
159 | void QmlApplicationViewer::showExpanded() |
|
159 | void QmlApplicationViewer::showExpanded() | |
160 | { |
|
160 | { | |
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
162 | showFullScreen(); |
|
162 | showFullScreen(); | |
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
164 | showMaximized(); |
|
164 | showMaximized(); | |
165 | #else |
|
165 | #else | |
166 | show(); |
|
166 | show(); | |
167 | #endif |
|
167 | #endif | |
168 | } |
|
168 | } | |
169 |
|
169 | |||
170 | QApplication *createApplication(int &argc, char **argv) |
|
170 | QApplication *createApplication(int &argc, char **argv) | |
171 | { |
|
171 | { | |
172 | #ifdef HARMATTAN_BOOSTER |
|
172 | #ifdef HARMATTAN_BOOSTER | |
173 | return MDeclarativeCache::qApplication(argc, argv); |
|
173 | return MDeclarativeCache::qApplication(argc, argv); | |
174 | #else |
|
174 | #else | |
175 | return new QApplication(argc, argv); |
|
175 | return new QApplication(argc, argv); | |
176 | #endif |
|
176 | #endif | |
177 | } |
|
177 | } |
@@ -1,46 +1,46 | |||||
1 |
// checksum 0xc67a version 0x |
|
1 | // checksum 0xc67a version 0x90018 | |
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 Fremantle. |
|
35 | // Note that this will only have an effect on Fremantle. | |
36 | void setOrientation(ScreenOrientation orientation); |
|
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,177 +1,177 | |||||
1 |
// checksum 0x |
|
1 | // checksum 0xaa72 version 0x90018 | |
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 <QDeclarativeComponent> |
|
16 | #include <QDeclarativeComponent> | |
17 | #include <QDeclarativeEngine> |
|
17 | #include <QDeclarativeEngine> | |
18 | #include <QDeclarativeContext> |
|
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_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 |
#elif defined(Q_OS_ |
|
64 | #elif defined(Q_OS_BLACKBERRY) | |
65 | if (!QDir::isAbsolutePath(path)) |
|
65 | if (!QDir::isAbsolutePath(path)) | |
66 | return QString::fromLatin1("app/native/%1").arg(path); |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
67 | #elif !defined(Q_OS_ANDROID) |
|
67 | #elif !defined(Q_OS_ANDROID) | |
68 | QString pathInInstallDir = |
|
68 | QString pathInInstallDir = | |
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); |
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
70 | if (QFileInfo(pathInInstallDir).exists()) |
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |
71 | return pathInInstallDir; |
|
71 | return pathInInstallDir; | |
72 | pathInInstallDir = |
|
72 | pathInInstallDir = | |
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
74 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |
75 | return pathInInstallDir; |
|
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 |
|
86 | |||
87 | // 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 | |
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
89 | #if !defined(NO_JSDEBUGGER) |
|
89 | #if !defined(NO_JSDEBUGGER) | |
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); |
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
91 | #endif |
|
91 | #endif | |
92 | #if !defined(NO_QMLOBSERVER) |
|
92 | #if !defined(NO_QMLOBSERVER) | |
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); |
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
94 | #endif |
|
94 | #endif | |
95 | #endif |
|
95 | #endif | |
96 | } |
|
96 | } | |
97 |
|
97 | |||
98 | QmlApplicationViewer::~QmlApplicationViewer() |
|
98 | QmlApplicationViewer::~QmlApplicationViewer() | |
99 | { |
|
99 | { | |
100 | delete d; |
|
100 | delete d; | |
101 | } |
|
101 | } | |
102 |
|
102 | |||
103 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
103 | QmlApplicationViewer *QmlApplicationViewer::create() | |
104 | { |
|
104 | { | |
105 | return new QmlApplicationViewer(); |
|
105 | return new QmlApplicationViewer(); | |
106 | } |
|
106 | } | |
107 |
|
107 | |||
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
109 | { |
|
109 | { | |
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); |
|
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
111 | #ifdef Q_OS_ANDROID |
|
111 | #ifdef Q_OS_ANDROID | |
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
113 | #else |
|
113 | #else | |
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
115 | #endif |
|
115 | #endif | |
116 | } |
|
116 | } | |
117 |
|
117 | |||
118 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
118 | void QmlApplicationViewer::addImportPath(const QString &path) | |
119 | { |
|
119 | { | |
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); |
|
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
121 | } |
|
121 | } | |
122 |
|
122 | |||
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
124 | { |
|
124 | { | |
125 | #if QT_VERSION < 0x050000 |
|
125 | #if QT_VERSION < 0x050000 | |
126 | Qt::WidgetAttribute attribute; |
|
126 | Qt::WidgetAttribute attribute; | |
127 | switch (orientation) { |
|
127 | switch (orientation) { | |
128 | #if QT_VERSION < 0x040702 |
|
128 | #if QT_VERSION < 0x040702 | |
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
130 | case ScreenOrientationLockPortrait: |
|
130 | case ScreenOrientationLockPortrait: | |
131 | attribute = static_cast<Qt::WidgetAttribute>(128); |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
132 | break; |
|
132 | break; | |
133 | case ScreenOrientationLockLandscape: |
|
133 | case ScreenOrientationLockLandscape: | |
134 | attribute = static_cast<Qt::WidgetAttribute>(129); |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
135 | break; |
|
135 | break; | |
136 | default: |
|
136 | default: | |
137 | case ScreenOrientationAuto: |
|
137 | case ScreenOrientationAuto: | |
138 | attribute = static_cast<Qt::WidgetAttribute>(130); |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
139 | break; |
|
139 | break; | |
140 | #else // QT_VERSION < 0x040702 |
|
140 | #else // QT_VERSION < 0x040702 | |
141 | case ScreenOrientationLockPortrait: |
|
141 | case ScreenOrientationLockPortrait: | |
142 | attribute = Qt::WA_LockPortraitOrientation; |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
143 | break; |
|
143 | break; | |
144 | case ScreenOrientationLockLandscape: |
|
144 | case ScreenOrientationLockLandscape: | |
145 | attribute = Qt::WA_LockLandscapeOrientation; |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
146 | break; |
|
146 | break; | |
147 | default: |
|
147 | default: | |
148 | case ScreenOrientationAuto: |
|
148 | case ScreenOrientationAuto: | |
149 | attribute = Qt::WA_AutoOrientation; |
|
149 | attribute = Qt::WA_AutoOrientation; | |
150 | break; |
|
150 | break; | |
151 | #endif // QT_VERSION < 0x040702 |
|
151 | #endif // QT_VERSION < 0x040702 | |
152 | }; |
|
152 | }; | |
153 | setAttribute(attribute, true); |
|
153 | setAttribute(attribute, true); | |
154 | #else // QT_VERSION < 0x050000 |
|
154 | #else // QT_VERSION < 0x050000 | |
155 | Q_UNUSED(orientation) |
|
155 | Q_UNUSED(orientation) | |
156 | #endif // QT_VERSION < 0x050000 |
|
156 | #endif // QT_VERSION < 0x050000 | |
157 | } |
|
157 | } | |
158 |
|
158 | |||
159 | void QmlApplicationViewer::showExpanded() |
|
159 | void QmlApplicationViewer::showExpanded() | |
160 | { |
|
160 | { | |
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
162 | showFullScreen(); |
|
162 | showFullScreen(); | |
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
164 | showMaximized(); |
|
164 | showMaximized(); | |
165 | #else |
|
165 | #else | |
166 | show(); |
|
166 | show(); | |
167 | #endif |
|
167 | #endif | |
168 | } |
|
168 | } | |
169 |
|
169 | |||
170 | QApplication *createApplication(int &argc, char **argv) |
|
170 | QApplication *createApplication(int &argc, char **argv) | |
171 | { |
|
171 | { | |
172 | #ifdef HARMATTAN_BOOSTER |
|
172 | #ifdef HARMATTAN_BOOSTER | |
173 | return MDeclarativeCache::qApplication(argc, argv); |
|
173 | return MDeclarativeCache::qApplication(argc, argv); | |
174 | #else |
|
174 | #else | |
175 | return new QApplication(argc, argv); |
|
175 | return new QApplication(argc, argv); | |
176 | #endif |
|
176 | #endif | |
177 | } |
|
177 | } |
@@ -1,46 +1,46 | |||||
1 |
// checksum 0xc67a version 0x |
|
1 | // checksum 0xc67a version 0x90018 | |
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 Fremantle. |
|
35 | // Note that this will only have an effect on Fremantle. | |
36 | void setOrientation(ScreenOrientation orientation); |
|
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,177 +1,177 | |||||
1 |
// checksum 0x |
|
1 | // checksum 0xaa72 version 0x90018 | |
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 <QDeclarativeComponent> |
|
16 | #include <QDeclarativeComponent> | |
17 | #include <QDeclarativeEngine> |
|
17 | #include <QDeclarativeEngine> | |
18 | #include <QDeclarativeContext> |
|
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_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 |
#elif defined(Q_OS_ |
|
64 | #elif defined(Q_OS_BLACKBERRY) | |
65 | if (!QDir::isAbsolutePath(path)) |
|
65 | if (!QDir::isAbsolutePath(path)) | |
66 | return QString::fromLatin1("app/native/%1").arg(path); |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
67 | #elif !defined(Q_OS_ANDROID) |
|
67 | #elif !defined(Q_OS_ANDROID) | |
68 | QString pathInInstallDir = |
|
68 | QString pathInInstallDir = | |
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); |
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
70 | if (QFileInfo(pathInInstallDir).exists()) |
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |
71 | return pathInInstallDir; |
|
71 | return pathInInstallDir; | |
72 | pathInInstallDir = |
|
72 | pathInInstallDir = | |
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
74 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |
75 | return pathInInstallDir; |
|
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 |
|
86 | |||
87 | // 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 | |
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
89 | #if !defined(NO_JSDEBUGGER) |
|
89 | #if !defined(NO_JSDEBUGGER) | |
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); |
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
91 | #endif |
|
91 | #endif | |
92 | #if !defined(NO_QMLOBSERVER) |
|
92 | #if !defined(NO_QMLOBSERVER) | |
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); |
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
94 | #endif |
|
94 | #endif | |
95 | #endif |
|
95 | #endif | |
96 | } |
|
96 | } | |
97 |
|
97 | |||
98 | QmlApplicationViewer::~QmlApplicationViewer() |
|
98 | QmlApplicationViewer::~QmlApplicationViewer() | |
99 | { |
|
99 | { | |
100 | delete d; |
|
100 | delete d; | |
101 | } |
|
101 | } | |
102 |
|
102 | |||
103 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
103 | QmlApplicationViewer *QmlApplicationViewer::create() | |
104 | { |
|
104 | { | |
105 | return new QmlApplicationViewer(); |
|
105 | return new QmlApplicationViewer(); | |
106 | } |
|
106 | } | |
107 |
|
107 | |||
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
109 | { |
|
109 | { | |
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); |
|
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
111 | #ifdef Q_OS_ANDROID |
|
111 | #ifdef Q_OS_ANDROID | |
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
113 | #else |
|
113 | #else | |
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
115 | #endif |
|
115 | #endif | |
116 | } |
|
116 | } | |
117 |
|
117 | |||
118 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
118 | void QmlApplicationViewer::addImportPath(const QString &path) | |
119 | { |
|
119 | { | |
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); |
|
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
121 | } |
|
121 | } | |
122 |
|
122 | |||
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
124 | { |
|
124 | { | |
125 | #if QT_VERSION < 0x050000 |
|
125 | #if QT_VERSION < 0x050000 | |
126 | Qt::WidgetAttribute attribute; |
|
126 | Qt::WidgetAttribute attribute; | |
127 | switch (orientation) { |
|
127 | switch (orientation) { | |
128 | #if QT_VERSION < 0x040702 |
|
128 | #if QT_VERSION < 0x040702 | |
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
130 | case ScreenOrientationLockPortrait: |
|
130 | case ScreenOrientationLockPortrait: | |
131 | attribute = static_cast<Qt::WidgetAttribute>(128); |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
132 | break; |
|
132 | break; | |
133 | case ScreenOrientationLockLandscape: |
|
133 | case ScreenOrientationLockLandscape: | |
134 | attribute = static_cast<Qt::WidgetAttribute>(129); |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
135 | break; |
|
135 | break; | |
136 | default: |
|
136 | default: | |
137 | case ScreenOrientationAuto: |
|
137 | case ScreenOrientationAuto: | |
138 | attribute = static_cast<Qt::WidgetAttribute>(130); |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
139 | break; |
|
139 | break; | |
140 | #else // QT_VERSION < 0x040702 |
|
140 | #else // QT_VERSION < 0x040702 | |
141 | case ScreenOrientationLockPortrait: |
|
141 | case ScreenOrientationLockPortrait: | |
142 | attribute = Qt::WA_LockPortraitOrientation; |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
143 | break; |
|
143 | break; | |
144 | case ScreenOrientationLockLandscape: |
|
144 | case ScreenOrientationLockLandscape: | |
145 | attribute = Qt::WA_LockLandscapeOrientation; |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
146 | break; |
|
146 | break; | |
147 | default: |
|
147 | default: | |
148 | case ScreenOrientationAuto: |
|
148 | case ScreenOrientationAuto: | |
149 | attribute = Qt::WA_AutoOrientation; |
|
149 | attribute = Qt::WA_AutoOrientation; | |
150 | break; |
|
150 | break; | |
151 | #endif // QT_VERSION < 0x040702 |
|
151 | #endif // QT_VERSION < 0x040702 | |
152 | }; |
|
152 | }; | |
153 | setAttribute(attribute, true); |
|
153 | setAttribute(attribute, true); | |
154 | #else // QT_VERSION < 0x050000 |
|
154 | #else // QT_VERSION < 0x050000 | |
155 | Q_UNUSED(orientation) |
|
155 | Q_UNUSED(orientation) | |
156 | #endif // QT_VERSION < 0x050000 |
|
156 | #endif // QT_VERSION < 0x050000 | |
157 | } |
|
157 | } | |
158 |
|
158 | |||
159 | void QmlApplicationViewer::showExpanded() |
|
159 | void QmlApplicationViewer::showExpanded() | |
160 | { |
|
160 | { | |
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
162 | showFullScreen(); |
|
162 | showFullScreen(); | |
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
164 | showMaximized(); |
|
164 | showMaximized(); | |
165 | #else |
|
165 | #else | |
166 | show(); |
|
166 | show(); | |
167 | #endif |
|
167 | #endif | |
168 | } |
|
168 | } | |
169 |
|
169 | |||
170 | QApplication *createApplication(int &argc, char **argv) |
|
170 | QApplication *createApplication(int &argc, char **argv) | |
171 | { |
|
171 | { | |
172 | #ifdef HARMATTAN_BOOSTER |
|
172 | #ifdef HARMATTAN_BOOSTER | |
173 | return MDeclarativeCache::qApplication(argc, argv); |
|
173 | return MDeclarativeCache::qApplication(argc, argv); | |
174 | #else |
|
174 | #else | |
175 | return new QApplication(argc, argv); |
|
175 | return new QApplication(argc, argv); | |
176 | #endif |
|
176 | #endif | |
177 | } |
|
177 | } |
@@ -1,46 +1,46 | |||||
1 |
// checksum 0xc67a version 0x |
|
1 | // checksum 0xc67a version 0x90018 | |
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 Fremantle. |
|
35 | // Note that this will only have an effect on Fremantle. | |
36 | void setOrientation(ScreenOrientation orientation); |
|
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,177 +1,177 | |||||
1 |
// checksum 0x |
|
1 | // checksum 0xaa72 version 0x90018 | |
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 <QDeclarativeComponent> |
|
16 | #include <QDeclarativeComponent> | |
17 | #include <QDeclarativeEngine> |
|
17 | #include <QDeclarativeEngine> | |
18 | #include <QDeclarativeContext> |
|
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_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 |
#elif defined(Q_OS_ |
|
64 | #elif defined(Q_OS_BLACKBERRY) | |
65 | if (!QDir::isAbsolutePath(path)) |
|
65 | if (!QDir::isAbsolutePath(path)) | |
66 | return QString::fromLatin1("app/native/%1").arg(path); |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
67 | #elif !defined(Q_OS_ANDROID) |
|
67 | #elif !defined(Q_OS_ANDROID) | |
68 | QString pathInInstallDir = |
|
68 | QString pathInInstallDir = | |
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); |
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
70 | if (QFileInfo(pathInInstallDir).exists()) |
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |
71 | return pathInInstallDir; |
|
71 | return pathInInstallDir; | |
72 | pathInInstallDir = |
|
72 | pathInInstallDir = | |
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
74 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |
75 | return pathInInstallDir; |
|
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 |
|
86 | |||
87 | // 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 | |
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
89 | #if !defined(NO_JSDEBUGGER) |
|
89 | #if !defined(NO_JSDEBUGGER) | |
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); |
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
91 | #endif |
|
91 | #endif | |
92 | #if !defined(NO_QMLOBSERVER) |
|
92 | #if !defined(NO_QMLOBSERVER) | |
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); |
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
94 | #endif |
|
94 | #endif | |
95 | #endif |
|
95 | #endif | |
96 | } |
|
96 | } | |
97 |
|
97 | |||
98 | QmlApplicationViewer::~QmlApplicationViewer() |
|
98 | QmlApplicationViewer::~QmlApplicationViewer() | |
99 | { |
|
99 | { | |
100 | delete d; |
|
100 | delete d; | |
101 | } |
|
101 | } | |
102 |
|
102 | |||
103 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
103 | QmlApplicationViewer *QmlApplicationViewer::create() | |
104 | { |
|
104 | { | |
105 | return new QmlApplicationViewer(); |
|
105 | return new QmlApplicationViewer(); | |
106 | } |
|
106 | } | |
107 |
|
107 | |||
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
109 | { |
|
109 | { | |
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); |
|
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
111 | #ifdef Q_OS_ANDROID |
|
111 | #ifdef Q_OS_ANDROID | |
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
113 | #else |
|
113 | #else | |
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
115 | #endif |
|
115 | #endif | |
116 | } |
|
116 | } | |
117 |
|
117 | |||
118 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
118 | void QmlApplicationViewer::addImportPath(const QString &path) | |
119 | { |
|
119 | { | |
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); |
|
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
121 | } |
|
121 | } | |
122 |
|
122 | |||
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
124 | { |
|
124 | { | |
125 | #if QT_VERSION < 0x050000 |
|
125 | #if QT_VERSION < 0x050000 | |
126 | Qt::WidgetAttribute attribute; |
|
126 | Qt::WidgetAttribute attribute; | |
127 | switch (orientation) { |
|
127 | switch (orientation) { | |
128 | #if QT_VERSION < 0x040702 |
|
128 | #if QT_VERSION < 0x040702 | |
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
130 | case ScreenOrientationLockPortrait: |
|
130 | case ScreenOrientationLockPortrait: | |
131 | attribute = static_cast<Qt::WidgetAttribute>(128); |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
132 | break; |
|
132 | break; | |
133 | case ScreenOrientationLockLandscape: |
|
133 | case ScreenOrientationLockLandscape: | |
134 | attribute = static_cast<Qt::WidgetAttribute>(129); |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
135 | break; |
|
135 | break; | |
136 | default: |
|
136 | default: | |
137 | case ScreenOrientationAuto: |
|
137 | case ScreenOrientationAuto: | |
138 | attribute = static_cast<Qt::WidgetAttribute>(130); |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
139 | break; |
|
139 | break; | |
140 | #else // QT_VERSION < 0x040702 |
|
140 | #else // QT_VERSION < 0x040702 | |
141 | case ScreenOrientationLockPortrait: |
|
141 | case ScreenOrientationLockPortrait: | |
142 | attribute = Qt::WA_LockPortraitOrientation; |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
143 | break; |
|
143 | break; | |
144 | case ScreenOrientationLockLandscape: |
|
144 | case ScreenOrientationLockLandscape: | |
145 | attribute = Qt::WA_LockLandscapeOrientation; |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
146 | break; |
|
146 | break; | |
147 | default: |
|
147 | default: | |
148 | case ScreenOrientationAuto: |
|
148 | case ScreenOrientationAuto: | |
149 | attribute = Qt::WA_AutoOrientation; |
|
149 | attribute = Qt::WA_AutoOrientation; | |
150 | break; |
|
150 | break; | |
151 | #endif // QT_VERSION < 0x040702 |
|
151 | #endif // QT_VERSION < 0x040702 | |
152 | }; |
|
152 | }; | |
153 | setAttribute(attribute, true); |
|
153 | setAttribute(attribute, true); | |
154 | #else // QT_VERSION < 0x050000 |
|
154 | #else // QT_VERSION < 0x050000 | |
155 | Q_UNUSED(orientation) |
|
155 | Q_UNUSED(orientation) | |
156 | #endif // QT_VERSION < 0x050000 |
|
156 | #endif // QT_VERSION < 0x050000 | |
157 | } |
|
157 | } | |
158 |
|
158 | |||
159 | void QmlApplicationViewer::showExpanded() |
|
159 | void QmlApplicationViewer::showExpanded() | |
160 | { |
|
160 | { | |
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
162 | showFullScreen(); |
|
162 | showFullScreen(); | |
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
164 | showMaximized(); |
|
164 | showMaximized(); | |
165 | #else |
|
165 | #else | |
166 | show(); |
|
166 | show(); | |
167 | #endif |
|
167 | #endif | |
168 | } |
|
168 | } | |
169 |
|
169 | |||
170 | QApplication *createApplication(int &argc, char **argv) |
|
170 | QApplication *createApplication(int &argc, char **argv) | |
171 | { |
|
171 | { | |
172 | #ifdef HARMATTAN_BOOSTER |
|
172 | #ifdef HARMATTAN_BOOSTER | |
173 | return MDeclarativeCache::qApplication(argc, argv); |
|
173 | return MDeclarativeCache::qApplication(argc, argv); | |
174 | #else |
|
174 | #else | |
175 | return new QApplication(argc, argv); |
|
175 | return new QApplication(argc, argv); | |
176 | #endif |
|
176 | #endif | |
177 | } |
|
177 | } |
@@ -1,46 +1,46 | |||||
1 |
// checksum 0xc67a version 0x |
|
1 | // checksum 0xc67a version 0x90018 | |
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 Fremantle. |
|
35 | // Note that this will only have an effect on Fremantle. | |
36 | void setOrientation(ScreenOrientation orientation); |
|
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,177 +1,177 | |||||
1 |
// checksum 0x |
|
1 | // checksum 0xaa72 version 0x90018 | |
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 <QDeclarativeComponent> |
|
16 | #include <QDeclarativeComponent> | |
17 | #include <QDeclarativeEngine> |
|
17 | #include <QDeclarativeEngine> | |
18 | #include <QDeclarativeContext> |
|
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_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 |
#elif defined(Q_OS_ |
|
64 | #elif defined(Q_OS_BLACKBERRY) | |
65 | if (!QDir::isAbsolutePath(path)) |
|
65 | if (!QDir::isAbsolutePath(path)) | |
66 | return QString::fromLatin1("app/native/%1").arg(path); |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
67 | #elif !defined(Q_OS_ANDROID) |
|
67 | #elif !defined(Q_OS_ANDROID) | |
68 | QString pathInInstallDir = |
|
68 | QString pathInInstallDir = | |
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); |
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
70 | if (QFileInfo(pathInInstallDir).exists()) |
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |
71 | return pathInInstallDir; |
|
71 | return pathInInstallDir; | |
72 | pathInInstallDir = |
|
72 | pathInInstallDir = | |
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
74 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |
75 | return pathInInstallDir; |
|
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 |
|
86 | |||
87 | // 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 | |
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
89 | #if !defined(NO_JSDEBUGGER) |
|
89 | #if !defined(NO_JSDEBUGGER) | |
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); |
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
91 | #endif |
|
91 | #endif | |
92 | #if !defined(NO_QMLOBSERVER) |
|
92 | #if !defined(NO_QMLOBSERVER) | |
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); |
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
94 | #endif |
|
94 | #endif | |
95 | #endif |
|
95 | #endif | |
96 | } |
|
96 | } | |
97 |
|
97 | |||
98 | QmlApplicationViewer::~QmlApplicationViewer() |
|
98 | QmlApplicationViewer::~QmlApplicationViewer() | |
99 | { |
|
99 | { | |
100 | delete d; |
|
100 | delete d; | |
101 | } |
|
101 | } | |
102 |
|
102 | |||
103 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
103 | QmlApplicationViewer *QmlApplicationViewer::create() | |
104 | { |
|
104 | { | |
105 | return new QmlApplicationViewer(); |
|
105 | return new QmlApplicationViewer(); | |
106 | } |
|
106 | } | |
107 |
|
107 | |||
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
109 | { |
|
109 | { | |
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); |
|
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
111 | #ifdef Q_OS_ANDROID |
|
111 | #ifdef Q_OS_ANDROID | |
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
113 | #else |
|
113 | #else | |
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
115 | #endif |
|
115 | #endif | |
116 | } |
|
116 | } | |
117 |
|
117 | |||
118 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
118 | void QmlApplicationViewer::addImportPath(const QString &path) | |
119 | { |
|
119 | { | |
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); |
|
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
121 | } |
|
121 | } | |
122 |
|
122 | |||
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
124 | { |
|
124 | { | |
125 | #if QT_VERSION < 0x050000 |
|
125 | #if QT_VERSION < 0x050000 | |
126 | Qt::WidgetAttribute attribute; |
|
126 | Qt::WidgetAttribute attribute; | |
127 | switch (orientation) { |
|
127 | switch (orientation) { | |
128 | #if QT_VERSION < 0x040702 |
|
128 | #if QT_VERSION < 0x040702 | |
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
130 | case ScreenOrientationLockPortrait: |
|
130 | case ScreenOrientationLockPortrait: | |
131 | attribute = static_cast<Qt::WidgetAttribute>(128); |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
132 | break; |
|
132 | break; | |
133 | case ScreenOrientationLockLandscape: |
|
133 | case ScreenOrientationLockLandscape: | |
134 | attribute = static_cast<Qt::WidgetAttribute>(129); |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
135 | break; |
|
135 | break; | |
136 | default: |
|
136 | default: | |
137 | case ScreenOrientationAuto: |
|
137 | case ScreenOrientationAuto: | |
138 | attribute = static_cast<Qt::WidgetAttribute>(130); |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
139 | break; |
|
139 | break; | |
140 | #else // QT_VERSION < 0x040702 |
|
140 | #else // QT_VERSION < 0x040702 | |
141 | case ScreenOrientationLockPortrait: |
|
141 | case ScreenOrientationLockPortrait: | |
142 | attribute = Qt::WA_LockPortraitOrientation; |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
143 | break; |
|
143 | break; | |
144 | case ScreenOrientationLockLandscape: |
|
144 | case ScreenOrientationLockLandscape: | |
145 | attribute = Qt::WA_LockLandscapeOrientation; |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
146 | break; |
|
146 | break; | |
147 | default: |
|
147 | default: | |
148 | case ScreenOrientationAuto: |
|
148 | case ScreenOrientationAuto: | |
149 | attribute = Qt::WA_AutoOrientation; |
|
149 | attribute = Qt::WA_AutoOrientation; | |
150 | break; |
|
150 | break; | |
151 | #endif // QT_VERSION < 0x040702 |
|
151 | #endif // QT_VERSION < 0x040702 | |
152 | }; |
|
152 | }; | |
153 | setAttribute(attribute, true); |
|
153 | setAttribute(attribute, true); | |
154 | #else // QT_VERSION < 0x050000 |
|
154 | #else // QT_VERSION < 0x050000 | |
155 | Q_UNUSED(orientation) |
|
155 | Q_UNUSED(orientation) | |
156 | #endif // QT_VERSION < 0x050000 |
|
156 | #endif // QT_VERSION < 0x050000 | |
157 | } |
|
157 | } | |
158 |
|
158 | |||
159 | void QmlApplicationViewer::showExpanded() |
|
159 | void QmlApplicationViewer::showExpanded() | |
160 | { |
|
160 | { | |
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
162 | showFullScreen(); |
|
162 | showFullScreen(); | |
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
164 | showMaximized(); |
|
164 | showMaximized(); | |
165 | #else |
|
165 | #else | |
166 | show(); |
|
166 | show(); | |
167 | #endif |
|
167 | #endif | |
168 | } |
|
168 | } | |
169 |
|
169 | |||
170 | QApplication *createApplication(int &argc, char **argv) |
|
170 | QApplication *createApplication(int &argc, char **argv) | |
171 | { |
|
171 | { | |
172 | #ifdef HARMATTAN_BOOSTER |
|
172 | #ifdef HARMATTAN_BOOSTER | |
173 | return MDeclarativeCache::qApplication(argc, argv); |
|
173 | return MDeclarativeCache::qApplication(argc, argv); | |
174 | #else |
|
174 | #else | |
175 | return new QApplication(argc, argv); |
|
175 | return new QApplication(argc, argv); | |
176 | #endif |
|
176 | #endif | |
177 | } |
|
177 | } |
@@ -1,46 +1,46 | |||||
1 |
// checksum 0xc67a version 0x |
|
1 | // checksum 0xc67a version 0x90018 | |
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 Fremantle. |
|
35 | // Note that this will only have an effect on Fremantle. | |
36 | void setOrientation(ScreenOrientation orientation); |
|
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 |
General Comments 0
You need to be logged in to leave comments.
Login now