@@ -0,0 +1,178 | |||||
|
1 | // checksum 0xbd34 version 0x80016 | |||
|
2 | /* | |||
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |||
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |||
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |||
|
6 | handled here. | |||
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |||
|
8 | may offer an updated version of it. | |||
|
9 | */ | |||
|
10 | ||||
|
11 | #include "qmlapplicationviewer.h" | |||
|
12 | ||||
|
13 | #include <QDir> | |||
|
14 | #include <QFileInfo> | |||
|
15 | #include <QApplication> | |||
|
16 | #include <QDeclarativeComponent> | |||
|
17 | #include <QDeclarativeEngine> | |||
|
18 | #include <QDeclarativeContext> | |||
|
19 | ||||
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |||
|
21 | ||||
|
22 | #ifdef HARMATTAN_BOOSTER | |||
|
23 | #include <MDeclarativeCache> | |||
|
24 | #endif | |||
|
25 | ||||
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |||
|
27 | ||||
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |||
|
29 | ||||
|
30 | #if !defined(NO_JSDEBUGGER) | |||
|
31 | #include <jsdebuggeragent.h> | |||
|
32 | #endif | |||
|
33 | #if !defined(NO_QMLOBSERVER) | |||
|
34 | #include <qdeclarativeviewobserver.h> | |||
|
35 | #endif | |||
|
36 | ||||
|
37 | // Enable debugging before any QDeclarativeEngine is created | |||
|
38 | struct QmlJsDebuggingEnabler | |||
|
39 | { | |||
|
40 | QmlJsDebuggingEnabler() | |||
|
41 | { | |||
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |||
|
43 | } | |||
|
44 | }; | |||
|
45 | ||||
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |||
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |||
|
48 | ||||
|
49 | #endif // QMLJSDEBUGGER | |||
|
50 | ||||
|
51 | class QmlApplicationViewerPrivate | |||
|
52 | { | |||
|
53 | QString mainQmlFile; | |||
|
54 | friend class QmlApplicationViewer; | |||
|
55 | static QString adjustPath(const QString &path); | |||
|
56 | }; | |||
|
57 | ||||
|
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |||
|
59 | { | |||
|
60 | #ifdef Q_OS_MAC | |||
|
61 | if (!QDir::isAbsolutePath(path)) | |||
|
62 | return QString::fromLatin1("%1/../Resources/%2") | |||
|
63 | .arg(QCoreApplication::applicationDirPath(), path); | |||
|
64 | #elif defined(Q_OS_QNX) | |||
|
65 | if (!QDir::isAbsolutePath(path)) | |||
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |||
|
67 | #elif !defined(Q_OS_ANDROID) | |||
|
68 | QString pathInInstallDir = | |||
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |||
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |||
|
71 | return pathInInstallDir; | |||
|
72 | pathInInstallDir = | |||
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |||
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |||
|
75 | return pathInInstallDir; | |||
|
76 | #endif | |||
|
77 | return path; | |||
|
78 | } | |||
|
79 | ||||
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |||
|
81 | : QDeclarativeView(parent) | |||
|
82 | , d(new QmlApplicationViewerPrivate()) | |||
|
83 | { | |||
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |||
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |||
|
86 | ||||
|
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |||
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |||
|
89 | #if !defined(NO_JSDEBUGGER) | |||
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |||
|
91 | #endif | |||
|
92 | #if !defined(NO_QMLOBSERVER) | |||
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |||
|
94 | #endif | |||
|
95 | #endif | |||
|
96 | addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); | |||
|
97 | } | |||
|
98 | ||||
|
99 | QmlApplicationViewer::~QmlApplicationViewer() | |||
|
100 | { | |||
|
101 | delete d; | |||
|
102 | } | |||
|
103 | ||||
|
104 | QmlApplicationViewer *QmlApplicationViewer::create() | |||
|
105 | { | |||
|
106 | return new QmlApplicationViewer(); | |||
|
107 | } | |||
|
108 | ||||
|
109 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |||
|
110 | { | |||
|
111 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |||
|
112 | #ifdef Q_OS_ANDROID | |||
|
113 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |||
|
114 | #else | |||
|
115 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |||
|
116 | #endif | |||
|
117 | } | |||
|
118 | ||||
|
119 | void QmlApplicationViewer::addImportPath(const QString &path) | |||
|
120 | { | |||
|
121 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |||
|
122 | } | |||
|
123 | ||||
|
124 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |||
|
125 | { | |||
|
126 | #if QT_VERSION < 0x050000 | |||
|
127 | Qt::WidgetAttribute attribute; | |||
|
128 | switch (orientation) { | |||
|
129 | #if QT_VERSION < 0x040702 | |||
|
130 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |||
|
131 | case ScreenOrientationLockPortrait: | |||
|
132 | attribute = static_cast<Qt::WidgetAttribute>(128); | |||
|
133 | break; | |||
|
134 | case ScreenOrientationLockLandscape: | |||
|
135 | attribute = static_cast<Qt::WidgetAttribute>(129); | |||
|
136 | break; | |||
|
137 | default: | |||
|
138 | case ScreenOrientationAuto: | |||
|
139 | attribute = static_cast<Qt::WidgetAttribute>(130); | |||
|
140 | break; | |||
|
141 | #else // QT_VERSION < 0x040702 | |||
|
142 | case ScreenOrientationLockPortrait: | |||
|
143 | attribute = Qt::WA_LockPortraitOrientation; | |||
|
144 | break; | |||
|
145 | case ScreenOrientationLockLandscape: | |||
|
146 | attribute = Qt::WA_LockLandscapeOrientation; | |||
|
147 | break; | |||
|
148 | default: | |||
|
149 | case ScreenOrientationAuto: | |||
|
150 | attribute = Qt::WA_AutoOrientation; | |||
|
151 | break; | |||
|
152 | #endif // QT_VERSION < 0x040702 | |||
|
153 | }; | |||
|
154 | setAttribute(attribute, true); | |||
|
155 | #else // QT_VERSION < 0x050000 | |||
|
156 | Q_UNUSED(orientation) | |||
|
157 | #endif // QT_VERSION < 0x050000 | |||
|
158 | } | |||
|
159 | ||||
|
160 | void QmlApplicationViewer::showExpanded() | |||
|
161 | { | |||
|
162 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |||
|
163 | showFullScreen(); | |||
|
164 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |||
|
165 | showMaximized(); | |||
|
166 | #else | |||
|
167 | show(); | |||
|
168 | #endif | |||
|
169 | } | |||
|
170 | ||||
|
171 | QApplication *createApplication(int &argc, char **argv) | |||
|
172 | { | |||
|
173 | #ifdef HARMATTAN_BOOSTER | |||
|
174 | return MDeclarativeCache::qApplication(argc, argv); | |||
|
175 | #else | |||
|
176 | return new QApplication(argc, argv); | |||
|
177 | #endif | |||
|
178 | } |
@@ -0,0 +1,46 | |||||
|
1 | // checksum 0xc67a version 0x80016 | |||
|
2 | /* | |||
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |||
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |||
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |||
|
6 | handled here. | |||
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |||
|
8 | may offer an updated version of it. | |||
|
9 | */ | |||
|
10 | ||||
|
11 | #ifndef QMLAPPLICATIONVIEWER_H | |||
|
12 | #define QMLAPPLICATIONVIEWER_H | |||
|
13 | ||||
|
14 | #include <QDeclarativeView> | |||
|
15 | ||||
|
16 | class QmlApplicationViewer : public QDeclarativeView | |||
|
17 | { | |||
|
18 | Q_OBJECT | |||
|
19 | ||||
|
20 | public: | |||
|
21 | enum ScreenOrientation { | |||
|
22 | ScreenOrientationLockPortrait, | |||
|
23 | ScreenOrientationLockLandscape, | |||
|
24 | ScreenOrientationAuto | |||
|
25 | }; | |||
|
26 | ||||
|
27 | explicit QmlApplicationViewer(QWidget *parent = 0); | |||
|
28 | virtual ~QmlApplicationViewer(); | |||
|
29 | ||||
|
30 | static QmlApplicationViewer *create(); | |||
|
31 | ||||
|
32 | void setMainQmlFile(const QString &file); | |||
|
33 | void addImportPath(const QString &path); | |||
|
34 | ||||
|
35 | // Note that this will only have an effect on Fremantle. | |||
|
36 | void setOrientation(ScreenOrientation orientation); | |||
|
37 | ||||
|
38 | void showExpanded(); | |||
|
39 | ||||
|
40 | private: | |||
|
41 | class QmlApplicationViewerPrivate *d; | |||
|
42 | }; | |||
|
43 | ||||
|
44 | QApplication *createApplication(int &argc, char **argv); | |||
|
45 | ||||
|
46 | #endif // QMLAPPLICATIONVIEWER_H |
@@ -0,0 +1,13 | |||||
|
1 | QT += declarative | |||
|
2 | ||||
|
3 | SOURCES += $$PWD/qmlapplicationviewer.cpp | |||
|
4 | HEADERS += $$PWD/qmlapplicationviewer.h | |||
|
5 | INCLUDEPATH += $$PWD | |||
|
6 | ||||
|
7 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set | |||
|
8 | !isEmpty(QMLJSDEBUGGER_PATH) { | |||
|
9 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) | |||
|
10 | } else { | |||
|
11 | DEFINES -= QMLJSDEBUGGER | |||
|
12 | } | |||
|
13 |
@@ -0,0 +1,178 | |||||
|
1 | // checksum 0xbd34 version 0x80016 | |||
|
2 | /* | |||
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |||
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |||
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |||
|
6 | handled here. | |||
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |||
|
8 | may offer an updated version of it. | |||
|
9 | */ | |||
|
10 | ||||
|
11 | #include "qmlapplicationviewer.h" | |||
|
12 | ||||
|
13 | #include <QDir> | |||
|
14 | #include <QFileInfo> | |||
|
15 | #include <QApplication> | |||
|
16 | #include <QDeclarativeComponent> | |||
|
17 | #include <QDeclarativeEngine> | |||
|
18 | #include <QDeclarativeContext> | |||
|
19 | ||||
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |||
|
21 | ||||
|
22 | #ifdef HARMATTAN_BOOSTER | |||
|
23 | #include <MDeclarativeCache> | |||
|
24 | #endif | |||
|
25 | ||||
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |||
|
27 | ||||
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |||
|
29 | ||||
|
30 | #if !defined(NO_JSDEBUGGER) | |||
|
31 | #include <jsdebuggeragent.h> | |||
|
32 | #endif | |||
|
33 | #if !defined(NO_QMLOBSERVER) | |||
|
34 | #include <qdeclarativeviewobserver.h> | |||
|
35 | #endif | |||
|
36 | ||||
|
37 | // Enable debugging before any QDeclarativeEngine is created | |||
|
38 | struct QmlJsDebuggingEnabler | |||
|
39 | { | |||
|
40 | QmlJsDebuggingEnabler() | |||
|
41 | { | |||
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |||
|
43 | } | |||
|
44 | }; | |||
|
45 | ||||
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |||
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |||
|
48 | ||||
|
49 | #endif // QMLJSDEBUGGER | |||
|
50 | ||||
|
51 | class QmlApplicationViewerPrivate | |||
|
52 | { | |||
|
53 | QString mainQmlFile; | |||
|
54 | friend class QmlApplicationViewer; | |||
|
55 | static QString adjustPath(const QString &path); | |||
|
56 | }; | |||
|
57 | ||||
|
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |||
|
59 | { | |||
|
60 | #ifdef Q_OS_MAC | |||
|
61 | if (!QDir::isAbsolutePath(path)) | |||
|
62 | return QString::fromLatin1("%1/../Resources/%2") | |||
|
63 | .arg(QCoreApplication::applicationDirPath(), path); | |||
|
64 | #elif defined(Q_OS_QNX) | |||
|
65 | if (!QDir::isAbsolutePath(path)) | |||
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |||
|
67 | #elif !defined(Q_OS_ANDROID) | |||
|
68 | QString pathInInstallDir = | |||
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |||
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |||
|
71 | return pathInInstallDir; | |||
|
72 | pathInInstallDir = | |||
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |||
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |||
|
75 | return pathInInstallDir; | |||
|
76 | #endif | |||
|
77 | return path; | |||
|
78 | } | |||
|
79 | ||||
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |||
|
81 | : QDeclarativeView(parent) | |||
|
82 | , d(new QmlApplicationViewerPrivate()) | |||
|
83 | { | |||
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |||
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |||
|
86 | ||||
|
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |||
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |||
|
89 | #if !defined(NO_JSDEBUGGER) | |||
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |||
|
91 | #endif | |||
|
92 | #if !defined(NO_QMLOBSERVER) | |||
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |||
|
94 | #endif | |||
|
95 | #endif | |||
|
96 | addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); | |||
|
97 | } | |||
|
98 | ||||
|
99 | QmlApplicationViewer::~QmlApplicationViewer() | |||
|
100 | { | |||
|
101 | delete d; | |||
|
102 | } | |||
|
103 | ||||
|
104 | QmlApplicationViewer *QmlApplicationViewer::create() | |||
|
105 | { | |||
|
106 | return new QmlApplicationViewer(); | |||
|
107 | } | |||
|
108 | ||||
|
109 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |||
|
110 | { | |||
|
111 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |||
|
112 | #ifdef Q_OS_ANDROID | |||
|
113 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |||
|
114 | #else | |||
|
115 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |||
|
116 | #endif | |||
|
117 | } | |||
|
118 | ||||
|
119 | void QmlApplicationViewer::addImportPath(const QString &path) | |||
|
120 | { | |||
|
121 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |||
|
122 | } | |||
|
123 | ||||
|
124 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |||
|
125 | { | |||
|
126 | #if QT_VERSION < 0x050000 | |||
|
127 | Qt::WidgetAttribute attribute; | |||
|
128 | switch (orientation) { | |||
|
129 | #if QT_VERSION < 0x040702 | |||
|
130 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |||
|
131 | case ScreenOrientationLockPortrait: | |||
|
132 | attribute = static_cast<Qt::WidgetAttribute>(128); | |||
|
133 | break; | |||
|
134 | case ScreenOrientationLockLandscape: | |||
|
135 | attribute = static_cast<Qt::WidgetAttribute>(129); | |||
|
136 | break; | |||
|
137 | default: | |||
|
138 | case ScreenOrientationAuto: | |||
|
139 | attribute = static_cast<Qt::WidgetAttribute>(130); | |||
|
140 | break; | |||
|
141 | #else // QT_VERSION < 0x040702 | |||
|
142 | case ScreenOrientationLockPortrait: | |||
|
143 | attribute = Qt::WA_LockPortraitOrientation; | |||
|
144 | break; | |||
|
145 | case ScreenOrientationLockLandscape: | |||
|
146 | attribute = Qt::WA_LockLandscapeOrientation; | |||
|
147 | break; | |||
|
148 | default: | |||
|
149 | case ScreenOrientationAuto: | |||
|
150 | attribute = Qt::WA_AutoOrientation; | |||
|
151 | break; | |||
|
152 | #endif // QT_VERSION < 0x040702 | |||
|
153 | }; | |||
|
154 | setAttribute(attribute, true); | |||
|
155 | #else // QT_VERSION < 0x050000 | |||
|
156 | Q_UNUSED(orientation) | |||
|
157 | #endif // QT_VERSION < 0x050000 | |||
|
158 | } | |||
|
159 | ||||
|
160 | void QmlApplicationViewer::showExpanded() | |||
|
161 | { | |||
|
162 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |||
|
163 | showFullScreen(); | |||
|
164 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |||
|
165 | showMaximized(); | |||
|
166 | #else | |||
|
167 | show(); | |||
|
168 | #endif | |||
|
169 | } | |||
|
170 | ||||
|
171 | QApplication *createApplication(int &argc, char **argv) | |||
|
172 | { | |||
|
173 | #ifdef HARMATTAN_BOOSTER | |||
|
174 | return MDeclarativeCache::qApplication(argc, argv); | |||
|
175 | #else | |||
|
176 | return new QApplication(argc, argv); | |||
|
177 | #endif | |||
|
178 | } |
@@ -0,0 +1,46 | |||||
|
1 | // checksum 0xc67a version 0x80016 | |||
|
2 | /* | |||
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |||
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |||
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |||
|
6 | handled here. | |||
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |||
|
8 | may offer an updated version of it. | |||
|
9 | */ | |||
|
10 | ||||
|
11 | #ifndef QMLAPPLICATIONVIEWER_H | |||
|
12 | #define QMLAPPLICATIONVIEWER_H | |||
|
13 | ||||
|
14 | #include <QDeclarativeView> | |||
|
15 | ||||
|
16 | class QmlApplicationViewer : public QDeclarativeView | |||
|
17 | { | |||
|
18 | Q_OBJECT | |||
|
19 | ||||
|
20 | public: | |||
|
21 | enum ScreenOrientation { | |||
|
22 | ScreenOrientationLockPortrait, | |||
|
23 | ScreenOrientationLockLandscape, | |||
|
24 | ScreenOrientationAuto | |||
|
25 | }; | |||
|
26 | ||||
|
27 | explicit QmlApplicationViewer(QWidget *parent = 0); | |||
|
28 | virtual ~QmlApplicationViewer(); | |||
|
29 | ||||
|
30 | static QmlApplicationViewer *create(); | |||
|
31 | ||||
|
32 | void setMainQmlFile(const QString &file); | |||
|
33 | void addImportPath(const QString &path); | |||
|
34 | ||||
|
35 | // Note that this will only have an effect on Fremantle. | |||
|
36 | void setOrientation(ScreenOrientation orientation); | |||
|
37 | ||||
|
38 | void showExpanded(); | |||
|
39 | ||||
|
40 | private: | |||
|
41 | class QmlApplicationViewerPrivate *d; | |||
|
42 | }; | |||
|
43 | ||||
|
44 | QApplication *createApplication(int &argc, char **argv); | |||
|
45 | ||||
|
46 | #endif // QMLAPPLICATIONVIEWER_H |
@@ -0,0 +1,13 | |||||
|
1 | QT += declarative | |||
|
2 | ||||
|
3 | SOURCES += $$PWD/qmlapplicationviewer.cpp | |||
|
4 | HEADERS += $$PWD/qmlapplicationviewer.h | |||
|
5 | INCLUDEPATH += $$PWD | |||
|
6 | ||||
|
7 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set | |||
|
8 | !isEmpty(QMLJSDEBUGGER_PATH) { | |||
|
9 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) | |||
|
10 | } else { | |||
|
11 | DEFINES -= QMLJSDEBUGGER | |||
|
12 | } | |||
|
13 |
@@ -0,0 +1,178 | |||||
|
1 | // checksum 0xbd34 version 0x80016 | |||
|
2 | /* | |||
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |||
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |||
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |||
|
6 | handled here. | |||
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |||
|
8 | may offer an updated version of it. | |||
|
9 | */ | |||
|
10 | ||||
|
11 | #include "qmlapplicationviewer.h" | |||
|
12 | ||||
|
13 | #include <QDir> | |||
|
14 | #include <QFileInfo> | |||
|
15 | #include <QApplication> | |||
|
16 | #include <QDeclarativeComponent> | |||
|
17 | #include <QDeclarativeEngine> | |||
|
18 | #include <QDeclarativeContext> | |||
|
19 | ||||
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |||
|
21 | ||||
|
22 | #ifdef HARMATTAN_BOOSTER | |||
|
23 | #include <MDeclarativeCache> | |||
|
24 | #endif | |||
|
25 | ||||
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |||
|
27 | ||||
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |||
|
29 | ||||
|
30 | #if !defined(NO_JSDEBUGGER) | |||
|
31 | #include <jsdebuggeragent.h> | |||
|
32 | #endif | |||
|
33 | #if !defined(NO_QMLOBSERVER) | |||
|
34 | #include <qdeclarativeviewobserver.h> | |||
|
35 | #endif | |||
|
36 | ||||
|
37 | // Enable debugging before any QDeclarativeEngine is created | |||
|
38 | struct QmlJsDebuggingEnabler | |||
|
39 | { | |||
|
40 | QmlJsDebuggingEnabler() | |||
|
41 | { | |||
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |||
|
43 | } | |||
|
44 | }; | |||
|
45 | ||||
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |||
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |||
|
48 | ||||
|
49 | #endif // QMLJSDEBUGGER | |||
|
50 | ||||
|
51 | class QmlApplicationViewerPrivate | |||
|
52 | { | |||
|
53 | QString mainQmlFile; | |||
|
54 | friend class QmlApplicationViewer; | |||
|
55 | static QString adjustPath(const QString &path); | |||
|
56 | }; | |||
|
57 | ||||
|
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |||
|
59 | { | |||
|
60 | #ifdef Q_OS_MAC | |||
|
61 | if (!QDir::isAbsolutePath(path)) | |||
|
62 | return QString::fromLatin1("%1/../Resources/%2") | |||
|
63 | .arg(QCoreApplication::applicationDirPath(), path); | |||
|
64 | #elif defined(Q_OS_QNX) | |||
|
65 | if (!QDir::isAbsolutePath(path)) | |||
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |||
|
67 | #elif !defined(Q_OS_ANDROID) | |||
|
68 | QString pathInInstallDir = | |||
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |||
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |||
|
71 | return pathInInstallDir; | |||
|
72 | pathInInstallDir = | |||
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |||
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |||
|
75 | return pathInInstallDir; | |||
|
76 | #endif | |||
|
77 | return path; | |||
|
78 | } | |||
|
79 | ||||
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |||
|
81 | : QDeclarativeView(parent) | |||
|
82 | , d(new QmlApplicationViewerPrivate()) | |||
|
83 | { | |||
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |||
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |||
|
86 | ||||
|
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |||
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |||
|
89 | #if !defined(NO_JSDEBUGGER) | |||
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |||
|
91 | #endif | |||
|
92 | #if !defined(NO_QMLOBSERVER) | |||
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |||
|
94 | #endif | |||
|
95 | #endif | |||
|
96 | addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); | |||
|
97 | } | |||
|
98 | ||||
|
99 | QmlApplicationViewer::~QmlApplicationViewer() | |||
|
100 | { | |||
|
101 | delete d; | |||
|
102 | } | |||
|
103 | ||||
|
104 | QmlApplicationViewer *QmlApplicationViewer::create() | |||
|
105 | { | |||
|
106 | return new QmlApplicationViewer(); | |||
|
107 | } | |||
|
108 | ||||
|
109 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |||
|
110 | { | |||
|
111 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |||
|
112 | #ifdef Q_OS_ANDROID | |||
|
113 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |||
|
114 | #else | |||
|
115 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |||
|
116 | #endif | |||
|
117 | } | |||
|
118 | ||||
|
119 | void QmlApplicationViewer::addImportPath(const QString &path) | |||
|
120 | { | |||
|
121 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |||
|
122 | } | |||
|
123 | ||||
|
124 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |||
|
125 | { | |||
|
126 | #if QT_VERSION < 0x050000 | |||
|
127 | Qt::WidgetAttribute attribute; | |||
|
128 | switch (orientation) { | |||
|
129 | #if QT_VERSION < 0x040702 | |||
|
130 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |||
|
131 | case ScreenOrientationLockPortrait: | |||
|
132 | attribute = static_cast<Qt::WidgetAttribute>(128); | |||
|
133 | break; | |||
|
134 | case ScreenOrientationLockLandscape: | |||
|
135 | attribute = static_cast<Qt::WidgetAttribute>(129); | |||
|
136 | break; | |||
|
137 | default: | |||
|
138 | case ScreenOrientationAuto: | |||
|
139 | attribute = static_cast<Qt::WidgetAttribute>(130); | |||
|
140 | break; | |||
|
141 | #else // QT_VERSION < 0x040702 | |||
|
142 | case ScreenOrientationLockPortrait: | |||
|
143 | attribute = Qt::WA_LockPortraitOrientation; | |||
|
144 | break; | |||
|
145 | case ScreenOrientationLockLandscape: | |||
|
146 | attribute = Qt::WA_LockLandscapeOrientation; | |||
|
147 | break; | |||
|
148 | default: | |||
|
149 | case ScreenOrientationAuto: | |||
|
150 | attribute = Qt::WA_AutoOrientation; | |||
|
151 | break; | |||
|
152 | #endif // QT_VERSION < 0x040702 | |||
|
153 | }; | |||
|
154 | setAttribute(attribute, true); | |||
|
155 | #else // QT_VERSION < 0x050000 | |||
|
156 | Q_UNUSED(orientation) | |||
|
157 | #endif // QT_VERSION < 0x050000 | |||
|
158 | } | |||
|
159 | ||||
|
160 | void QmlApplicationViewer::showExpanded() | |||
|
161 | { | |||
|
162 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |||
|
163 | showFullScreen(); | |||
|
164 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |||
|
165 | showMaximized(); | |||
|
166 | #else | |||
|
167 | show(); | |||
|
168 | #endif | |||
|
169 | } | |||
|
170 | ||||
|
171 | QApplication *createApplication(int &argc, char **argv) | |||
|
172 | { | |||
|
173 | #ifdef HARMATTAN_BOOSTER | |||
|
174 | return MDeclarativeCache::qApplication(argc, argv); | |||
|
175 | #else | |||
|
176 | return new QApplication(argc, argv); | |||
|
177 | #endif | |||
|
178 | } |
@@ -0,0 +1,46 | |||||
|
1 | // checksum 0xc67a version 0x80016 | |||
|
2 | /* | |||
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |||
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |||
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |||
|
6 | handled here. | |||
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |||
|
8 | may offer an updated version of it. | |||
|
9 | */ | |||
|
10 | ||||
|
11 | #ifndef QMLAPPLICATIONVIEWER_H | |||
|
12 | #define QMLAPPLICATIONVIEWER_H | |||
|
13 | ||||
|
14 | #include <QDeclarativeView> | |||
|
15 | ||||
|
16 | class QmlApplicationViewer : public QDeclarativeView | |||
|
17 | { | |||
|
18 | Q_OBJECT | |||
|
19 | ||||
|
20 | public: | |||
|
21 | enum ScreenOrientation { | |||
|
22 | ScreenOrientationLockPortrait, | |||
|
23 | ScreenOrientationLockLandscape, | |||
|
24 | ScreenOrientationAuto | |||
|
25 | }; | |||
|
26 | ||||
|
27 | explicit QmlApplicationViewer(QWidget *parent = 0); | |||
|
28 | virtual ~QmlApplicationViewer(); | |||
|
29 | ||||
|
30 | static QmlApplicationViewer *create(); | |||
|
31 | ||||
|
32 | void setMainQmlFile(const QString &file); | |||
|
33 | void addImportPath(const QString &path); | |||
|
34 | ||||
|
35 | // Note that this will only have an effect on Fremantle. | |||
|
36 | void setOrientation(ScreenOrientation orientation); | |||
|
37 | ||||
|
38 | void showExpanded(); | |||
|
39 | ||||
|
40 | private: | |||
|
41 | class QmlApplicationViewerPrivate *d; | |||
|
42 | }; | |||
|
43 | ||||
|
44 | QApplication *createApplication(int &argc, char **argv); | |||
|
45 | ||||
|
46 | #endif // QMLAPPLICATIONVIEWER_H |
@@ -0,0 +1,13 | |||||
|
1 | QT += declarative | |||
|
2 | ||||
|
3 | SOURCES += $$PWD/qmlapplicationviewer.cpp | |||
|
4 | HEADERS += $$PWD/qmlapplicationviewer.h | |||
|
5 | INCLUDEPATH += $$PWD | |||
|
6 | ||||
|
7 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set | |||
|
8 | !isEmpty(QMLJSDEBUGGER_PATH) { | |||
|
9 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) | |||
|
10 | } else { | |||
|
11 | DEFINES -= QMLJSDEBUGGER | |||
|
12 | } | |||
|
13 |
@@ -0,0 +1,178 | |||||
|
1 | // checksum 0xbd34 version 0x80016 | |||
|
2 | /* | |||
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |||
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |||
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |||
|
6 | handled here. | |||
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |||
|
8 | may offer an updated version of it. | |||
|
9 | */ | |||
|
10 | ||||
|
11 | #include "qmlapplicationviewer.h" | |||
|
12 | ||||
|
13 | #include <QDir> | |||
|
14 | #include <QFileInfo> | |||
|
15 | #include <QApplication> | |||
|
16 | #include <QDeclarativeComponent> | |||
|
17 | #include <QDeclarativeEngine> | |||
|
18 | #include <QDeclarativeContext> | |||
|
19 | ||||
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |||
|
21 | ||||
|
22 | #ifdef HARMATTAN_BOOSTER | |||
|
23 | #include <MDeclarativeCache> | |||
|
24 | #endif | |||
|
25 | ||||
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |||
|
27 | ||||
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |||
|
29 | ||||
|
30 | #if !defined(NO_JSDEBUGGER) | |||
|
31 | #include <jsdebuggeragent.h> | |||
|
32 | #endif | |||
|
33 | #if !defined(NO_QMLOBSERVER) | |||
|
34 | #include <qdeclarativeviewobserver.h> | |||
|
35 | #endif | |||
|
36 | ||||
|
37 | // Enable debugging before any QDeclarativeEngine is created | |||
|
38 | struct QmlJsDebuggingEnabler | |||
|
39 | { | |||
|
40 | QmlJsDebuggingEnabler() | |||
|
41 | { | |||
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |||
|
43 | } | |||
|
44 | }; | |||
|
45 | ||||
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |||
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |||
|
48 | ||||
|
49 | #endif // QMLJSDEBUGGER | |||
|
50 | ||||
|
51 | class QmlApplicationViewerPrivate | |||
|
52 | { | |||
|
53 | QString mainQmlFile; | |||
|
54 | friend class QmlApplicationViewer; | |||
|
55 | static QString adjustPath(const QString &path); | |||
|
56 | }; | |||
|
57 | ||||
|
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |||
|
59 | { | |||
|
60 | #ifdef Q_OS_MAC | |||
|
61 | if (!QDir::isAbsolutePath(path)) | |||
|
62 | return QString::fromLatin1("%1/../Resources/%2") | |||
|
63 | .arg(QCoreApplication::applicationDirPath(), path); | |||
|
64 | #elif defined(Q_OS_QNX) | |||
|
65 | if (!QDir::isAbsolutePath(path)) | |||
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |||
|
67 | #elif !defined(Q_OS_ANDROID) | |||
|
68 | QString pathInInstallDir = | |||
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |||
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |||
|
71 | return pathInInstallDir; | |||
|
72 | pathInInstallDir = | |||
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |||
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |||
|
75 | return pathInInstallDir; | |||
|
76 | #endif | |||
|
77 | return path; | |||
|
78 | } | |||
|
79 | ||||
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |||
|
81 | : QDeclarativeView(parent) | |||
|
82 | , d(new QmlApplicationViewerPrivate()) | |||
|
83 | { | |||
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |||
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |||
|
86 | ||||
|
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |||
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |||
|
89 | #if !defined(NO_JSDEBUGGER) | |||
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |||
|
91 | #endif | |||
|
92 | #if !defined(NO_QMLOBSERVER) | |||
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |||
|
94 | #endif | |||
|
95 | #endif | |||
|
96 | addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); | |||
|
97 | } | |||
|
98 | ||||
|
99 | QmlApplicationViewer::~QmlApplicationViewer() | |||
|
100 | { | |||
|
101 | delete d; | |||
|
102 | } | |||
|
103 | ||||
|
104 | QmlApplicationViewer *QmlApplicationViewer::create() | |||
|
105 | { | |||
|
106 | return new QmlApplicationViewer(); | |||
|
107 | } | |||
|
108 | ||||
|
109 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |||
|
110 | { | |||
|
111 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |||
|
112 | #ifdef Q_OS_ANDROID | |||
|
113 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |||
|
114 | #else | |||
|
115 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |||
|
116 | #endif | |||
|
117 | } | |||
|
118 | ||||
|
119 | void QmlApplicationViewer::addImportPath(const QString &path) | |||
|
120 | { | |||
|
121 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |||
|
122 | } | |||
|
123 | ||||
|
124 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |||
|
125 | { | |||
|
126 | #if QT_VERSION < 0x050000 | |||
|
127 | Qt::WidgetAttribute attribute; | |||
|
128 | switch (orientation) { | |||
|
129 | #if QT_VERSION < 0x040702 | |||
|
130 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |||
|
131 | case ScreenOrientationLockPortrait: | |||
|
132 | attribute = static_cast<Qt::WidgetAttribute>(128); | |||
|
133 | break; | |||
|
134 | case ScreenOrientationLockLandscape: | |||
|
135 | attribute = static_cast<Qt::WidgetAttribute>(129); | |||
|
136 | break; | |||
|
137 | default: | |||
|
138 | case ScreenOrientationAuto: | |||
|
139 | attribute = static_cast<Qt::WidgetAttribute>(130); | |||
|
140 | break; | |||
|
141 | #else // QT_VERSION < 0x040702 | |||
|
142 | case ScreenOrientationLockPortrait: | |||
|
143 | attribute = Qt::WA_LockPortraitOrientation; | |||
|
144 | break; | |||
|
145 | case ScreenOrientationLockLandscape: | |||
|
146 | attribute = Qt::WA_LockLandscapeOrientation; | |||
|
147 | break; | |||
|
148 | default: | |||
|
149 | case ScreenOrientationAuto: | |||
|
150 | attribute = Qt::WA_AutoOrientation; | |||
|
151 | break; | |||
|
152 | #endif // QT_VERSION < 0x040702 | |||
|
153 | }; | |||
|
154 | setAttribute(attribute, true); | |||
|
155 | #else // QT_VERSION < 0x050000 | |||
|
156 | Q_UNUSED(orientation) | |||
|
157 | #endif // QT_VERSION < 0x050000 | |||
|
158 | } | |||
|
159 | ||||
|
160 | void QmlApplicationViewer::showExpanded() | |||
|
161 | { | |||
|
162 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |||
|
163 | showFullScreen(); | |||
|
164 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |||
|
165 | showMaximized(); | |||
|
166 | #else | |||
|
167 | show(); | |||
|
168 | #endif | |||
|
169 | } | |||
|
170 | ||||
|
171 | QApplication *createApplication(int &argc, char **argv) | |||
|
172 | { | |||
|
173 | #ifdef HARMATTAN_BOOSTER | |||
|
174 | return MDeclarativeCache::qApplication(argc, argv); | |||
|
175 | #else | |||
|
176 | return new QApplication(argc, argv); | |||
|
177 | #endif | |||
|
178 | } |
@@ -0,0 +1,46 | |||||
|
1 | // checksum 0xc67a version 0x80016 | |||
|
2 | /* | |||
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |||
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |||
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |||
|
6 | handled here. | |||
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |||
|
8 | may offer an updated version of it. | |||
|
9 | */ | |||
|
10 | ||||
|
11 | #ifndef QMLAPPLICATIONVIEWER_H | |||
|
12 | #define QMLAPPLICATIONVIEWER_H | |||
|
13 | ||||
|
14 | #include <QDeclarativeView> | |||
|
15 | ||||
|
16 | class QmlApplicationViewer : public QDeclarativeView | |||
|
17 | { | |||
|
18 | Q_OBJECT | |||
|
19 | ||||
|
20 | public: | |||
|
21 | enum ScreenOrientation { | |||
|
22 | ScreenOrientationLockPortrait, | |||
|
23 | ScreenOrientationLockLandscape, | |||
|
24 | ScreenOrientationAuto | |||
|
25 | }; | |||
|
26 | ||||
|
27 | explicit QmlApplicationViewer(QWidget *parent = 0); | |||
|
28 | virtual ~QmlApplicationViewer(); | |||
|
29 | ||||
|
30 | static QmlApplicationViewer *create(); | |||
|
31 | ||||
|
32 | void setMainQmlFile(const QString &file); | |||
|
33 | void addImportPath(const QString &path); | |||
|
34 | ||||
|
35 | // Note that this will only have an effect on Fremantle. | |||
|
36 | void setOrientation(ScreenOrientation orientation); | |||
|
37 | ||||
|
38 | void showExpanded(); | |||
|
39 | ||||
|
40 | private: | |||
|
41 | class QmlApplicationViewerPrivate *d; | |||
|
42 | }; | |||
|
43 | ||||
|
44 | QApplication *createApplication(int &argc, char **argv); | |||
|
45 | ||||
|
46 | #endif // QMLAPPLICATIONVIEWER_H |
@@ -0,0 +1,13 | |||||
|
1 | QT += declarative | |||
|
2 | ||||
|
3 | SOURCES += $$PWD/qmlapplicationviewer.cpp | |||
|
4 | HEADERS += $$PWD/qmlapplicationviewer.h | |||
|
5 | INCLUDEPATH += $$PWD | |||
|
6 | ||||
|
7 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set | |||
|
8 | !isEmpty(QMLJSDEBUGGER_PATH) { | |||
|
9 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) | |||
|
10 | } else { | |||
|
11 | DEFINES -= QMLJSDEBUGGER | |||
|
12 | } | |||
|
13 |
@@ -0,0 +1,178 | |||||
|
1 | // checksum 0xbd34 version 0x80016 | |||
|
2 | /* | |||
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |||
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |||
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |||
|
6 | handled here. | |||
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |||
|
8 | may offer an updated version of it. | |||
|
9 | */ | |||
|
10 | ||||
|
11 | #include "qmlapplicationviewer.h" | |||
|
12 | ||||
|
13 | #include <QDir> | |||
|
14 | #include <QFileInfo> | |||
|
15 | #include <QApplication> | |||
|
16 | #include <QDeclarativeComponent> | |||
|
17 | #include <QDeclarativeEngine> | |||
|
18 | #include <QDeclarativeContext> | |||
|
19 | ||||
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |||
|
21 | ||||
|
22 | #ifdef HARMATTAN_BOOSTER | |||
|
23 | #include <MDeclarativeCache> | |||
|
24 | #endif | |||
|
25 | ||||
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |||
|
27 | ||||
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |||
|
29 | ||||
|
30 | #if !defined(NO_JSDEBUGGER) | |||
|
31 | #include <jsdebuggeragent.h> | |||
|
32 | #endif | |||
|
33 | #if !defined(NO_QMLOBSERVER) | |||
|
34 | #include <qdeclarativeviewobserver.h> | |||
|
35 | #endif | |||
|
36 | ||||
|
37 | // Enable debugging before any QDeclarativeEngine is created | |||
|
38 | struct QmlJsDebuggingEnabler | |||
|
39 | { | |||
|
40 | QmlJsDebuggingEnabler() | |||
|
41 | { | |||
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |||
|
43 | } | |||
|
44 | }; | |||
|
45 | ||||
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |||
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |||
|
48 | ||||
|
49 | #endif // QMLJSDEBUGGER | |||
|
50 | ||||
|
51 | class QmlApplicationViewerPrivate | |||
|
52 | { | |||
|
53 | QString mainQmlFile; | |||
|
54 | friend class QmlApplicationViewer; | |||
|
55 | static QString adjustPath(const QString &path); | |||
|
56 | }; | |||
|
57 | ||||
|
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |||
|
59 | { | |||
|
60 | #ifdef Q_OS_MAC | |||
|
61 | if (!QDir::isAbsolutePath(path)) | |||
|
62 | return QString::fromLatin1("%1/../Resources/%2") | |||
|
63 | .arg(QCoreApplication::applicationDirPath(), path); | |||
|
64 | #elif defined(Q_OS_QNX) | |||
|
65 | if (!QDir::isAbsolutePath(path)) | |||
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |||
|
67 | #elif !defined(Q_OS_ANDROID) | |||
|
68 | QString pathInInstallDir = | |||
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |||
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |||
|
71 | return pathInInstallDir; | |||
|
72 | pathInInstallDir = | |||
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |||
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |||
|
75 | return pathInInstallDir; | |||
|
76 | #endif | |||
|
77 | return path; | |||
|
78 | } | |||
|
79 | ||||
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |||
|
81 | : QDeclarativeView(parent) | |||
|
82 | , d(new QmlApplicationViewerPrivate()) | |||
|
83 | { | |||
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |||
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |||
|
86 | ||||
|
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |||
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |||
|
89 | #if !defined(NO_JSDEBUGGER) | |||
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |||
|
91 | #endif | |||
|
92 | #if !defined(NO_QMLOBSERVER) | |||
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |||
|
94 | #endif | |||
|
95 | #endif | |||
|
96 | addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); | |||
|
97 | } | |||
|
98 | ||||
|
99 | QmlApplicationViewer::~QmlApplicationViewer() | |||
|
100 | { | |||
|
101 | delete d; | |||
|
102 | } | |||
|
103 | ||||
|
104 | QmlApplicationViewer *QmlApplicationViewer::create() | |||
|
105 | { | |||
|
106 | return new QmlApplicationViewer(); | |||
|
107 | } | |||
|
108 | ||||
|
109 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |||
|
110 | { | |||
|
111 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |||
|
112 | #ifdef Q_OS_ANDROID | |||
|
113 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |||
|
114 | #else | |||
|
115 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |||
|
116 | #endif | |||
|
117 | } | |||
|
118 | ||||
|
119 | void QmlApplicationViewer::addImportPath(const QString &path) | |||
|
120 | { | |||
|
121 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |||
|
122 | } | |||
|
123 | ||||
|
124 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |||
|
125 | { | |||
|
126 | #if QT_VERSION < 0x050000 | |||
|
127 | Qt::WidgetAttribute attribute; | |||
|
128 | switch (orientation) { | |||
|
129 | #if QT_VERSION < 0x040702 | |||
|
130 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |||
|
131 | case ScreenOrientationLockPortrait: | |||
|
132 | attribute = static_cast<Qt::WidgetAttribute>(128); | |||
|
133 | break; | |||
|
134 | case ScreenOrientationLockLandscape: | |||
|
135 | attribute = static_cast<Qt::WidgetAttribute>(129); | |||
|
136 | break; | |||
|
137 | default: | |||
|
138 | case ScreenOrientationAuto: | |||
|
139 | attribute = static_cast<Qt::WidgetAttribute>(130); | |||
|
140 | break; | |||
|
141 | #else // QT_VERSION < 0x040702 | |||
|
142 | case ScreenOrientationLockPortrait: | |||
|
143 | attribute = Qt::WA_LockPortraitOrientation; | |||
|
144 | break; | |||
|
145 | case ScreenOrientationLockLandscape: | |||
|
146 | attribute = Qt::WA_LockLandscapeOrientation; | |||
|
147 | break; | |||
|
148 | default: | |||
|
149 | case ScreenOrientationAuto: | |||
|
150 | attribute = Qt::WA_AutoOrientation; | |||
|
151 | break; | |||
|
152 | #endif // QT_VERSION < 0x040702 | |||
|
153 | }; | |||
|
154 | setAttribute(attribute, true); | |||
|
155 | #else // QT_VERSION < 0x050000 | |||
|
156 | Q_UNUSED(orientation) | |||
|
157 | #endif // QT_VERSION < 0x050000 | |||
|
158 | } | |||
|
159 | ||||
|
160 | void QmlApplicationViewer::showExpanded() | |||
|
161 | { | |||
|
162 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |||
|
163 | showFullScreen(); | |||
|
164 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |||
|
165 | showMaximized(); | |||
|
166 | #else | |||
|
167 | show(); | |||
|
168 | #endif | |||
|
169 | } | |||
|
170 | ||||
|
171 | QApplication *createApplication(int &argc, char **argv) | |||
|
172 | { | |||
|
173 | #ifdef HARMATTAN_BOOSTER | |||
|
174 | return MDeclarativeCache::qApplication(argc, argv); | |||
|
175 | #else | |||
|
176 | return new QApplication(argc, argv); | |||
|
177 | #endif | |||
|
178 | } |
@@ -0,0 +1,46 | |||||
|
1 | // checksum 0xc67a version 0x80016 | |||
|
2 | /* | |||
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |||
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |||
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |||
|
6 | handled here. | |||
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |||
|
8 | may offer an updated version of it. | |||
|
9 | */ | |||
|
10 | ||||
|
11 | #ifndef QMLAPPLICATIONVIEWER_H | |||
|
12 | #define QMLAPPLICATIONVIEWER_H | |||
|
13 | ||||
|
14 | #include <QDeclarativeView> | |||
|
15 | ||||
|
16 | class QmlApplicationViewer : public QDeclarativeView | |||
|
17 | { | |||
|
18 | Q_OBJECT | |||
|
19 | ||||
|
20 | public: | |||
|
21 | enum ScreenOrientation { | |||
|
22 | ScreenOrientationLockPortrait, | |||
|
23 | ScreenOrientationLockLandscape, | |||
|
24 | ScreenOrientationAuto | |||
|
25 | }; | |||
|
26 | ||||
|
27 | explicit QmlApplicationViewer(QWidget *parent = 0); | |||
|
28 | virtual ~QmlApplicationViewer(); | |||
|
29 | ||||
|
30 | static QmlApplicationViewer *create(); | |||
|
31 | ||||
|
32 | void setMainQmlFile(const QString &file); | |||
|
33 | void addImportPath(const QString &path); | |||
|
34 | ||||
|
35 | // Note that this will only have an effect on Fremantle. | |||
|
36 | void setOrientation(ScreenOrientation orientation); | |||
|
37 | ||||
|
38 | void showExpanded(); | |||
|
39 | ||||
|
40 | private: | |||
|
41 | class QmlApplicationViewerPrivate *d; | |||
|
42 | }; | |||
|
43 | ||||
|
44 | QApplication *createApplication(int &argc, char **argv); | |||
|
45 | ||||
|
46 | #endif // QMLAPPLICATIONVIEWER_H |
@@ -0,0 +1,13 | |||||
|
1 | QT += declarative | |||
|
2 | ||||
|
3 | SOURCES += $$PWD/qmlapplicationviewer.cpp | |||
|
4 | HEADERS += $$PWD/qmlapplicationviewer.h | |||
|
5 | INCLUDEPATH += $$PWD | |||
|
6 | ||||
|
7 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set | |||
|
8 | !isEmpty(QMLJSDEBUGGER_PATH) { | |||
|
9 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) | |||
|
10 | } else { | |||
|
11 | DEFINES -= QMLJSDEBUGGER | |||
|
12 | } | |||
|
13 |
@@ -0,0 +1,178 | |||||
|
1 | // checksum 0xbd34 version 0x80016 | |||
|
2 | /* | |||
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |||
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |||
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |||
|
6 | handled here. | |||
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |||
|
8 | may offer an updated version of it. | |||
|
9 | */ | |||
|
10 | ||||
|
11 | #include "qmlapplicationviewer.h" | |||
|
12 | ||||
|
13 | #include <QDir> | |||
|
14 | #include <QFileInfo> | |||
|
15 | #include <QApplication> | |||
|
16 | #include <QDeclarativeComponent> | |||
|
17 | #include <QDeclarativeEngine> | |||
|
18 | #include <QDeclarativeContext> | |||
|
19 | ||||
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |||
|
21 | ||||
|
22 | #ifdef HARMATTAN_BOOSTER | |||
|
23 | #include <MDeclarativeCache> | |||
|
24 | #endif | |||
|
25 | ||||
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |||
|
27 | ||||
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |||
|
29 | ||||
|
30 | #if !defined(NO_JSDEBUGGER) | |||
|
31 | #include <jsdebuggeragent.h> | |||
|
32 | #endif | |||
|
33 | #if !defined(NO_QMLOBSERVER) | |||
|
34 | #include <qdeclarativeviewobserver.h> | |||
|
35 | #endif | |||
|
36 | ||||
|
37 | // Enable debugging before any QDeclarativeEngine is created | |||
|
38 | struct QmlJsDebuggingEnabler | |||
|
39 | { | |||
|
40 | QmlJsDebuggingEnabler() | |||
|
41 | { | |||
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |||
|
43 | } | |||
|
44 | }; | |||
|
45 | ||||
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |||
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |||
|
48 | ||||
|
49 | #endif // QMLJSDEBUGGER | |||
|
50 | ||||
|
51 | class QmlApplicationViewerPrivate | |||
|
52 | { | |||
|
53 | QString mainQmlFile; | |||
|
54 | friend class QmlApplicationViewer; | |||
|
55 | static QString adjustPath(const QString &path); | |||
|
56 | }; | |||
|
57 | ||||
|
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |||
|
59 | { | |||
|
60 | #ifdef Q_OS_MAC | |||
|
61 | if (!QDir::isAbsolutePath(path)) | |||
|
62 | return QString::fromLatin1("%1/../Resources/%2") | |||
|
63 | .arg(QCoreApplication::applicationDirPath(), path); | |||
|
64 | #elif defined(Q_OS_QNX) | |||
|
65 | if (!QDir::isAbsolutePath(path)) | |||
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |||
|
67 | #elif !defined(Q_OS_ANDROID) | |||
|
68 | QString pathInInstallDir = | |||
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |||
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |||
|
71 | return pathInInstallDir; | |||
|
72 | pathInInstallDir = | |||
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |||
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |||
|
75 | return pathInInstallDir; | |||
|
76 | #endif | |||
|
77 | return path; | |||
|
78 | } | |||
|
79 | ||||
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |||
|
81 | : QDeclarativeView(parent) | |||
|
82 | , d(new QmlApplicationViewerPrivate()) | |||
|
83 | { | |||
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |||
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |||
|
86 | ||||
|
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |||
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |||
|
89 | #if !defined(NO_JSDEBUGGER) | |||
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |||
|
91 | #endif | |||
|
92 | #if !defined(NO_QMLOBSERVER) | |||
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |||
|
94 | #endif | |||
|
95 | #endif | |||
|
96 | addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); | |||
|
97 | } | |||
|
98 | ||||
|
99 | QmlApplicationViewer::~QmlApplicationViewer() | |||
|
100 | { | |||
|
101 | delete d; | |||
|
102 | } | |||
|
103 | ||||
|
104 | QmlApplicationViewer *QmlApplicationViewer::create() | |||
|
105 | { | |||
|
106 | return new QmlApplicationViewer(); | |||
|
107 | } | |||
|
108 | ||||
|
109 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |||
|
110 | { | |||
|
111 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |||
|
112 | #ifdef Q_OS_ANDROID | |||
|
113 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |||
|
114 | #else | |||
|
115 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |||
|
116 | #endif | |||
|
117 | } | |||
|
118 | ||||
|
119 | void QmlApplicationViewer::addImportPath(const QString &path) | |||
|
120 | { | |||
|
121 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |||
|
122 | } | |||
|
123 | ||||
|
124 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |||
|
125 | { | |||
|
126 | #if QT_VERSION < 0x050000 | |||
|
127 | Qt::WidgetAttribute attribute; | |||
|
128 | switch (orientation) { | |||
|
129 | #if QT_VERSION < 0x040702 | |||
|
130 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |||
|
131 | case ScreenOrientationLockPortrait: | |||
|
132 | attribute = static_cast<Qt::WidgetAttribute>(128); | |||
|
133 | break; | |||
|
134 | case ScreenOrientationLockLandscape: | |||
|
135 | attribute = static_cast<Qt::WidgetAttribute>(129); | |||
|
136 | break; | |||
|
137 | default: | |||
|
138 | case ScreenOrientationAuto: | |||
|
139 | attribute = static_cast<Qt::WidgetAttribute>(130); | |||
|
140 | break; | |||
|
141 | #else // QT_VERSION < 0x040702 | |||
|
142 | case ScreenOrientationLockPortrait: | |||
|
143 | attribute = Qt::WA_LockPortraitOrientation; | |||
|
144 | break; | |||
|
145 | case ScreenOrientationLockLandscape: | |||
|
146 | attribute = Qt::WA_LockLandscapeOrientation; | |||
|
147 | break; | |||
|
148 | default: | |||
|
149 | case ScreenOrientationAuto: | |||
|
150 | attribute = Qt::WA_AutoOrientation; | |||
|
151 | break; | |||
|
152 | #endif // QT_VERSION < 0x040702 | |||
|
153 | }; | |||
|
154 | setAttribute(attribute, true); | |||
|
155 | #else // QT_VERSION < 0x050000 | |||
|
156 | Q_UNUSED(orientation) | |||
|
157 | #endif // QT_VERSION < 0x050000 | |||
|
158 | } | |||
|
159 | ||||
|
160 | void QmlApplicationViewer::showExpanded() | |||
|
161 | { | |||
|
162 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |||
|
163 | showFullScreen(); | |||
|
164 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |||
|
165 | showMaximized(); | |||
|
166 | #else | |||
|
167 | show(); | |||
|
168 | #endif | |||
|
169 | } | |||
|
170 | ||||
|
171 | QApplication *createApplication(int &argc, char **argv) | |||
|
172 | { | |||
|
173 | #ifdef HARMATTAN_BOOSTER | |||
|
174 | return MDeclarativeCache::qApplication(argc, argv); | |||
|
175 | #else | |||
|
176 | return new QApplication(argc, argv); | |||
|
177 | #endif | |||
|
178 | } |
@@ -0,0 +1,46 | |||||
|
1 | // checksum 0xc67a version 0x80016 | |||
|
2 | /* | |||
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |||
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |||
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |||
|
6 | handled here. | |||
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |||
|
8 | may offer an updated version of it. | |||
|
9 | */ | |||
|
10 | ||||
|
11 | #ifndef QMLAPPLICATIONVIEWER_H | |||
|
12 | #define QMLAPPLICATIONVIEWER_H | |||
|
13 | ||||
|
14 | #include <QDeclarativeView> | |||
|
15 | ||||
|
16 | class QmlApplicationViewer : public QDeclarativeView | |||
|
17 | { | |||
|
18 | Q_OBJECT | |||
|
19 | ||||
|
20 | public: | |||
|
21 | enum ScreenOrientation { | |||
|
22 | ScreenOrientationLockPortrait, | |||
|
23 | ScreenOrientationLockLandscape, | |||
|
24 | ScreenOrientationAuto | |||
|
25 | }; | |||
|
26 | ||||
|
27 | explicit QmlApplicationViewer(QWidget *parent = 0); | |||
|
28 | virtual ~QmlApplicationViewer(); | |||
|
29 | ||||
|
30 | static QmlApplicationViewer *create(); | |||
|
31 | ||||
|
32 | void setMainQmlFile(const QString &file); | |||
|
33 | void addImportPath(const QString &path); | |||
|
34 | ||||
|
35 | // Note that this will only have an effect on Fremantle. | |||
|
36 | void setOrientation(ScreenOrientation orientation); | |||
|
37 | ||||
|
38 | void showExpanded(); | |||
|
39 | ||||
|
40 | private: | |||
|
41 | class QmlApplicationViewerPrivate *d; | |||
|
42 | }; | |||
|
43 | ||||
|
44 | QApplication *createApplication(int &argc, char **argv); | |||
|
45 | ||||
|
46 | #endif // QMLAPPLICATIONVIEWER_H |
@@ -0,0 +1,13 | |||||
|
1 | QT += declarative | |||
|
2 | ||||
|
3 | SOURCES += $$PWD/qmlapplicationviewer.cpp | |||
|
4 | HEADERS += $$PWD/qmlapplicationviewer.h | |||
|
5 | INCLUDEPATH += $$PWD | |||
|
6 | ||||
|
7 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set | |||
|
8 | !isEmpty(QMLJSDEBUGGER_PATH) { | |||
|
9 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) | |||
|
10 | } else { | |||
|
11 | DEFINES -= QMLJSDEBUGGER | |||
|
12 | } | |||
|
13 |
@@ -0,0 +1,178 | |||||
|
1 | // checksum 0xbd34 version 0x80016 | |||
|
2 | /* | |||
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |||
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |||
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |||
|
6 | handled here. | |||
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |||
|
8 | may offer an updated version of it. | |||
|
9 | */ | |||
|
10 | ||||
|
11 | #include "qmlapplicationviewer.h" | |||
|
12 | ||||
|
13 | #include <QDir> | |||
|
14 | #include <QFileInfo> | |||
|
15 | #include <QApplication> | |||
|
16 | #include <QDeclarativeComponent> | |||
|
17 | #include <QDeclarativeEngine> | |||
|
18 | #include <QDeclarativeContext> | |||
|
19 | ||||
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |||
|
21 | ||||
|
22 | #ifdef HARMATTAN_BOOSTER | |||
|
23 | #include <MDeclarativeCache> | |||
|
24 | #endif | |||
|
25 | ||||
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |||
|
27 | ||||
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |||
|
29 | ||||
|
30 | #if !defined(NO_JSDEBUGGER) | |||
|
31 | #include <jsdebuggeragent.h> | |||
|
32 | #endif | |||
|
33 | #if !defined(NO_QMLOBSERVER) | |||
|
34 | #include <qdeclarativeviewobserver.h> | |||
|
35 | #endif | |||
|
36 | ||||
|
37 | // Enable debugging before any QDeclarativeEngine is created | |||
|
38 | struct QmlJsDebuggingEnabler | |||
|
39 | { | |||
|
40 | QmlJsDebuggingEnabler() | |||
|
41 | { | |||
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |||
|
43 | } | |||
|
44 | }; | |||
|
45 | ||||
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |||
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |||
|
48 | ||||
|
49 | #endif // QMLJSDEBUGGER | |||
|
50 | ||||
|
51 | class QmlApplicationViewerPrivate | |||
|
52 | { | |||
|
53 | QString mainQmlFile; | |||
|
54 | friend class QmlApplicationViewer; | |||
|
55 | static QString adjustPath(const QString &path); | |||
|
56 | }; | |||
|
57 | ||||
|
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |||
|
59 | { | |||
|
60 | #ifdef Q_OS_MAC | |||
|
61 | if (!QDir::isAbsolutePath(path)) | |||
|
62 | return QString::fromLatin1("%1/../Resources/%2") | |||
|
63 | .arg(QCoreApplication::applicationDirPath(), path); | |||
|
64 | #elif defined(Q_OS_QNX) | |||
|
65 | if (!QDir::isAbsolutePath(path)) | |||
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |||
|
67 | #elif !defined(Q_OS_ANDROID) | |||
|
68 | QString pathInInstallDir = | |||
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |||
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |||
|
71 | return pathInInstallDir; | |||
|
72 | pathInInstallDir = | |||
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |||
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |||
|
75 | return pathInInstallDir; | |||
|
76 | #endif | |||
|
77 | return path; | |||
|
78 | } | |||
|
79 | ||||
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |||
|
81 | : QDeclarativeView(parent) | |||
|
82 | , d(new QmlApplicationViewerPrivate()) | |||
|
83 | { | |||
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |||
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |||
|
86 | ||||
|
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |||
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |||
|
89 | #if !defined(NO_JSDEBUGGER) | |||
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |||
|
91 | #endif | |||
|
92 | #if !defined(NO_QMLOBSERVER) | |||
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |||
|
94 | #endif | |||
|
95 | #endif | |||
|
96 | addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); | |||
|
97 | } | |||
|
98 | ||||
|
99 | QmlApplicationViewer::~QmlApplicationViewer() | |||
|
100 | { | |||
|
101 | delete d; | |||
|
102 | } | |||
|
103 | ||||
|
104 | QmlApplicationViewer *QmlApplicationViewer::create() | |||
|
105 | { | |||
|
106 | return new QmlApplicationViewer(); | |||
|
107 | } | |||
|
108 | ||||
|
109 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |||
|
110 | { | |||
|
111 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |||
|
112 | #ifdef Q_OS_ANDROID | |||
|
113 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |||
|
114 | #else | |||
|
115 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |||
|
116 | #endif | |||
|
117 | } | |||
|
118 | ||||
|
119 | void QmlApplicationViewer::addImportPath(const QString &path) | |||
|
120 | { | |||
|
121 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |||
|
122 | } | |||
|
123 | ||||
|
124 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |||
|
125 | { | |||
|
126 | #if QT_VERSION < 0x050000 | |||
|
127 | Qt::WidgetAttribute attribute; | |||
|
128 | switch (orientation) { | |||
|
129 | #if QT_VERSION < 0x040702 | |||
|
130 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |||
|
131 | case ScreenOrientationLockPortrait: | |||
|
132 | attribute = static_cast<Qt::WidgetAttribute>(128); | |||
|
133 | break; | |||
|
134 | case ScreenOrientationLockLandscape: | |||
|
135 | attribute = static_cast<Qt::WidgetAttribute>(129); | |||
|
136 | break; | |||
|
137 | default: | |||
|
138 | case ScreenOrientationAuto: | |||
|
139 | attribute = static_cast<Qt::WidgetAttribute>(130); | |||
|
140 | break; | |||
|
141 | #else // QT_VERSION < 0x040702 | |||
|
142 | case ScreenOrientationLockPortrait: | |||
|
143 | attribute = Qt::WA_LockPortraitOrientation; | |||
|
144 | break; | |||
|
145 | case ScreenOrientationLockLandscape: | |||
|
146 | attribute = Qt::WA_LockLandscapeOrientation; | |||
|
147 | break; | |||
|
148 | default: | |||
|
149 | case ScreenOrientationAuto: | |||
|
150 | attribute = Qt::WA_AutoOrientation; | |||
|
151 | break; | |||
|
152 | #endif // QT_VERSION < 0x040702 | |||
|
153 | }; | |||
|
154 | setAttribute(attribute, true); | |||
|
155 | #else // QT_VERSION < 0x050000 | |||
|
156 | Q_UNUSED(orientation) | |||
|
157 | #endif // QT_VERSION < 0x050000 | |||
|
158 | } | |||
|
159 | ||||
|
160 | void QmlApplicationViewer::showExpanded() | |||
|
161 | { | |||
|
162 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |||
|
163 | showFullScreen(); | |||
|
164 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |||
|
165 | showMaximized(); | |||
|
166 | #else | |||
|
167 | show(); | |||
|
168 | #endif | |||
|
169 | } | |||
|
170 | ||||
|
171 | QApplication *createApplication(int &argc, char **argv) | |||
|
172 | { | |||
|
173 | #ifdef HARMATTAN_BOOSTER | |||
|
174 | return MDeclarativeCache::qApplication(argc, argv); | |||
|
175 | #else | |||
|
176 | return new QApplication(argc, argv); | |||
|
177 | #endif | |||
|
178 | } |
@@ -0,0 +1,46 | |||||
|
1 | // checksum 0xc67a version 0x80016 | |||
|
2 | /* | |||
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |||
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |||
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |||
|
6 | handled here. | |||
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |||
|
8 | may offer an updated version of it. | |||
|
9 | */ | |||
|
10 | ||||
|
11 | #ifndef QMLAPPLICATIONVIEWER_H | |||
|
12 | #define QMLAPPLICATIONVIEWER_H | |||
|
13 | ||||
|
14 | #include <QDeclarativeView> | |||
|
15 | ||||
|
16 | class QmlApplicationViewer : public QDeclarativeView | |||
|
17 | { | |||
|
18 | Q_OBJECT | |||
|
19 | ||||
|
20 | public: | |||
|
21 | enum ScreenOrientation { | |||
|
22 | ScreenOrientationLockPortrait, | |||
|
23 | ScreenOrientationLockLandscape, | |||
|
24 | ScreenOrientationAuto | |||
|
25 | }; | |||
|
26 | ||||
|
27 | explicit QmlApplicationViewer(QWidget *parent = 0); | |||
|
28 | virtual ~QmlApplicationViewer(); | |||
|
29 | ||||
|
30 | static QmlApplicationViewer *create(); | |||
|
31 | ||||
|
32 | void setMainQmlFile(const QString &file); | |||
|
33 | void addImportPath(const QString &path); | |||
|
34 | ||||
|
35 | // Note that this will only have an effect on Fremantle. | |||
|
36 | void setOrientation(ScreenOrientation orientation); | |||
|
37 | ||||
|
38 | void showExpanded(); | |||
|
39 | ||||
|
40 | private: | |||
|
41 | class QmlApplicationViewerPrivate *d; | |||
|
42 | }; | |||
|
43 | ||||
|
44 | QApplication *createApplication(int &argc, char **argv); | |||
|
45 | ||||
|
46 | #endif // QMLAPPLICATIONVIEWER_H |
@@ -0,0 +1,13 | |||||
|
1 | QT += declarative | |||
|
2 | ||||
|
3 | SOURCES += $$PWD/qmlapplicationviewer.cpp | |||
|
4 | HEADERS += $$PWD/qmlapplicationviewer.h | |||
|
5 | INCLUDEPATH += $$PWD | |||
|
6 | ||||
|
7 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set | |||
|
8 | !isEmpty(QMLJSDEBUGGER_PATH) { | |||
|
9 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) | |||
|
10 | } else { | |||
|
11 | DEFINES -= QMLJSDEBUGGER | |||
|
12 | } | |||
|
13 |
@@ -0,0 +1,178 | |||||
|
1 | // checksum 0xbd34 version 0x80016 | |||
|
2 | /* | |||
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |||
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |||
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |||
|
6 | handled here. | |||
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |||
|
8 | may offer an updated version of it. | |||
|
9 | */ | |||
|
10 | ||||
|
11 | #include "qmlapplicationviewer.h" | |||
|
12 | ||||
|
13 | #include <QDir> | |||
|
14 | #include <QFileInfo> | |||
|
15 | #include <QApplication> | |||
|
16 | #include <QDeclarativeComponent> | |||
|
17 | #include <QDeclarativeEngine> | |||
|
18 | #include <QDeclarativeContext> | |||
|
19 | ||||
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |||
|
21 | ||||
|
22 | #ifdef HARMATTAN_BOOSTER | |||
|
23 | #include <MDeclarativeCache> | |||
|
24 | #endif | |||
|
25 | ||||
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |||
|
27 | ||||
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |||
|
29 | ||||
|
30 | #if !defined(NO_JSDEBUGGER) | |||
|
31 | #include <jsdebuggeragent.h> | |||
|
32 | #endif | |||
|
33 | #if !defined(NO_QMLOBSERVER) | |||
|
34 | #include <qdeclarativeviewobserver.h> | |||
|
35 | #endif | |||
|
36 | ||||
|
37 | // Enable debugging before any QDeclarativeEngine is created | |||
|
38 | struct QmlJsDebuggingEnabler | |||
|
39 | { | |||
|
40 | QmlJsDebuggingEnabler() | |||
|
41 | { | |||
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |||
|
43 | } | |||
|
44 | }; | |||
|
45 | ||||
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |||
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |||
|
48 | ||||
|
49 | #endif // QMLJSDEBUGGER | |||
|
50 | ||||
|
51 | class QmlApplicationViewerPrivate | |||
|
52 | { | |||
|
53 | QString mainQmlFile; | |||
|
54 | friend class QmlApplicationViewer; | |||
|
55 | static QString adjustPath(const QString &path); | |||
|
56 | }; | |||
|
57 | ||||
|
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |||
|
59 | { | |||
|
60 | #ifdef Q_OS_MAC | |||
|
61 | if (!QDir::isAbsolutePath(path)) | |||
|
62 | return QString::fromLatin1("%1/../Resources/%2") | |||
|
63 | .arg(QCoreApplication::applicationDirPath(), path); | |||
|
64 | #elif defined(Q_OS_QNX) | |||
|
65 | if (!QDir::isAbsolutePath(path)) | |||
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |||
|
67 | #elif !defined(Q_OS_ANDROID) | |||
|
68 | QString pathInInstallDir = | |||
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |||
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |||
|
71 | return pathInInstallDir; | |||
|
72 | pathInInstallDir = | |||
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |||
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |||
|
75 | return pathInInstallDir; | |||
|
76 | #endif | |||
|
77 | return path; | |||
|
78 | } | |||
|
79 | ||||
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |||
|
81 | : QDeclarativeView(parent) | |||
|
82 | , d(new QmlApplicationViewerPrivate()) | |||
|
83 | { | |||
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |||
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |||
|
86 | ||||
|
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |||
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |||
|
89 | #if !defined(NO_JSDEBUGGER) | |||
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |||
|
91 | #endif | |||
|
92 | #if !defined(NO_QMLOBSERVER) | |||
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |||
|
94 | #endif | |||
|
95 | #endif | |||
|
96 | addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); | |||
|
97 | } | |||
|
98 | ||||
|
99 | QmlApplicationViewer::~QmlApplicationViewer() | |||
|
100 | { | |||
|
101 | delete d; | |||
|
102 | } | |||
|
103 | ||||
|
104 | QmlApplicationViewer *QmlApplicationViewer::create() | |||
|
105 | { | |||
|
106 | return new QmlApplicationViewer(); | |||
|
107 | } | |||
|
108 | ||||
|
109 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |||
|
110 | { | |||
|
111 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |||
|
112 | #ifdef Q_OS_ANDROID | |||
|
113 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |||
|
114 | #else | |||
|
115 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |||
|
116 | #endif | |||
|
117 | } | |||
|
118 | ||||
|
119 | void QmlApplicationViewer::addImportPath(const QString &path) | |||
|
120 | { | |||
|
121 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |||
|
122 | } | |||
|
123 | ||||
|
124 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |||
|
125 | { | |||
|
126 | #if QT_VERSION < 0x050000 | |||
|
127 | Qt::WidgetAttribute attribute; | |||
|
128 | switch (orientation) { | |||
|
129 | #if QT_VERSION < 0x040702 | |||
|
130 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |||
|
131 | case ScreenOrientationLockPortrait: | |||
|
132 | attribute = static_cast<Qt::WidgetAttribute>(128); | |||
|
133 | break; | |||
|
134 | case ScreenOrientationLockLandscape: | |||
|
135 | attribute = static_cast<Qt::WidgetAttribute>(129); | |||
|
136 | break; | |||
|
137 | default: | |||
|
138 | case ScreenOrientationAuto: | |||
|
139 | attribute = static_cast<Qt::WidgetAttribute>(130); | |||
|
140 | break; | |||
|
141 | #else // QT_VERSION < 0x040702 | |||
|
142 | case ScreenOrientationLockPortrait: | |||
|
143 | attribute = Qt::WA_LockPortraitOrientation; | |||
|
144 | break; | |||
|
145 | case ScreenOrientationLockLandscape: | |||
|
146 | attribute = Qt::WA_LockLandscapeOrientation; | |||
|
147 | break; | |||
|
148 | default: | |||
|
149 | case ScreenOrientationAuto: | |||
|
150 | attribute = Qt::WA_AutoOrientation; | |||
|
151 | break; | |||
|
152 | #endif // QT_VERSION < 0x040702 | |||
|
153 | }; | |||
|
154 | setAttribute(attribute, true); | |||
|
155 | #else // QT_VERSION < 0x050000 | |||
|
156 | Q_UNUSED(orientation) | |||
|
157 | #endif // QT_VERSION < 0x050000 | |||
|
158 | } | |||
|
159 | ||||
|
160 | void QmlApplicationViewer::showExpanded() | |||
|
161 | { | |||
|
162 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |||
|
163 | showFullScreen(); | |||
|
164 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |||
|
165 | showMaximized(); | |||
|
166 | #else | |||
|
167 | show(); | |||
|
168 | #endif | |||
|
169 | } | |||
|
170 | ||||
|
171 | QApplication *createApplication(int &argc, char **argv) | |||
|
172 | { | |||
|
173 | #ifdef HARMATTAN_BOOSTER | |||
|
174 | return MDeclarativeCache::qApplication(argc, argv); | |||
|
175 | #else | |||
|
176 | return new QApplication(argc, argv); | |||
|
177 | #endif | |||
|
178 | } |
@@ -0,0 +1,46 | |||||
|
1 | // checksum 0xc67a version 0x80016 | |||
|
2 | /* | |||
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |||
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |||
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |||
|
6 | handled here. | |||
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |||
|
8 | may offer an updated version of it. | |||
|
9 | */ | |||
|
10 | ||||
|
11 | #ifndef QMLAPPLICATIONVIEWER_H | |||
|
12 | #define QMLAPPLICATIONVIEWER_H | |||
|
13 | ||||
|
14 | #include <QDeclarativeView> | |||
|
15 | ||||
|
16 | class QmlApplicationViewer : public QDeclarativeView | |||
|
17 | { | |||
|
18 | Q_OBJECT | |||
|
19 | ||||
|
20 | public: | |||
|
21 | enum ScreenOrientation { | |||
|
22 | ScreenOrientationLockPortrait, | |||
|
23 | ScreenOrientationLockLandscape, | |||
|
24 | ScreenOrientationAuto | |||
|
25 | }; | |||
|
26 | ||||
|
27 | explicit QmlApplicationViewer(QWidget *parent = 0); | |||
|
28 | virtual ~QmlApplicationViewer(); | |||
|
29 | ||||
|
30 | static QmlApplicationViewer *create(); | |||
|
31 | ||||
|
32 | void setMainQmlFile(const QString &file); | |||
|
33 | void addImportPath(const QString &path); | |||
|
34 | ||||
|
35 | // Note that this will only have an effect on Fremantle. | |||
|
36 | void setOrientation(ScreenOrientation orientation); | |||
|
37 | ||||
|
38 | void showExpanded(); | |||
|
39 | ||||
|
40 | private: | |||
|
41 | class QmlApplicationViewerPrivate *d; | |||
|
42 | }; | |||
|
43 | ||||
|
44 | QApplication *createApplication(int &argc, char **argv); | |||
|
45 | ||||
|
46 | #endif // QMLAPPLICATIONVIEWER_H |
@@ -0,0 +1,13 | |||||
|
1 | QT += declarative | |||
|
2 | ||||
|
3 | SOURCES += $$PWD/qmlapplicationviewer.cpp | |||
|
4 | HEADERS += $$PWD/qmlapplicationviewer.h | |||
|
5 | INCLUDEPATH += $$PWD | |||
|
6 | ||||
|
7 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set | |||
|
8 | !isEmpty(QMLJSDEBUGGER_PATH) { | |||
|
9 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) | |||
|
10 | } else { | |||
|
11 | DEFINES -= QMLJSDEBUGGER | |||
|
12 | } | |||
|
13 |
@@ -0,0 +1,71 | |||||
|
1 | // checksum 0x56a9 version 0x80001 | |||
|
2 | /* | |||
|
3 | This file was generated by the Qt Quick 2 Application wizard of Qt Creator. | |||
|
4 | QtQuick2ApplicationViewer is a convenience class containing mobile device specific | |||
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |||
|
6 | handled here. | |||
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |||
|
8 | may offer an updated version of it. | |||
|
9 | */ | |||
|
10 | ||||
|
11 | #include "qtquick2applicationviewer.h" | |||
|
12 | ||||
|
13 | #include <QtCore/QCoreApplication> | |||
|
14 | #include <QtCore/QDir> | |||
|
15 | #include <QtQml/QQmlEngine> | |||
|
16 | ||||
|
17 | class QtQuick2ApplicationViewerPrivate | |||
|
18 | { | |||
|
19 | QString mainQmlFile; | |||
|
20 | friend class QtQuick2ApplicationViewer; | |||
|
21 | static QString adjustPath(const QString &path); | |||
|
22 | }; | |||
|
23 | ||||
|
24 | QString QtQuick2ApplicationViewerPrivate::adjustPath(const QString &path) | |||
|
25 | { | |||
|
26 | #if defined(Q_OS_MAC) | |||
|
27 | if (!QDir::isAbsolutePath(path)) | |||
|
28 | return QString::fromLatin1("%1/../Resources/%2") | |||
|
29 | .arg(QCoreApplication::applicationDirPath(), path); | |||
|
30 | #elif defined(Q_OS_UNIX) | |||
|
31 | const QString pathInInstallDir = | |||
|
32 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |||
|
33 | if (QFileInfo(pathInInstallDir).exists()) | |||
|
34 | return pathInInstallDir; | |||
|
35 | #endif | |||
|
36 | return path; | |||
|
37 | } | |||
|
38 | ||||
|
39 | QtQuick2ApplicationViewer::QtQuick2ApplicationViewer(QWindow *parent) | |||
|
40 | : QQuickView(parent) | |||
|
41 | , d(new QtQuick2ApplicationViewerPrivate()) | |||
|
42 | { | |||
|
43 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |||
|
44 | setResizeMode(QQuickView::SizeRootObjectToView); | |||
|
45 | addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QString::fromLatin1("qml"))); | |||
|
46 | } | |||
|
47 | ||||
|
48 | QtQuick2ApplicationViewer::~QtQuick2ApplicationViewer() | |||
|
49 | { | |||
|
50 | delete d; | |||
|
51 | } | |||
|
52 | ||||
|
53 | void QtQuick2ApplicationViewer::setMainQmlFile(const QString &file) | |||
|
54 | { | |||
|
55 | d->mainQmlFile = QtQuick2ApplicationViewerPrivate::adjustPath(file); | |||
|
56 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |||
|
57 | } | |||
|
58 | ||||
|
59 | void QtQuick2ApplicationViewer::addImportPath(const QString &path) | |||
|
60 | { | |||
|
61 | engine()->addImportPath(QtQuick2ApplicationViewerPrivate::adjustPath(path)); | |||
|
62 | } | |||
|
63 | ||||
|
64 | void QtQuick2ApplicationViewer::showExpanded() | |||
|
65 | { | |||
|
66 | #if defined(Q_WS_SIMULATOR) | |||
|
67 | showFullScreen(); | |||
|
68 | #else | |||
|
69 | show(); | |||
|
70 | #endif | |||
|
71 | } |
@@ -0,0 +1,33 | |||||
|
1 | // checksum 0xfde6 version 0x80001 | |||
|
2 | /* | |||
|
3 | This file was generated by the Qt Quick 2 Application wizard of Qt Creator. | |||
|
4 | QtQuick2ApplicationViewer is a convenience class containing mobile device specific | |||
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |||
|
6 | handled here. | |||
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |||
|
8 | may offer an updated version of it. | |||
|
9 | */ | |||
|
10 | ||||
|
11 | #ifndef QTQUICK2APPLICATIONVIEWER_H | |||
|
12 | #define QTQUICK2APPLICATIONVIEWER_H | |||
|
13 | ||||
|
14 | #include <QtQuick/QQuickView> | |||
|
15 | ||||
|
16 | class QtQuick2ApplicationViewer : public QQuickView | |||
|
17 | { | |||
|
18 | Q_OBJECT | |||
|
19 | ||||
|
20 | public: | |||
|
21 | explicit QtQuick2ApplicationViewer(QWindow *parent = 0); | |||
|
22 | virtual ~QtQuick2ApplicationViewer(); | |||
|
23 | ||||
|
24 | void setMainQmlFile(const QString &file); | |||
|
25 | void addImportPath(const QString &path); | |||
|
26 | ||||
|
27 | void showExpanded(); | |||
|
28 | ||||
|
29 | private: | |||
|
30 | class QtQuick2ApplicationViewerPrivate *d; | |||
|
31 | }; | |||
|
32 | ||||
|
33 | #endif // QTQUICK2APPLICATIONVIEWER_H |
@@ -0,0 +1,6 | |||||
|
1 | QT += qml quick widgets | |||
|
2 | ||||
|
3 | SOURCES += $$PWD/qtquick2applicationviewer.cpp | |||
|
4 | HEADERS += $$PWD/qtquick2applicationviewer.h | |||
|
5 | INCLUDEPATH += $$PWD | |||
|
6 |
@@ -0,0 +1,178 | |||||
|
1 | // checksum 0xbd34 version 0x80016 | |||
|
2 | /* | |||
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |||
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |||
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |||
|
6 | handled here. | |||
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |||
|
8 | may offer an updated version of it. | |||
|
9 | */ | |||
|
10 | ||||
|
11 | #include "qmlapplicationviewer.h" | |||
|
12 | ||||
|
13 | #include <QDir> | |||
|
14 | #include <QFileInfo> | |||
|
15 | #include <QApplication> | |||
|
16 | #include <QDeclarativeComponent> | |||
|
17 | #include <QDeclarativeEngine> | |||
|
18 | #include <QDeclarativeContext> | |||
|
19 | ||||
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |||
|
21 | ||||
|
22 | #ifdef HARMATTAN_BOOSTER | |||
|
23 | #include <MDeclarativeCache> | |||
|
24 | #endif | |||
|
25 | ||||
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |||
|
27 | ||||
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |||
|
29 | ||||
|
30 | #if !defined(NO_JSDEBUGGER) | |||
|
31 | #include <jsdebuggeragent.h> | |||
|
32 | #endif | |||
|
33 | #if !defined(NO_QMLOBSERVER) | |||
|
34 | #include <qdeclarativeviewobserver.h> | |||
|
35 | #endif | |||
|
36 | ||||
|
37 | // Enable debugging before any QDeclarativeEngine is created | |||
|
38 | struct QmlJsDebuggingEnabler | |||
|
39 | { | |||
|
40 | QmlJsDebuggingEnabler() | |||
|
41 | { | |||
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |||
|
43 | } | |||
|
44 | }; | |||
|
45 | ||||
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |||
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |||
|
48 | ||||
|
49 | #endif // QMLJSDEBUGGER | |||
|
50 | ||||
|
51 | class QmlApplicationViewerPrivate | |||
|
52 | { | |||
|
53 | QString mainQmlFile; | |||
|
54 | friend class QmlApplicationViewer; | |||
|
55 | static QString adjustPath(const QString &path); | |||
|
56 | }; | |||
|
57 | ||||
|
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |||
|
59 | { | |||
|
60 | #ifdef Q_OS_MAC | |||
|
61 | if (!QDir::isAbsolutePath(path)) | |||
|
62 | return QString::fromLatin1("%1/../Resources/%2") | |||
|
63 | .arg(QCoreApplication::applicationDirPath(), path); | |||
|
64 | #elif defined(Q_OS_QNX) | |||
|
65 | if (!QDir::isAbsolutePath(path)) | |||
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |||
|
67 | #elif !defined(Q_OS_ANDROID) | |||
|
68 | QString pathInInstallDir = | |||
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |||
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |||
|
71 | return pathInInstallDir; | |||
|
72 | pathInInstallDir = | |||
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |||
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |||
|
75 | return pathInInstallDir; | |||
|
76 | #endif | |||
|
77 | return path; | |||
|
78 | } | |||
|
79 | ||||
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |||
|
81 | : QDeclarativeView(parent) | |||
|
82 | , d(new QmlApplicationViewerPrivate()) | |||
|
83 | { | |||
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |||
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |||
|
86 | ||||
|
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |||
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |||
|
89 | #if !defined(NO_JSDEBUGGER) | |||
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |||
|
91 | #endif | |||
|
92 | #if !defined(NO_QMLOBSERVER) | |||
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |||
|
94 | #endif | |||
|
95 | #endif | |||
|
96 | addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); | |||
|
97 | } | |||
|
98 | ||||
|
99 | QmlApplicationViewer::~QmlApplicationViewer() | |||
|
100 | { | |||
|
101 | delete d; | |||
|
102 | } | |||
|
103 | ||||
|
104 | QmlApplicationViewer *QmlApplicationViewer::create() | |||
|
105 | { | |||
|
106 | return new QmlApplicationViewer(); | |||
|
107 | } | |||
|
108 | ||||
|
109 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |||
|
110 | { | |||
|
111 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |||
|
112 | #ifdef Q_OS_ANDROID | |||
|
113 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |||
|
114 | #else | |||
|
115 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |||
|
116 | #endif | |||
|
117 | } | |||
|
118 | ||||
|
119 | void QmlApplicationViewer::addImportPath(const QString &path) | |||
|
120 | { | |||
|
121 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |||
|
122 | } | |||
|
123 | ||||
|
124 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |||
|
125 | { | |||
|
126 | #if QT_VERSION < 0x050000 | |||
|
127 | Qt::WidgetAttribute attribute; | |||
|
128 | switch (orientation) { | |||
|
129 | #if QT_VERSION < 0x040702 | |||
|
130 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |||
|
131 | case ScreenOrientationLockPortrait: | |||
|
132 | attribute = static_cast<Qt::WidgetAttribute>(128); | |||
|
133 | break; | |||
|
134 | case ScreenOrientationLockLandscape: | |||
|
135 | attribute = static_cast<Qt::WidgetAttribute>(129); | |||
|
136 | break; | |||
|
137 | default: | |||
|
138 | case ScreenOrientationAuto: | |||
|
139 | attribute = static_cast<Qt::WidgetAttribute>(130); | |||
|
140 | break; | |||
|
141 | #else // QT_VERSION < 0x040702 | |||
|
142 | case ScreenOrientationLockPortrait: | |||
|
143 | attribute = Qt::WA_LockPortraitOrientation; | |||
|
144 | break; | |||
|
145 | case ScreenOrientationLockLandscape: | |||
|
146 | attribute = Qt::WA_LockLandscapeOrientation; | |||
|
147 | break; | |||
|
148 | default: | |||
|
149 | case ScreenOrientationAuto: | |||
|
150 | attribute = Qt::WA_AutoOrientation; | |||
|
151 | break; | |||
|
152 | #endif // QT_VERSION < 0x040702 | |||
|
153 | }; | |||
|
154 | setAttribute(attribute, true); | |||
|
155 | #else // QT_VERSION < 0x050000 | |||
|
156 | Q_UNUSED(orientation) | |||
|
157 | #endif // QT_VERSION < 0x050000 | |||
|
158 | } | |||
|
159 | ||||
|
160 | void QmlApplicationViewer::showExpanded() | |||
|
161 | { | |||
|
162 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |||
|
163 | showFullScreen(); | |||
|
164 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |||
|
165 | showMaximized(); | |||
|
166 | #else | |||
|
167 | show(); | |||
|
168 | #endif | |||
|
169 | } | |||
|
170 | ||||
|
171 | QApplication *createApplication(int &argc, char **argv) | |||
|
172 | { | |||
|
173 | #ifdef HARMATTAN_BOOSTER | |||
|
174 | return MDeclarativeCache::qApplication(argc, argv); | |||
|
175 | #else | |||
|
176 | return new QApplication(argc, argv); | |||
|
177 | #endif | |||
|
178 | } |
@@ -0,0 +1,46 | |||||
|
1 | // checksum 0xc67a version 0x80016 | |||
|
2 | /* | |||
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |||
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |||
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |||
|
6 | handled here. | |||
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |||
|
8 | may offer an updated version of it. | |||
|
9 | */ | |||
|
10 | ||||
|
11 | #ifndef QMLAPPLICATIONVIEWER_H | |||
|
12 | #define QMLAPPLICATIONVIEWER_H | |||
|
13 | ||||
|
14 | #include <QDeclarativeView> | |||
|
15 | ||||
|
16 | class QmlApplicationViewer : public QDeclarativeView | |||
|
17 | { | |||
|
18 | Q_OBJECT | |||
|
19 | ||||
|
20 | public: | |||
|
21 | enum ScreenOrientation { | |||
|
22 | ScreenOrientationLockPortrait, | |||
|
23 | ScreenOrientationLockLandscape, | |||
|
24 | ScreenOrientationAuto | |||
|
25 | }; | |||
|
26 | ||||
|
27 | explicit QmlApplicationViewer(QWidget *parent = 0); | |||
|
28 | virtual ~QmlApplicationViewer(); | |||
|
29 | ||||
|
30 | static QmlApplicationViewer *create(); | |||
|
31 | ||||
|
32 | void setMainQmlFile(const QString &file); | |||
|
33 | void addImportPath(const QString &path); | |||
|
34 | ||||
|
35 | // Note that this will only have an effect on Fremantle. | |||
|
36 | void setOrientation(ScreenOrientation orientation); | |||
|
37 | ||||
|
38 | void showExpanded(); | |||
|
39 | ||||
|
40 | private: | |||
|
41 | class QmlApplicationViewerPrivate *d; | |||
|
42 | }; | |||
|
43 | ||||
|
44 | QApplication *createApplication(int &argc, char **argv); | |||
|
45 | ||||
|
46 | #endif // QMLAPPLICATIONVIEWER_H |
@@ -0,0 +1,13 | |||||
|
1 | QT += declarative | |||
|
2 | ||||
|
3 | SOURCES += $$PWD/qmlapplicationviewer.cpp | |||
|
4 | HEADERS += $$PWD/qmlapplicationviewer.h | |||
|
5 | INCLUDEPATH += $$PWD | |||
|
6 | ||||
|
7 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set | |||
|
8 | !isEmpty(QMLJSDEBUGGER_PATH) { | |||
|
9 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) | |||
|
10 | } else { | |||
|
11 | DEFINES -= QMLJSDEBUGGER | |||
|
12 | } | |||
|
13 |
@@ -0,0 +1,178 | |||||
|
1 | // checksum 0xbd34 version 0x80016 | |||
|
2 | /* | |||
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |||
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |||
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |||
|
6 | handled here. | |||
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |||
|
8 | may offer an updated version of it. | |||
|
9 | */ | |||
|
10 | ||||
|
11 | #include "qmlapplicationviewer.h" | |||
|
12 | ||||
|
13 | #include <QDir> | |||
|
14 | #include <QFileInfo> | |||
|
15 | #include <QApplication> | |||
|
16 | #include <QDeclarativeComponent> | |||
|
17 | #include <QDeclarativeEngine> | |||
|
18 | #include <QDeclarativeContext> | |||
|
19 | ||||
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |||
|
21 | ||||
|
22 | #ifdef HARMATTAN_BOOSTER | |||
|
23 | #include <MDeclarativeCache> | |||
|
24 | #endif | |||
|
25 | ||||
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |||
|
27 | ||||
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |||
|
29 | ||||
|
30 | #if !defined(NO_JSDEBUGGER) | |||
|
31 | #include <jsdebuggeragent.h> | |||
|
32 | #endif | |||
|
33 | #if !defined(NO_QMLOBSERVER) | |||
|
34 | #include <qdeclarativeviewobserver.h> | |||
|
35 | #endif | |||
|
36 | ||||
|
37 | // Enable debugging before any QDeclarativeEngine is created | |||
|
38 | struct QmlJsDebuggingEnabler | |||
|
39 | { | |||
|
40 | QmlJsDebuggingEnabler() | |||
|
41 | { | |||
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |||
|
43 | } | |||
|
44 | }; | |||
|
45 | ||||
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |||
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |||
|
48 | ||||
|
49 | #endif // QMLJSDEBUGGER | |||
|
50 | ||||
|
51 | class QmlApplicationViewerPrivate | |||
|
52 | { | |||
|
53 | QString mainQmlFile; | |||
|
54 | friend class QmlApplicationViewer; | |||
|
55 | static QString adjustPath(const QString &path); | |||
|
56 | }; | |||
|
57 | ||||
|
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |||
|
59 | { | |||
|
60 | #ifdef Q_OS_MAC | |||
|
61 | if (!QDir::isAbsolutePath(path)) | |||
|
62 | return QString::fromLatin1("%1/../Resources/%2") | |||
|
63 | .arg(QCoreApplication::applicationDirPath(), path); | |||
|
64 | #elif defined(Q_OS_QNX) | |||
|
65 | if (!QDir::isAbsolutePath(path)) | |||
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |||
|
67 | #elif !defined(Q_OS_ANDROID) | |||
|
68 | QString pathInInstallDir = | |||
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |||
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |||
|
71 | return pathInInstallDir; | |||
|
72 | pathInInstallDir = | |||
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |||
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |||
|
75 | return pathInInstallDir; | |||
|
76 | #endif | |||
|
77 | return path; | |||
|
78 | } | |||
|
79 | ||||
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |||
|
81 | : QDeclarativeView(parent) | |||
|
82 | , d(new QmlApplicationViewerPrivate()) | |||
|
83 | { | |||
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |||
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |||
|
86 | ||||
|
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |||
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |||
|
89 | #if !defined(NO_JSDEBUGGER) | |||
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |||
|
91 | #endif | |||
|
92 | #if !defined(NO_QMLOBSERVER) | |||
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |||
|
94 | #endif | |||
|
95 | #endif | |||
|
96 | addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); | |||
|
97 | } | |||
|
98 | ||||
|
99 | QmlApplicationViewer::~QmlApplicationViewer() | |||
|
100 | { | |||
|
101 | delete d; | |||
|
102 | } | |||
|
103 | ||||
|
104 | QmlApplicationViewer *QmlApplicationViewer::create() | |||
|
105 | { | |||
|
106 | return new QmlApplicationViewer(); | |||
|
107 | } | |||
|
108 | ||||
|
109 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |||
|
110 | { | |||
|
111 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |||
|
112 | #ifdef Q_OS_ANDROID | |||
|
113 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |||
|
114 | #else | |||
|
115 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |||
|
116 | #endif | |||
|
117 | } | |||
|
118 | ||||
|
119 | void QmlApplicationViewer::addImportPath(const QString &path) | |||
|
120 | { | |||
|
121 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |||
|
122 | } | |||
|
123 | ||||
|
124 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |||
|
125 | { | |||
|
126 | #if QT_VERSION < 0x050000 | |||
|
127 | Qt::WidgetAttribute attribute; | |||
|
128 | switch (orientation) { | |||
|
129 | #if QT_VERSION < 0x040702 | |||
|
130 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |||
|
131 | case ScreenOrientationLockPortrait: | |||
|
132 | attribute = static_cast<Qt::WidgetAttribute>(128); | |||
|
133 | break; | |||
|
134 | case ScreenOrientationLockLandscape: | |||
|
135 | attribute = static_cast<Qt::WidgetAttribute>(129); | |||
|
136 | break; | |||
|
137 | default: | |||
|
138 | case ScreenOrientationAuto: | |||
|
139 | attribute = static_cast<Qt::WidgetAttribute>(130); | |||
|
140 | break; | |||
|
141 | #else // QT_VERSION < 0x040702 | |||
|
142 | case ScreenOrientationLockPortrait: | |||
|
143 | attribute = Qt::WA_LockPortraitOrientation; | |||
|
144 | break; | |||
|
145 | case ScreenOrientationLockLandscape: | |||
|
146 | attribute = Qt::WA_LockLandscapeOrientation; | |||
|
147 | break; | |||
|
148 | default: | |||
|
149 | case ScreenOrientationAuto: | |||
|
150 | attribute = Qt::WA_AutoOrientation; | |||
|
151 | break; | |||
|
152 | #endif // QT_VERSION < 0x040702 | |||
|
153 | }; | |||
|
154 | setAttribute(attribute, true); | |||
|
155 | #else // QT_VERSION < 0x050000 | |||
|
156 | Q_UNUSED(orientation) | |||
|
157 | #endif // QT_VERSION < 0x050000 | |||
|
158 | } | |||
|
159 | ||||
|
160 | void QmlApplicationViewer::showExpanded() | |||
|
161 | { | |||
|
162 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |||
|
163 | showFullScreen(); | |||
|
164 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |||
|
165 | showMaximized(); | |||
|
166 | #else | |||
|
167 | show(); | |||
|
168 | #endif | |||
|
169 | } | |||
|
170 | ||||
|
171 | QApplication *createApplication(int &argc, char **argv) | |||
|
172 | { | |||
|
173 | #ifdef HARMATTAN_BOOSTER | |||
|
174 | return MDeclarativeCache::qApplication(argc, argv); | |||
|
175 | #else | |||
|
176 | return new QApplication(argc, argv); | |||
|
177 | #endif | |||
|
178 | } |
@@ -0,0 +1,46 | |||||
|
1 | // checksum 0xc67a version 0x80016 | |||
|
2 | /* | |||
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |||
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |||
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |||
|
6 | handled here. | |||
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |||
|
8 | may offer an updated version of it. | |||
|
9 | */ | |||
|
10 | ||||
|
11 | #ifndef QMLAPPLICATIONVIEWER_H | |||
|
12 | #define QMLAPPLICATIONVIEWER_H | |||
|
13 | ||||
|
14 | #include <QDeclarativeView> | |||
|
15 | ||||
|
16 | class QmlApplicationViewer : public QDeclarativeView | |||
|
17 | { | |||
|
18 | Q_OBJECT | |||
|
19 | ||||
|
20 | public: | |||
|
21 | enum ScreenOrientation { | |||
|
22 | ScreenOrientationLockPortrait, | |||
|
23 | ScreenOrientationLockLandscape, | |||
|
24 | ScreenOrientationAuto | |||
|
25 | }; | |||
|
26 | ||||
|
27 | explicit QmlApplicationViewer(QWidget *parent = 0); | |||
|
28 | virtual ~QmlApplicationViewer(); | |||
|
29 | ||||
|
30 | static QmlApplicationViewer *create(); | |||
|
31 | ||||
|
32 | void setMainQmlFile(const QString &file); | |||
|
33 | void addImportPath(const QString &path); | |||
|
34 | ||||
|
35 | // Note that this will only have an effect on Fremantle. | |||
|
36 | void setOrientation(ScreenOrientation orientation); | |||
|
37 | ||||
|
38 | void showExpanded(); | |||
|
39 | ||||
|
40 | private: | |||
|
41 | class QmlApplicationViewerPrivate *d; | |||
|
42 | }; | |||
|
43 | ||||
|
44 | QApplication *createApplication(int &argc, char **argv); | |||
|
45 | ||||
|
46 | #endif // QMLAPPLICATIONVIEWER_H |
@@ -0,0 +1,13 | |||||
|
1 | QT += declarative | |||
|
2 | ||||
|
3 | SOURCES += $$PWD/qmlapplicationviewer.cpp | |||
|
4 | HEADERS += $$PWD/qmlapplicationviewer.h | |||
|
5 | INCLUDEPATH += $$PWD | |||
|
6 | ||||
|
7 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set | |||
|
8 | !isEmpty(QMLJSDEBUGGER_PATH) { | |||
|
9 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) | |||
|
10 | } else { | |||
|
11 | DEFINES -= QMLJSDEBUGGER | |||
|
12 | } | |||
|
13 |
@@ -0,0 +1,178 | |||||
|
1 | // checksum 0xbd34 version 0x80016 | |||
|
2 | /* | |||
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |||
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |||
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |||
|
6 | handled here. | |||
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |||
|
8 | may offer an updated version of it. | |||
|
9 | */ | |||
|
10 | ||||
|
11 | #include "qmlapplicationviewer.h" | |||
|
12 | ||||
|
13 | #include <QDir> | |||
|
14 | #include <QFileInfo> | |||
|
15 | #include <QApplication> | |||
|
16 | #include <QDeclarativeComponent> | |||
|
17 | #include <QDeclarativeEngine> | |||
|
18 | #include <QDeclarativeContext> | |||
|
19 | ||||
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |||
|
21 | ||||
|
22 | #ifdef HARMATTAN_BOOSTER | |||
|
23 | #include <MDeclarativeCache> | |||
|
24 | #endif | |||
|
25 | ||||
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |||
|
27 | ||||
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |||
|
29 | ||||
|
30 | #if !defined(NO_JSDEBUGGER) | |||
|
31 | #include <jsdebuggeragent.h> | |||
|
32 | #endif | |||
|
33 | #if !defined(NO_QMLOBSERVER) | |||
|
34 | #include <qdeclarativeviewobserver.h> | |||
|
35 | #endif | |||
|
36 | ||||
|
37 | // Enable debugging before any QDeclarativeEngine is created | |||
|
38 | struct QmlJsDebuggingEnabler | |||
|
39 | { | |||
|
40 | QmlJsDebuggingEnabler() | |||
|
41 | { | |||
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |||
|
43 | } | |||
|
44 | }; | |||
|
45 | ||||
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |||
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |||
|
48 | ||||
|
49 | #endif // QMLJSDEBUGGER | |||
|
50 | ||||
|
51 | class QmlApplicationViewerPrivate | |||
|
52 | { | |||
|
53 | QString mainQmlFile; | |||
|
54 | friend class QmlApplicationViewer; | |||
|
55 | static QString adjustPath(const QString &path); | |||
|
56 | }; | |||
|
57 | ||||
|
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |||
|
59 | { | |||
|
60 | #ifdef Q_OS_MAC | |||
|
61 | if (!QDir::isAbsolutePath(path)) | |||
|
62 | return QString::fromLatin1("%1/../Resources/%2") | |||
|
63 | .arg(QCoreApplication::applicationDirPath(), path); | |||
|
64 | #elif defined(Q_OS_QNX) | |||
|
65 | if (!QDir::isAbsolutePath(path)) | |||
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |||
|
67 | #elif !defined(Q_OS_ANDROID) | |||
|
68 | QString pathInInstallDir = | |||
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |||
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |||
|
71 | return pathInInstallDir; | |||
|
72 | pathInInstallDir = | |||
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |||
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |||
|
75 | return pathInInstallDir; | |||
|
76 | #endif | |||
|
77 | return path; | |||
|
78 | } | |||
|
79 | ||||
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |||
|
81 | : QDeclarativeView(parent) | |||
|
82 | , d(new QmlApplicationViewerPrivate()) | |||
|
83 | { | |||
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |||
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |||
|
86 | ||||
|
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |||
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |||
|
89 | #if !defined(NO_JSDEBUGGER) | |||
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |||
|
91 | #endif | |||
|
92 | #if !defined(NO_QMLOBSERVER) | |||
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |||
|
94 | #endif | |||
|
95 | #endif | |||
|
96 | addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); | |||
|
97 | } | |||
|
98 | ||||
|
99 | QmlApplicationViewer::~QmlApplicationViewer() | |||
|
100 | { | |||
|
101 | delete d; | |||
|
102 | } | |||
|
103 | ||||
|
104 | QmlApplicationViewer *QmlApplicationViewer::create() | |||
|
105 | { | |||
|
106 | return new QmlApplicationViewer(); | |||
|
107 | } | |||
|
108 | ||||
|
109 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |||
|
110 | { | |||
|
111 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |||
|
112 | #ifdef Q_OS_ANDROID | |||
|
113 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |||
|
114 | #else | |||
|
115 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |||
|
116 | #endif | |||
|
117 | } | |||
|
118 | ||||
|
119 | void QmlApplicationViewer::addImportPath(const QString &path) | |||
|
120 | { | |||
|
121 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |||
|
122 | } | |||
|
123 | ||||
|
124 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |||
|
125 | { | |||
|
126 | #if QT_VERSION < 0x050000 | |||
|
127 | Qt::WidgetAttribute attribute; | |||
|
128 | switch (orientation) { | |||
|
129 | #if QT_VERSION < 0x040702 | |||
|
130 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |||
|
131 | case ScreenOrientationLockPortrait: | |||
|
132 | attribute = static_cast<Qt::WidgetAttribute>(128); | |||
|
133 | break; | |||
|
134 | case ScreenOrientationLockLandscape: | |||
|
135 | attribute = static_cast<Qt::WidgetAttribute>(129); | |||
|
136 | break; | |||
|
137 | default: | |||
|
138 | case ScreenOrientationAuto: | |||
|
139 | attribute = static_cast<Qt::WidgetAttribute>(130); | |||
|
140 | break; | |||
|
141 | #else // QT_VERSION < 0x040702 | |||
|
142 | case ScreenOrientationLockPortrait: | |||
|
143 | attribute = Qt::WA_LockPortraitOrientation; | |||
|
144 | break; | |||
|
145 | case ScreenOrientationLockLandscape: | |||
|
146 | attribute = Qt::WA_LockLandscapeOrientation; | |||
|
147 | break; | |||
|
148 | default: | |||
|
149 | case ScreenOrientationAuto: | |||
|
150 | attribute = Qt::WA_AutoOrientation; | |||
|
151 | break; | |||
|
152 | #endif // QT_VERSION < 0x040702 | |||
|
153 | }; | |||
|
154 | setAttribute(attribute, true); | |||
|
155 | #else // QT_VERSION < 0x050000 | |||
|
156 | Q_UNUSED(orientation) | |||
|
157 | #endif // QT_VERSION < 0x050000 | |||
|
158 | } | |||
|
159 | ||||
|
160 | void QmlApplicationViewer::showExpanded() | |||
|
161 | { | |||
|
162 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |||
|
163 | showFullScreen(); | |||
|
164 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |||
|
165 | showMaximized(); | |||
|
166 | #else | |||
|
167 | show(); | |||
|
168 | #endif | |||
|
169 | } | |||
|
170 | ||||
|
171 | QApplication *createApplication(int &argc, char **argv) | |||
|
172 | { | |||
|
173 | #ifdef HARMATTAN_BOOSTER | |||
|
174 | return MDeclarativeCache::qApplication(argc, argv); | |||
|
175 | #else | |||
|
176 | return new QApplication(argc, argv); | |||
|
177 | #endif | |||
|
178 | } |
@@ -0,0 +1,46 | |||||
|
1 | // checksum 0xc67a version 0x80016 | |||
|
2 | /* | |||
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |||
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |||
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |||
|
6 | handled here. | |||
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |||
|
8 | may offer an updated version of it. | |||
|
9 | */ | |||
|
10 | ||||
|
11 | #ifndef QMLAPPLICATIONVIEWER_H | |||
|
12 | #define QMLAPPLICATIONVIEWER_H | |||
|
13 | ||||
|
14 | #include <QDeclarativeView> | |||
|
15 | ||||
|
16 | class QmlApplicationViewer : public QDeclarativeView | |||
|
17 | { | |||
|
18 | Q_OBJECT | |||
|
19 | ||||
|
20 | public: | |||
|
21 | enum ScreenOrientation { | |||
|
22 | ScreenOrientationLockPortrait, | |||
|
23 | ScreenOrientationLockLandscape, | |||
|
24 | ScreenOrientationAuto | |||
|
25 | }; | |||
|
26 | ||||
|
27 | explicit QmlApplicationViewer(QWidget *parent = 0); | |||
|
28 | virtual ~QmlApplicationViewer(); | |||
|
29 | ||||
|
30 | static QmlApplicationViewer *create(); | |||
|
31 | ||||
|
32 | void setMainQmlFile(const QString &file); | |||
|
33 | void addImportPath(const QString &path); | |||
|
34 | ||||
|
35 | // Note that this will only have an effect on Fremantle. | |||
|
36 | void setOrientation(ScreenOrientation orientation); | |||
|
37 | ||||
|
38 | void showExpanded(); | |||
|
39 | ||||
|
40 | private: | |||
|
41 | class QmlApplicationViewerPrivate *d; | |||
|
42 | }; | |||
|
43 | ||||
|
44 | QApplication *createApplication(int &argc, char **argv); | |||
|
45 | ||||
|
46 | #endif // QMLAPPLICATIONVIEWER_H |
@@ -0,0 +1,13 | |||||
|
1 | QT += declarative | |||
|
2 | ||||
|
3 | SOURCES += $$PWD/qmlapplicationviewer.cpp | |||
|
4 | HEADERS += $$PWD/qmlapplicationviewer.h | |||
|
5 | INCLUDEPATH += $$PWD | |||
|
6 | ||||
|
7 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set | |||
|
8 | !isEmpty(QMLJSDEBUGGER_PATH) { | |||
|
9 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) | |||
|
10 | } else { | |||
|
11 | DEFINES -= QMLJSDEBUGGER | |||
|
12 | } | |||
|
13 |
@@ -0,0 +1,71 | |||||
|
1 | // checksum 0x56a9 version 0x80001 | |||
|
2 | /* | |||
|
3 | This file was generated by the Qt Quick 2 Application wizard of Qt Creator. | |||
|
4 | QtQuick2ApplicationViewer is a convenience class containing mobile device specific | |||
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |||
|
6 | handled here. | |||
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |||
|
8 | may offer an updated version of it. | |||
|
9 | */ | |||
|
10 | ||||
|
11 | #include "qtquick2applicationviewer.h" | |||
|
12 | ||||
|
13 | #include <QtCore/QCoreApplication> | |||
|
14 | #include <QtCore/QDir> | |||
|
15 | #include <QtQml/QQmlEngine> | |||
|
16 | ||||
|
17 | class QtQuick2ApplicationViewerPrivate | |||
|
18 | { | |||
|
19 | QString mainQmlFile; | |||
|
20 | friend class QtQuick2ApplicationViewer; | |||
|
21 | static QString adjustPath(const QString &path); | |||
|
22 | }; | |||
|
23 | ||||
|
24 | QString QtQuick2ApplicationViewerPrivate::adjustPath(const QString &path) | |||
|
25 | { | |||
|
26 | #if defined(Q_OS_MAC) | |||
|
27 | if (!QDir::isAbsolutePath(path)) | |||
|
28 | return QString::fromLatin1("%1/../Resources/%2") | |||
|
29 | .arg(QCoreApplication::applicationDirPath(), path); | |||
|
30 | #elif defined(Q_OS_UNIX) | |||
|
31 | const QString pathInInstallDir = | |||
|
32 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |||
|
33 | if (QFileInfo(pathInInstallDir).exists()) | |||
|
34 | return pathInInstallDir; | |||
|
35 | #endif | |||
|
36 | return path; | |||
|
37 | } | |||
|
38 | ||||
|
39 | QtQuick2ApplicationViewer::QtQuick2ApplicationViewer(QWindow *parent) | |||
|
40 | : QQuickView(parent) | |||
|
41 | , d(new QtQuick2ApplicationViewerPrivate()) | |||
|
42 | { | |||
|
43 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |||
|
44 | setResizeMode(QQuickView::SizeRootObjectToView); | |||
|
45 | addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QString::fromLatin1("qml"))); | |||
|
46 | } | |||
|
47 | ||||
|
48 | QtQuick2ApplicationViewer::~QtQuick2ApplicationViewer() | |||
|
49 | { | |||
|
50 | delete d; | |||
|
51 | } | |||
|
52 | ||||
|
53 | void QtQuick2ApplicationViewer::setMainQmlFile(const QString &file) | |||
|
54 | { | |||
|
55 | d->mainQmlFile = QtQuick2ApplicationViewerPrivate::adjustPath(file); | |||
|
56 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |||
|
57 | } | |||
|
58 | ||||
|
59 | void QtQuick2ApplicationViewer::addImportPath(const QString &path) | |||
|
60 | { | |||
|
61 | engine()->addImportPath(QtQuick2ApplicationViewerPrivate::adjustPath(path)); | |||
|
62 | } | |||
|
63 | ||||
|
64 | void QtQuick2ApplicationViewer::showExpanded() | |||
|
65 | { | |||
|
66 | #if defined(Q_WS_SIMULATOR) | |||
|
67 | showFullScreen(); | |||
|
68 | #else | |||
|
69 | show(); | |||
|
70 | #endif | |||
|
71 | } |
@@ -0,0 +1,33 | |||||
|
1 | // checksum 0xfde6 version 0x80001 | |||
|
2 | /* | |||
|
3 | This file was generated by the Qt Quick 2 Application wizard of Qt Creator. | |||
|
4 | QtQuick2ApplicationViewer is a convenience class containing mobile device specific | |||
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |||
|
6 | handled here. | |||
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |||
|
8 | may offer an updated version of it. | |||
|
9 | */ | |||
|
10 | ||||
|
11 | #ifndef QTQUICK2APPLICATIONVIEWER_H | |||
|
12 | #define QTQUICK2APPLICATIONVIEWER_H | |||
|
13 | ||||
|
14 | #include <QtQuick/QQuickView> | |||
|
15 | ||||
|
16 | class QtQuick2ApplicationViewer : public QQuickView | |||
|
17 | { | |||
|
18 | Q_OBJECT | |||
|
19 | ||||
|
20 | public: | |||
|
21 | explicit QtQuick2ApplicationViewer(QWindow *parent = 0); | |||
|
22 | virtual ~QtQuick2ApplicationViewer(); | |||
|
23 | ||||
|
24 | void setMainQmlFile(const QString &file); | |||
|
25 | void addImportPath(const QString &path); | |||
|
26 | ||||
|
27 | void showExpanded(); | |||
|
28 | ||||
|
29 | private: | |||
|
30 | class QtQuick2ApplicationViewerPrivate *d; | |||
|
31 | }; | |||
|
32 | ||||
|
33 | #endif // QTQUICK2APPLICATIONVIEWER_H |
@@ -0,0 +1,6 | |||||
|
1 | QT += qml quick widgets | |||
|
2 | ||||
|
3 | SOURCES += $$PWD/qtquick2applicationviewer.cpp | |||
|
4 | HEADERS += $$PWD/qtquick2applicationviewer.h | |||
|
5 | INCLUDEPATH += $$PWD | |||
|
6 |
1 | NO CONTENT: file renamed from demos/shared/qmlapplicationviewer/qmlapplicationviewer.cpp to demos/qmlaxes/qmlapplicationviewer/qmlapplicationviewer.cpp |
|
NO CONTENT: file renamed from demos/shared/qmlapplicationviewer/qmlapplicationviewer.cpp to demos/qmlaxes/qmlapplicationviewer/qmlapplicationviewer.cpp |
1 | NO CONTENT: file renamed from demos/shared/qmlapplicationviewer/qmlapplicationviewer.h to demos/qmlaxes/qmlapplicationviewer/qmlapplicationviewer.h |
|
NO CONTENT: file renamed from demos/shared/qmlapplicationviewer/qmlapplicationviewer.h to demos/qmlaxes/qmlapplicationviewer/qmlapplicationviewer.h |
1 | NO CONTENT: file renamed from demos/shared/qmlapplicationviewer/qmlapplicationviewer.pri to demos/qmlaxes/qmlapplicationviewer/qmlapplicationviewer.pri |
|
NO CONTENT: file renamed from demos/shared/qmlapplicationviewer/qmlapplicationviewer.pri to demos/qmlaxes/qmlapplicationviewer/qmlapplicationviewer.pri |
@@ -1,9 +1,9 | |||||
1 | !include( ../demos.pri ) { |
|
1 | !include( ../demos.pri ) { | |
2 | error( "Couldn't find the demos.pri file!" ) |
|
2 | error( "Couldn't find the demos.pri file!" ) | |
3 | } |
|
3 | } | |
4 |
|
4 | |||
5 | RESOURCES += resources.qrc |
|
5 | RESOURCES += resources.qrc | |
6 | SOURCES += main.cpp |
|
6 | SOURCES += main.cpp | |
7 | OTHER_FILES += qml/qmlaxes/* |
|
7 | OTHER_FILES += qml/qmlaxes/* | |
8 |
|
8 | |||
9 |
include( |
|
9 | include(qmlapplicationviewer/qmlapplicationviewer.pri) |
@@ -1,9 +1,9 | |||||
1 | !include( ../demos.pri ) { |
|
1 | !include( ../demos.pri ) { | |
2 | error( "Couldn't find the demos.pri file!" ) |
|
2 | error( "Couldn't find the demos.pri file!" ) | |
3 | } |
|
3 | } | |
4 |
|
4 | |||
5 | RESOURCES += resources.qrc |
|
5 | RESOURCES += resources.qrc | |
6 | SOURCES += main.cpp |
|
6 | SOURCES += main.cpp | |
7 | OTHER_FILES += qml/qmlchart/* |
|
7 | OTHER_FILES += qml/qmlchart/* | |
8 |
|
8 | |||
9 |
include( |
|
9 | include(qmlapplicationviewer/qmlapplicationviewer.pri) |
@@ -1,9 +1,9 | |||||
1 | !include( ../demos.pri ) { |
|
1 | !include( ../demos.pri ) { | |
2 | error( "Couldn't find the demos.pri file!" ) |
|
2 | error( "Couldn't find the demos.pri file!" ) | |
3 | } |
|
3 | } | |
4 |
|
4 | |||
5 | RESOURCES += resources.qrc |
|
5 | RESOURCES += resources.qrc | |
6 | SOURCES += main.cpp |
|
6 | SOURCES += main.cpp | |
7 | OTHER_FILES += qml/qmlcustomizations/* |
|
7 | OTHER_FILES += qml/qmlcustomizations/* | |
8 |
|
8 | |||
9 |
include( |
|
9 | include(qmlapplicationviewer/qmlapplicationviewer.pri) |
@@ -1,9 +1,9 | |||||
1 | !include( ../demos.pri ) { |
|
1 | !include( ../demos.pri ) { | |
2 | error( "Couldn't find the demos.pri file!" ) |
|
2 | error( "Couldn't find the demos.pri file!" ) | |
3 | } |
|
3 | } | |
4 |
|
4 | |||
5 | RESOURCES += resources.qrc |
|
5 | RESOURCES += resources.qrc | |
6 | SOURCES += main.cpp |
|
6 | SOURCES += main.cpp | |
7 | OTHER_FILES += qml/qmlcustomlegend/* |
|
7 | OTHER_FILES += qml/qmlcustomlegend/* | |
8 |
|
8 | |||
9 |
include( |
|
9 | include(qmlapplicationviewer/qmlapplicationviewer.pri) |
@@ -1,13 +1,13 | |||||
1 | !include( ../demos.pri ) { |
|
1 | !include( ../demos.pri ) { | |
2 | error( "Couldn't find the demos.pri file!" ) |
|
2 | error( "Couldn't find the demos.pri file!" ) | |
3 | } |
|
3 | } | |
4 |
|
4 | |||
5 | RESOURCES += resources.qrc |
|
5 | RESOURCES += resources.qrc | |
6 | SOURCES += main.cpp\ |
|
6 | SOURCES += main.cpp\ | |
7 | customtablemodel.cpp \ |
|
7 | customtablemodel.cpp \ | |
8 | declarativemodel.cpp |
|
8 | declarativemodel.cpp | |
9 | HEADERS += customtablemodel.h \ |
|
9 | HEADERS += customtablemodel.h \ | |
10 | declarativemodel.h |
|
10 | declarativemodel.h | |
11 | OTHER_FILES += qml/qmlcustommodel/* |
|
11 | OTHER_FILES += qml/qmlcustommodel/* | |
12 |
|
12 | |||
13 |
include( |
|
13 | include(qmlapplicationviewer/qmlapplicationviewer.pri) |
@@ -1,9 +1,9 | |||||
1 | !include( ../demos.pri ) { |
|
1 | !include( ../demos.pri ) { | |
2 | error( "Couldn't find the demos.pri file!" ) |
|
2 | error( "Couldn't find the demos.pri file!" ) | |
3 | } |
|
3 | } | |
4 |
|
4 | |||
5 | RESOURCES += resources.qrc |
|
5 | RESOURCES += resources.qrc | |
6 | SOURCES += main.cpp |
|
6 | SOURCES += main.cpp | |
7 | OTHER_FILES += qml/qmlf1legends/* |
|
7 | OTHER_FILES += qml/qmlf1legends/* | |
8 |
|
8 | |||
9 |
include( |
|
9 | include(qmlapplicationviewer/qmlapplicationviewer.pri) |
@@ -1,14 +1,14 | |||||
1 | !include( ../demos.pri ) { |
|
1 | !include( ../demos.pri ) { | |
2 | error( "Couldn't find the demos.pri file!" ) |
|
2 | error( "Couldn't find the demos.pri file!" ) | |
3 | } |
|
3 | } | |
4 |
|
4 | |||
5 | QT += opengl |
|
5 | QT += opengl | |
6 | RESOURCES += resources.qrc |
|
6 | RESOURCES += resources.qrc | |
7 | SOURCES += main.cpp \ |
|
7 | SOURCES += main.cpp \ | |
8 | datasource.cpp |
|
8 | datasource.cpp | |
9 | OTHER_FILES += qml/qmloscilloscope/* |
|
9 | OTHER_FILES += qml/qmloscilloscope/* | |
10 |
|
10 | |||
11 |
include( |
|
11 | include(qmlapplicationviewer/qmlapplicationviewer.pri) | |
12 |
|
12 | |||
13 | HEADERS += \ |
|
13 | HEADERS += \ | |
14 | datasource.h |
|
14 | datasource.h |
@@ -1,9 +1,9 | |||||
1 | !include( ../demos.pri ) { |
|
1 | !include( ../demos.pri ) { | |
2 | error( "Couldn't find the demos.pri file!" ) |
|
2 | error( "Couldn't find the demos.pri file!" ) | |
3 | } |
|
3 | } | |
4 |
|
4 | |||
5 | RESOURCES += resources.qrc |
|
5 | RESOURCES += resources.qrc | |
6 | SOURCES += main.cpp |
|
6 | SOURCES += main.cpp | |
7 | OTHER_FILES += qml/qmlpolarchart/* |
|
7 | OTHER_FILES += qml/qmlpolarchart/* | |
8 |
|
8 | |||
9 |
include( |
|
9 | include(qmlapplicationviewer/qmlapplicationviewer.pri) |
@@ -1,10 +1,10 | |||||
1 | !include( ../demos.pri ) { |
|
1 | !include( ../demos.pri ) { | |
2 | error( "Couldn't find the demos.pri file!" ) |
|
2 | error( "Couldn't find the demos.pri file!" ) | |
3 | } |
|
3 | } | |
4 |
|
4 | |||
5 | RESOURCES += resources.qrc |
|
5 | RESOURCES += resources.qrc | |
6 | SOURCES += main.cpp |
|
6 | SOURCES += main.cpp | |
7 | OTHER_FILES += qml/qmlweather/* |
|
7 | OTHER_FILES += qml/qmlweather/* | |
8 |
|
8 | |||
9 |
include( |
|
9 | include(qmlapplicationviewer/qmlapplicationviewer.pri) | |
10 |
|
10 |
1 | NO CONTENT: file renamed from demos/shared/qtquick2applicationviewer/qtquick2applicationviewer.cpp to demos/quick2chart/qtquick2applicationviewer/qtquick2applicationviewer.cpp |
|
NO CONTENT: file renamed from demos/shared/qtquick2applicationviewer/qtquick2applicationviewer.cpp to demos/quick2chart/qtquick2applicationviewer/qtquick2applicationviewer.cpp |
1 | NO CONTENT: file renamed from demos/shared/qtquick2applicationviewer/qtquick2applicationviewer.h to demos/quick2chart/qtquick2applicationviewer/qtquick2applicationviewer.h |
|
NO CONTENT: file renamed from demos/shared/qtquick2applicationviewer/qtquick2applicationviewer.h to demos/quick2chart/qtquick2applicationviewer/qtquick2applicationviewer.h |
1 | NO CONTENT: file renamed from demos/shared/qtquick2applicationviewer/qtquick2applicationviewer.pri to demos/quick2chart/qtquick2applicationviewer/qtquick2applicationviewer.pri |
|
NO CONTENT: file renamed from demos/shared/qtquick2applicationviewer/qtquick2applicationviewer.pri to demos/quick2chart/qtquick2applicationviewer/qtquick2applicationviewer.pri |
@@ -1,10 +1,10 | |||||
1 | !include( ../demos.pri ) { |
|
1 | !include( ../demos.pri ) { | |
2 | error( "Couldn't find the demos.pri file!" ) |
|
2 | error( "Couldn't find the demos.pri file!" ) | |
3 | } |
|
3 | } | |
4 |
|
4 | |||
5 | RESOURCES += resources.qrc |
|
5 | RESOURCES += resources.qrc | |
6 | SOURCES += main.cpp |
|
6 | SOURCES += main.cpp | |
7 | OTHER_FILES += qml/quick2chart/* |
|
7 | OTHER_FILES += qml/quick2chart/* | |
8 |
|
8 | |||
9 |
include( |
|
9 | include(qtquick2applicationviewer/qtquick2applicationviewer.pri) | |
10 |
|
10 |
@@ -1,14 +1,14 | |||||
1 | !include( ../demos.pri ) { |
|
1 | !include( ../demos.pri ) { | |
2 | error( "Couldn't find the demos.pri file!" ) |
|
2 | error( "Couldn't find the demos.pri file!" ) | |
3 | } |
|
3 | } | |
4 |
|
4 | |||
5 | QT += opengl |
|
5 | QT += opengl | |
6 | RESOURCES += resources.qrc |
|
6 | RESOURCES += resources.qrc | |
7 | SOURCES += main.cpp \ |
|
7 | SOURCES += main.cpp \ | |
8 | datasource.cpp |
|
8 | datasource.cpp | |
9 | OTHER_FILES += qml/quick2oscilloscope/* |
|
9 | OTHER_FILES += qml/quick2oscilloscope/* | |
10 |
|
10 | |||
11 |
include( |
|
11 | include(qtquick2applicationviewer/qtquick2applicationviewer.pri) | |
12 |
|
12 | |||
13 | HEADERS += \ |
|
13 | HEADERS += \ | |
14 | datasource.h |
|
14 | datasource.h |
@@ -1,9 +1,9 | |||||
1 | !include( ../examples.pri ) { |
|
1 | !include( ../examples.pri ) { | |
2 | error( "Couldn't find the examples.pri file!" ) |
|
2 | error( "Couldn't find the examples.pri file!" ) | |
3 | } |
|
3 | } | |
4 |
|
4 | |||
5 | RESOURCES += resources.qrc |
|
5 | RESOURCES += resources.qrc | |
6 | SOURCES += main.cpp |
|
6 | SOURCES += main.cpp | |
7 | OTHER_FILES += qml/qmlpiechart/* |
|
7 | OTHER_FILES += qml/qmlpiechart/* | |
8 |
|
8 | |||
9 |
include( |
|
9 | include(qmlapplicationviewer/qmlapplicationviewer.pri) |
@@ -1,9 +1,9 | |||||
1 | !include( ../tests.pri ) { |
|
1 | !include( ../tests.pri ) { | |
2 | error( "Couldn't find the test.pri file!" ) |
|
2 | error( "Couldn't find the test.pri file!" ) | |
3 | } |
|
3 | } | |
4 |
|
4 | |||
5 | RESOURCES += resources.qrc |
|
5 | RESOURCES += resources.qrc | |
6 | SOURCES += main.cpp |
|
6 | SOURCES += main.cpp | |
7 | OTHER_FILES += qml/qmlchartaxis/* |
|
7 | OTHER_FILES += qml/qmlchartaxis/* | |
8 |
|
8 | |||
9 |
include( |
|
9 | include(qmlapplicationviewer/qmlapplicationviewer.pri) |
@@ -1,9 +1,9 | |||||
1 | !include( ../tests.pri ) { |
|
1 | !include( ../tests.pri ) { | |
2 | error( "Couldn't find the test.pri file!" ) |
|
2 | error( "Couldn't find the test.pri file!" ) | |
3 | } |
|
3 | } | |
4 |
|
4 | |||
5 | RESOURCES += resources.qrc |
|
5 | RESOURCES += resources.qrc | |
6 | SOURCES += main.cpp |
|
6 | SOURCES += main.cpp | |
7 | OTHER_FILES += qml/qmlchartproperties/* |
|
7 | OTHER_FILES += qml/qmlchartproperties/* | |
8 |
|
8 | |||
9 |
include( |
|
9 | include(qmlapplicationviewer/qmlapplicationviewer.pri) |
@@ -1,9 +1,9 | |||||
1 | !include( ../tests.pri ) { |
|
1 | !include( ../tests.pri ) { | |
2 | error( "Couldn't find the test.pri file!" ) |
|
2 | error( "Couldn't find the test.pri file!" ) | |
3 | } |
|
3 | } | |
4 |
|
4 | |||
5 | RESOURCES += resources.qrc |
|
5 | RESOURCES += resources.qrc | |
6 | SOURCES += main.cpp |
|
6 | SOURCES += main.cpp | |
7 | OTHER_FILES += qml/quick2chartproperties/* |
|
7 | OTHER_FILES += qml/quick2chartproperties/* | |
8 |
|
8 | |||
9 |
include( |
|
9 | include(qtquick2applicationviewer/qtquick2applicationviewer.pri) |
General Comments 0
You need to be logged in to leave comments.
Login now