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