@@ -1,36 +1,37 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QApplication> |
|
21 | #include <QApplication> | |
22 | #include <QtDeclarative/QDeclarativeEngine> |
|
22 | #include <QtDeclarative/QDeclarativeEngine> | |
23 | #include "qmlapplicationviewer.h" |
|
23 | #include "qmlapplicationviewer.h" | |
24 |
|
24 | |||
25 | Q_DECL_EXPORT int main(int argc, char *argv[]) |
|
25 | Q_DECL_EXPORT int main(int argc, char *argv[]) | |
26 | { |
|
26 | { | |
27 | QScopedPointer<QApplication> app(createApplication(argc, argv)); |
|
27 | QScopedPointer<QApplication> app(createApplication(argc, argv)); | |
28 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); |
|
28 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); | |
|
29 | viewer->addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); | |||
29 |
|
30 | |||
30 | // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); |
|
31 | // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); | |
31 | viewer->setSource(QUrl("qrc:/qml/qmlaxes/loader.qml")); |
|
32 | viewer->setSource(QUrl("qrc:/qml/qmlaxes/loader.qml")); | |
32 | viewer->setRenderHint(QPainter::Antialiasing, true); |
|
33 | viewer->setRenderHint(QPainter::Antialiasing, true); | |
33 | viewer->showExpanded(); |
|
34 | viewer->showExpanded(); | |
34 |
|
35 | |||
35 | return app->exec(); |
|
36 | return app->exec(); | |
36 | } |
|
37 | } |
@@ -1,178 +1,177 | |||||
1 | // checksum 0xbd34 version 0x80016 |
|
1 | // checksum 0xbd34 version 0x80016 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #include "qmlapplicationviewer.h" |
|
11 | #include "qmlapplicationviewer.h" | |
12 |
|
12 | |||
13 | #include <QDir> |
|
13 | #include <QDir> | |
14 | #include <QFileInfo> |
|
14 | #include <QFileInfo> | |
15 | #include <QApplication> |
|
15 | #include <QApplication> | |
16 | #include <QDeclarativeComponent> |
|
16 | #include <QDeclarativeComponent> | |
17 | #include <QDeclarativeEngine> |
|
17 | #include <QDeclarativeEngine> | |
18 | #include <QDeclarativeContext> |
|
18 | #include <QDeclarativeContext> | |
19 |
|
19 | |||
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |
21 |
|
21 | |||
22 | #ifdef HARMATTAN_BOOSTER |
|
22 | #ifdef HARMATTAN_BOOSTER | |
23 | #include <MDeclarativeCache> |
|
23 | #include <MDeclarativeCache> | |
24 | #endif |
|
24 | #endif | |
25 |
|
25 | |||
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
27 |
|
27 | |||
28 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |
29 |
|
29 | |||
30 | #if !defined(NO_JSDEBUGGER) |
|
30 | #if !defined(NO_JSDEBUGGER) | |
31 | #include <jsdebuggeragent.h> |
|
31 | #include <jsdebuggeragent.h> | |
32 | #endif |
|
32 | #endif | |
33 | #if !defined(NO_QMLOBSERVER) |
|
33 | #if !defined(NO_QMLOBSERVER) | |
34 | #include <qdeclarativeviewobserver.h> |
|
34 | #include <qdeclarativeviewobserver.h> | |
35 | #endif |
|
35 | #endif | |
36 |
|
36 | |||
37 | // Enable debugging before any QDeclarativeEngine is created |
|
37 | // Enable debugging before any QDeclarativeEngine is created | |
38 | struct QmlJsDebuggingEnabler |
|
38 | struct QmlJsDebuggingEnabler | |
39 | { |
|
39 | { | |
40 | QmlJsDebuggingEnabler() |
|
40 | QmlJsDebuggingEnabler() | |
41 | { |
|
41 | { | |
42 | QDeclarativeDebugHelper::enableDebugging(); |
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |
43 | } |
|
43 | } | |
44 | }; |
|
44 | }; | |
45 |
|
45 | |||
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |
48 |
|
48 | |||
49 | #endif // QMLJSDEBUGGER |
|
49 | #endif // QMLJSDEBUGGER | |
50 |
|
50 | |||
51 | class QmlApplicationViewerPrivate |
|
51 | class QmlApplicationViewerPrivate | |
52 | { |
|
52 | { | |
53 | QString mainQmlFile; |
|
53 | QString mainQmlFile; | |
54 | friend class QmlApplicationViewer; |
|
54 | friend class QmlApplicationViewer; | |
55 | static QString adjustPath(const QString &path); |
|
55 | static QString adjustPath(const QString &path); | |
56 | }; |
|
56 | }; | |
57 |
|
57 | |||
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |
59 | { |
|
59 | { | |
60 | #ifdef Q_OS_MAC |
|
60 | #ifdef Q_OS_MAC | |
61 | if (!QDir::isAbsolutePath(path)) |
|
61 | if (!QDir::isAbsolutePath(path)) | |
62 | return QString::fromLatin1("%1/../Resources/%2") |
|
62 | return QString::fromLatin1("%1/../Resources/%2") | |
63 | .arg(QCoreApplication::applicationDirPath(), path); |
|
63 | .arg(QCoreApplication::applicationDirPath(), path); | |
64 | #elif defined(Q_OS_QNX) |
|
64 | #elif defined(Q_OS_QNX) | |
65 | if (!QDir::isAbsolutePath(path)) |
|
65 | if (!QDir::isAbsolutePath(path)) | |
66 | return QString::fromLatin1("app/native/%1").arg(path); |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
67 | #elif !defined(Q_OS_ANDROID) |
|
67 | #elif !defined(Q_OS_ANDROID) | |
68 | QString pathInInstallDir = |
|
68 | QString pathInInstallDir = | |
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); |
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
70 | if (QFileInfo(pathInInstallDir).exists()) |
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |
71 | return pathInInstallDir; |
|
71 | return pathInInstallDir; | |
72 | pathInInstallDir = |
|
72 | pathInInstallDir = | |
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
74 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |
75 | return pathInInstallDir; |
|
75 | return pathInInstallDir; | |
76 | #endif |
|
76 | #endif | |
77 | return path; |
|
77 | return path; | |
78 | } |
|
78 | } | |
79 |
|
79 | |||
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |
81 | : QDeclarativeView(parent) |
|
81 | : QDeclarativeView(parent) | |
82 | , d(new QmlApplicationViewerPrivate()) |
|
82 | , d(new QmlApplicationViewerPrivate()) | |
83 | { |
|
83 | { | |
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
86 |
|
86 | |||
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
89 | #if !defined(NO_JSDEBUGGER) |
|
89 | #if !defined(NO_JSDEBUGGER) | |
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); |
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
91 | #endif |
|
91 | #endif | |
92 | #if !defined(NO_QMLOBSERVER) |
|
92 | #if !defined(NO_QMLOBSERVER) | |
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); |
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
94 | #endif |
|
94 | #endif | |
95 | #endif |
|
95 | #endif | |
96 | addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); |
|
|||
97 | } |
|
96 | } | |
98 |
|
97 | |||
99 | QmlApplicationViewer::~QmlApplicationViewer() |
|
98 | QmlApplicationViewer::~QmlApplicationViewer() | |
100 | { |
|
99 | { | |
101 | delete d; |
|
100 | delete d; | |
102 | } |
|
101 | } | |
103 |
|
102 | |||
104 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
103 | QmlApplicationViewer *QmlApplicationViewer::create() | |
105 | { |
|
104 | { | |
106 | return new QmlApplicationViewer(); |
|
105 | return new QmlApplicationViewer(); | |
107 | } |
|
106 | } | |
108 |
|
107 | |||
109 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
110 | { |
|
109 | { | |
111 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); |
|
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
112 | #ifdef Q_OS_ANDROID |
|
111 | #ifdef Q_OS_ANDROID | |
113 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
114 | #else |
|
113 | #else | |
115 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
116 | #endif |
|
115 | #endif | |
117 | } |
|
116 | } | |
118 |
|
117 | |||
119 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
118 | void QmlApplicationViewer::addImportPath(const QString &path) | |
120 | { |
|
119 | { | |
121 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); |
|
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
122 | } |
|
121 | } | |
123 |
|
122 | |||
124 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
125 | { |
|
124 | { | |
126 | #if QT_VERSION < 0x050000 |
|
125 | #if QT_VERSION < 0x050000 | |
127 | Qt::WidgetAttribute attribute; |
|
126 | Qt::WidgetAttribute attribute; | |
128 | switch (orientation) { |
|
127 | switch (orientation) { | |
129 | #if QT_VERSION < 0x040702 |
|
128 | #if QT_VERSION < 0x040702 | |
130 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
131 | case ScreenOrientationLockPortrait: |
|
130 | case ScreenOrientationLockPortrait: | |
132 | attribute = static_cast<Qt::WidgetAttribute>(128); |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
133 | break; |
|
132 | break; | |
134 | case ScreenOrientationLockLandscape: |
|
133 | case ScreenOrientationLockLandscape: | |
135 | attribute = static_cast<Qt::WidgetAttribute>(129); |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
136 | break; |
|
135 | break; | |
137 | default: |
|
136 | default: | |
138 | case ScreenOrientationAuto: |
|
137 | case ScreenOrientationAuto: | |
139 | attribute = static_cast<Qt::WidgetAttribute>(130); |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
140 | break; |
|
139 | break; | |
141 | #else // QT_VERSION < 0x040702 |
|
140 | #else // QT_VERSION < 0x040702 | |
142 | case ScreenOrientationLockPortrait: |
|
141 | case ScreenOrientationLockPortrait: | |
143 | attribute = Qt::WA_LockPortraitOrientation; |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
144 | break; |
|
143 | break; | |
145 | case ScreenOrientationLockLandscape: |
|
144 | case ScreenOrientationLockLandscape: | |
146 | attribute = Qt::WA_LockLandscapeOrientation; |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
147 | break; |
|
146 | break; | |
148 | default: |
|
147 | default: | |
149 | case ScreenOrientationAuto: |
|
148 | case ScreenOrientationAuto: | |
150 | attribute = Qt::WA_AutoOrientation; |
|
149 | attribute = Qt::WA_AutoOrientation; | |
151 | break; |
|
150 | break; | |
152 | #endif // QT_VERSION < 0x040702 |
|
151 | #endif // QT_VERSION < 0x040702 | |
153 | }; |
|
152 | }; | |
154 | setAttribute(attribute, true); |
|
153 | setAttribute(attribute, true); | |
155 | #else // QT_VERSION < 0x050000 |
|
154 | #else // QT_VERSION < 0x050000 | |
156 | Q_UNUSED(orientation) |
|
155 | Q_UNUSED(orientation) | |
157 | #endif // QT_VERSION < 0x050000 |
|
156 | #endif // QT_VERSION < 0x050000 | |
158 | } |
|
157 | } | |
159 |
|
158 | |||
160 | void QmlApplicationViewer::showExpanded() |
|
159 | void QmlApplicationViewer::showExpanded() | |
161 | { |
|
160 | { | |
162 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
163 | showFullScreen(); |
|
162 | showFullScreen(); | |
164 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
165 | showMaximized(); |
|
164 | showMaximized(); | |
166 | #else |
|
165 | #else | |
167 | show(); |
|
166 | show(); | |
168 | #endif |
|
167 | #endif | |
169 | } |
|
168 | } | |
170 |
|
169 | |||
171 | QApplication *createApplication(int &argc, char **argv) |
|
170 | QApplication *createApplication(int &argc, char **argv) | |
172 | { |
|
171 | { | |
173 | #ifdef HARMATTAN_BOOSTER |
|
172 | #ifdef HARMATTAN_BOOSTER | |
174 | return MDeclarativeCache::qApplication(argc, argv); |
|
173 | return MDeclarativeCache::qApplication(argc, argv); | |
175 | #else |
|
174 | #else | |
176 | return new QApplication(argc, argv); |
|
175 | return new QApplication(argc, argv); | |
177 | #endif |
|
176 | #endif | |
178 | } |
|
177 | } |
@@ -1,36 +1,37 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QApplication> |
|
21 | #include <QApplication> | |
22 | #include <QtDeclarative/QDeclarativeEngine> |
|
22 | #include <QtDeclarative/QDeclarativeEngine> | |
23 | #include "qmlapplicationviewer.h" |
|
23 | #include "qmlapplicationviewer.h" | |
24 |
|
24 | |||
25 | Q_DECL_EXPORT int main(int argc, char *argv[]) |
|
25 | Q_DECL_EXPORT int main(int argc, char *argv[]) | |
26 | { |
|
26 | { | |
27 | QScopedPointer<QApplication> app(createApplication(argc, argv)); |
|
27 | QScopedPointer<QApplication> app(createApplication(argc, argv)); | |
28 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); |
|
28 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); | |
|
29 | viewer->addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); | |||
29 |
|
30 | |||
30 | // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); |
|
31 | // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); | |
31 | viewer->setSource(QUrl("qrc:/qml/qmlchart/loader.qml")); |
|
32 | viewer->setSource(QUrl("qrc:/qml/qmlchart/loader.qml")); | |
32 | viewer->setRenderHint(QPainter::Antialiasing, true); |
|
33 | viewer->setRenderHint(QPainter::Antialiasing, true); | |
33 | viewer->showExpanded(); |
|
34 | viewer->showExpanded(); | |
34 |
|
35 | |||
35 | return app->exec(); |
|
36 | return app->exec(); | |
36 | } |
|
37 | } |
@@ -1,178 +1,177 | |||||
1 | // checksum 0xbd34 version 0x80016 |
|
1 | // checksum 0xbd34 version 0x80016 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #include "qmlapplicationviewer.h" |
|
11 | #include "qmlapplicationviewer.h" | |
12 |
|
12 | |||
13 | #include <QDir> |
|
13 | #include <QDir> | |
14 | #include <QFileInfo> |
|
14 | #include <QFileInfo> | |
15 | #include <QApplication> |
|
15 | #include <QApplication> | |
16 | #include <QDeclarativeComponent> |
|
16 | #include <QDeclarativeComponent> | |
17 | #include <QDeclarativeEngine> |
|
17 | #include <QDeclarativeEngine> | |
18 | #include <QDeclarativeContext> |
|
18 | #include <QDeclarativeContext> | |
19 |
|
19 | |||
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |
21 |
|
21 | |||
22 | #ifdef HARMATTAN_BOOSTER |
|
22 | #ifdef HARMATTAN_BOOSTER | |
23 | #include <MDeclarativeCache> |
|
23 | #include <MDeclarativeCache> | |
24 | #endif |
|
24 | #endif | |
25 |
|
25 | |||
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
27 |
|
27 | |||
28 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |
29 |
|
29 | |||
30 | #if !defined(NO_JSDEBUGGER) |
|
30 | #if !defined(NO_JSDEBUGGER) | |
31 | #include <jsdebuggeragent.h> |
|
31 | #include <jsdebuggeragent.h> | |
32 | #endif |
|
32 | #endif | |
33 | #if !defined(NO_QMLOBSERVER) |
|
33 | #if !defined(NO_QMLOBSERVER) | |
34 | #include <qdeclarativeviewobserver.h> |
|
34 | #include <qdeclarativeviewobserver.h> | |
35 | #endif |
|
35 | #endif | |
36 |
|
36 | |||
37 | // Enable debugging before any QDeclarativeEngine is created |
|
37 | // Enable debugging before any QDeclarativeEngine is created | |
38 | struct QmlJsDebuggingEnabler |
|
38 | struct QmlJsDebuggingEnabler | |
39 | { |
|
39 | { | |
40 | QmlJsDebuggingEnabler() |
|
40 | QmlJsDebuggingEnabler() | |
41 | { |
|
41 | { | |
42 | QDeclarativeDebugHelper::enableDebugging(); |
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |
43 | } |
|
43 | } | |
44 | }; |
|
44 | }; | |
45 |
|
45 | |||
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |
48 |
|
48 | |||
49 | #endif // QMLJSDEBUGGER |
|
49 | #endif // QMLJSDEBUGGER | |
50 |
|
50 | |||
51 | class QmlApplicationViewerPrivate |
|
51 | class QmlApplicationViewerPrivate | |
52 | { |
|
52 | { | |
53 | QString mainQmlFile; |
|
53 | QString mainQmlFile; | |
54 | friend class QmlApplicationViewer; |
|
54 | friend class QmlApplicationViewer; | |
55 | static QString adjustPath(const QString &path); |
|
55 | static QString adjustPath(const QString &path); | |
56 | }; |
|
56 | }; | |
57 |
|
57 | |||
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |
59 | { |
|
59 | { | |
60 | #ifdef Q_OS_MAC |
|
60 | #ifdef Q_OS_MAC | |
61 | if (!QDir::isAbsolutePath(path)) |
|
61 | if (!QDir::isAbsolutePath(path)) | |
62 | return QString::fromLatin1("%1/../Resources/%2") |
|
62 | return QString::fromLatin1("%1/../Resources/%2") | |
63 | .arg(QCoreApplication::applicationDirPath(), path); |
|
63 | .arg(QCoreApplication::applicationDirPath(), path); | |
64 | #elif defined(Q_OS_QNX) |
|
64 | #elif defined(Q_OS_QNX) | |
65 | if (!QDir::isAbsolutePath(path)) |
|
65 | if (!QDir::isAbsolutePath(path)) | |
66 | return QString::fromLatin1("app/native/%1").arg(path); |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
67 | #elif !defined(Q_OS_ANDROID) |
|
67 | #elif !defined(Q_OS_ANDROID) | |
68 | QString pathInInstallDir = |
|
68 | QString pathInInstallDir = | |
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); |
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
70 | if (QFileInfo(pathInInstallDir).exists()) |
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |
71 | return pathInInstallDir; |
|
71 | return pathInInstallDir; | |
72 | pathInInstallDir = |
|
72 | pathInInstallDir = | |
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
74 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |
75 | return pathInInstallDir; |
|
75 | return pathInInstallDir; | |
76 | #endif |
|
76 | #endif | |
77 | return path; |
|
77 | return path; | |
78 | } |
|
78 | } | |
79 |
|
79 | |||
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |
81 | : QDeclarativeView(parent) |
|
81 | : QDeclarativeView(parent) | |
82 | , d(new QmlApplicationViewerPrivate()) |
|
82 | , d(new QmlApplicationViewerPrivate()) | |
83 | { |
|
83 | { | |
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
86 |
|
86 | |||
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
89 | #if !defined(NO_JSDEBUGGER) |
|
89 | #if !defined(NO_JSDEBUGGER) | |
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); |
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
91 | #endif |
|
91 | #endif | |
92 | #if !defined(NO_QMLOBSERVER) |
|
92 | #if !defined(NO_QMLOBSERVER) | |
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); |
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
94 | #endif |
|
94 | #endif | |
95 | #endif |
|
95 | #endif | |
96 | addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); |
|
|||
97 | } |
|
96 | } | |
98 |
|
97 | |||
99 | QmlApplicationViewer::~QmlApplicationViewer() |
|
98 | QmlApplicationViewer::~QmlApplicationViewer() | |
100 | { |
|
99 | { | |
101 | delete d; |
|
100 | delete d; | |
102 | } |
|
101 | } | |
103 |
|
102 | |||
104 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
103 | QmlApplicationViewer *QmlApplicationViewer::create() | |
105 | { |
|
104 | { | |
106 | return new QmlApplicationViewer(); |
|
105 | return new QmlApplicationViewer(); | |
107 | } |
|
106 | } | |
108 |
|
107 | |||
109 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
110 | { |
|
109 | { | |
111 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); |
|
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
112 | #ifdef Q_OS_ANDROID |
|
111 | #ifdef Q_OS_ANDROID | |
113 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
114 | #else |
|
113 | #else | |
115 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
116 | #endif |
|
115 | #endif | |
117 | } |
|
116 | } | |
118 |
|
117 | |||
119 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
118 | void QmlApplicationViewer::addImportPath(const QString &path) | |
120 | { |
|
119 | { | |
121 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); |
|
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
122 | } |
|
121 | } | |
123 |
|
122 | |||
124 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
125 | { |
|
124 | { | |
126 | #if QT_VERSION < 0x050000 |
|
125 | #if QT_VERSION < 0x050000 | |
127 | Qt::WidgetAttribute attribute; |
|
126 | Qt::WidgetAttribute attribute; | |
128 | switch (orientation) { |
|
127 | switch (orientation) { | |
129 | #if QT_VERSION < 0x040702 |
|
128 | #if QT_VERSION < 0x040702 | |
130 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
131 | case ScreenOrientationLockPortrait: |
|
130 | case ScreenOrientationLockPortrait: | |
132 | attribute = static_cast<Qt::WidgetAttribute>(128); |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
133 | break; |
|
132 | break; | |
134 | case ScreenOrientationLockLandscape: |
|
133 | case ScreenOrientationLockLandscape: | |
135 | attribute = static_cast<Qt::WidgetAttribute>(129); |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
136 | break; |
|
135 | break; | |
137 | default: |
|
136 | default: | |
138 | case ScreenOrientationAuto: |
|
137 | case ScreenOrientationAuto: | |
139 | attribute = static_cast<Qt::WidgetAttribute>(130); |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
140 | break; |
|
139 | break; | |
141 | #else // QT_VERSION < 0x040702 |
|
140 | #else // QT_VERSION < 0x040702 | |
142 | case ScreenOrientationLockPortrait: |
|
141 | case ScreenOrientationLockPortrait: | |
143 | attribute = Qt::WA_LockPortraitOrientation; |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
144 | break; |
|
143 | break; | |
145 | case ScreenOrientationLockLandscape: |
|
144 | case ScreenOrientationLockLandscape: | |
146 | attribute = Qt::WA_LockLandscapeOrientation; |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
147 | break; |
|
146 | break; | |
148 | default: |
|
147 | default: | |
149 | case ScreenOrientationAuto: |
|
148 | case ScreenOrientationAuto: | |
150 | attribute = Qt::WA_AutoOrientation; |
|
149 | attribute = Qt::WA_AutoOrientation; | |
151 | break; |
|
150 | break; | |
152 | #endif // QT_VERSION < 0x040702 |
|
151 | #endif // QT_VERSION < 0x040702 | |
153 | }; |
|
152 | }; | |
154 | setAttribute(attribute, true); |
|
153 | setAttribute(attribute, true); | |
155 | #else // QT_VERSION < 0x050000 |
|
154 | #else // QT_VERSION < 0x050000 | |
156 | Q_UNUSED(orientation) |
|
155 | Q_UNUSED(orientation) | |
157 | #endif // QT_VERSION < 0x050000 |
|
156 | #endif // QT_VERSION < 0x050000 | |
158 | } |
|
157 | } | |
159 |
|
158 | |||
160 | void QmlApplicationViewer::showExpanded() |
|
159 | void QmlApplicationViewer::showExpanded() | |
161 | { |
|
160 | { | |
162 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
163 | showFullScreen(); |
|
162 | showFullScreen(); | |
164 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
165 | showMaximized(); |
|
164 | showMaximized(); | |
166 | #else |
|
165 | #else | |
167 | show(); |
|
166 | show(); | |
168 | #endif |
|
167 | #endif | |
169 | } |
|
168 | } | |
170 |
|
169 | |||
171 | QApplication *createApplication(int &argc, char **argv) |
|
170 | QApplication *createApplication(int &argc, char **argv) | |
172 | { |
|
171 | { | |
173 | #ifdef HARMATTAN_BOOSTER |
|
172 | #ifdef HARMATTAN_BOOSTER | |
174 | return MDeclarativeCache::qApplication(argc, argv); |
|
173 | return MDeclarativeCache::qApplication(argc, argv); | |
175 | #else |
|
174 | #else | |
176 | return new QApplication(argc, argv); |
|
175 | return new QApplication(argc, argv); | |
177 | #endif |
|
176 | #endif | |
178 | } |
|
177 | } |
@@ -1,36 +1,37 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QApplication> |
|
21 | #include <QApplication> | |
22 | #include <QtDeclarative/QDeclarativeEngine> |
|
22 | #include <QtDeclarative/QDeclarativeEngine> | |
23 | #include "qmlapplicationviewer.h" |
|
23 | #include "qmlapplicationviewer.h" | |
24 |
|
24 | |||
25 | Q_DECL_EXPORT int main(int argc, char *argv[]) |
|
25 | Q_DECL_EXPORT int main(int argc, char *argv[]) | |
26 | { |
|
26 | { | |
27 | QScopedPointer<QApplication> app(createApplication(argc, argv)); |
|
27 | QScopedPointer<QApplication> app(createApplication(argc, argv)); | |
28 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); |
|
28 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); | |
|
29 | viewer->addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); | |||
29 |
|
30 | |||
30 | // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); |
|
31 | // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); | |
31 | viewer->setSource(QUrl("qrc:/qml/qmlcustomizations/loader.qml")); |
|
32 | viewer->setSource(QUrl("qrc:/qml/qmlcustomizations/loader.qml")); | |
32 | viewer->setRenderHint(QPainter::Antialiasing, true); |
|
33 | viewer->setRenderHint(QPainter::Antialiasing, true); | |
33 | viewer->showExpanded(); |
|
34 | viewer->showExpanded(); | |
34 |
|
35 | |||
35 | return app->exec(); |
|
36 | return app->exec(); | |
36 | } |
|
37 | } |
@@ -1,178 +1,177 | |||||
1 | // checksum 0xbd34 version 0x80016 |
|
1 | // checksum 0xbd34 version 0x80016 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #include "qmlapplicationviewer.h" |
|
11 | #include "qmlapplicationviewer.h" | |
12 |
|
12 | |||
13 | #include <QDir> |
|
13 | #include <QDir> | |
14 | #include <QFileInfo> |
|
14 | #include <QFileInfo> | |
15 | #include <QApplication> |
|
15 | #include <QApplication> | |
16 | #include <QDeclarativeComponent> |
|
16 | #include <QDeclarativeComponent> | |
17 | #include <QDeclarativeEngine> |
|
17 | #include <QDeclarativeEngine> | |
18 | #include <QDeclarativeContext> |
|
18 | #include <QDeclarativeContext> | |
19 |
|
19 | |||
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |
21 |
|
21 | |||
22 | #ifdef HARMATTAN_BOOSTER |
|
22 | #ifdef HARMATTAN_BOOSTER | |
23 | #include <MDeclarativeCache> |
|
23 | #include <MDeclarativeCache> | |
24 | #endif |
|
24 | #endif | |
25 |
|
25 | |||
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
27 |
|
27 | |||
28 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |
29 |
|
29 | |||
30 | #if !defined(NO_JSDEBUGGER) |
|
30 | #if !defined(NO_JSDEBUGGER) | |
31 | #include <jsdebuggeragent.h> |
|
31 | #include <jsdebuggeragent.h> | |
32 | #endif |
|
32 | #endif | |
33 | #if !defined(NO_QMLOBSERVER) |
|
33 | #if !defined(NO_QMLOBSERVER) | |
34 | #include <qdeclarativeviewobserver.h> |
|
34 | #include <qdeclarativeviewobserver.h> | |
35 | #endif |
|
35 | #endif | |
36 |
|
36 | |||
37 | // Enable debugging before any QDeclarativeEngine is created |
|
37 | // Enable debugging before any QDeclarativeEngine is created | |
38 | struct QmlJsDebuggingEnabler |
|
38 | struct QmlJsDebuggingEnabler | |
39 | { |
|
39 | { | |
40 | QmlJsDebuggingEnabler() |
|
40 | QmlJsDebuggingEnabler() | |
41 | { |
|
41 | { | |
42 | QDeclarativeDebugHelper::enableDebugging(); |
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |
43 | } |
|
43 | } | |
44 | }; |
|
44 | }; | |
45 |
|
45 | |||
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |
48 |
|
48 | |||
49 | #endif // QMLJSDEBUGGER |
|
49 | #endif // QMLJSDEBUGGER | |
50 |
|
50 | |||
51 | class QmlApplicationViewerPrivate |
|
51 | class QmlApplicationViewerPrivate | |
52 | { |
|
52 | { | |
53 | QString mainQmlFile; |
|
53 | QString mainQmlFile; | |
54 | friend class QmlApplicationViewer; |
|
54 | friend class QmlApplicationViewer; | |
55 | static QString adjustPath(const QString &path); |
|
55 | static QString adjustPath(const QString &path); | |
56 | }; |
|
56 | }; | |
57 |
|
57 | |||
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |
59 | { |
|
59 | { | |
60 | #ifdef Q_OS_MAC |
|
60 | #ifdef Q_OS_MAC | |
61 | if (!QDir::isAbsolutePath(path)) |
|
61 | if (!QDir::isAbsolutePath(path)) | |
62 | return QString::fromLatin1("%1/../Resources/%2") |
|
62 | return QString::fromLatin1("%1/../Resources/%2") | |
63 | .arg(QCoreApplication::applicationDirPath(), path); |
|
63 | .arg(QCoreApplication::applicationDirPath(), path); | |
64 | #elif defined(Q_OS_QNX) |
|
64 | #elif defined(Q_OS_QNX) | |
65 | if (!QDir::isAbsolutePath(path)) |
|
65 | if (!QDir::isAbsolutePath(path)) | |
66 | return QString::fromLatin1("app/native/%1").arg(path); |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
67 | #elif !defined(Q_OS_ANDROID) |
|
67 | #elif !defined(Q_OS_ANDROID) | |
68 | QString pathInInstallDir = |
|
68 | QString pathInInstallDir = | |
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); |
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
70 | if (QFileInfo(pathInInstallDir).exists()) |
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |
71 | return pathInInstallDir; |
|
71 | return pathInInstallDir; | |
72 | pathInInstallDir = |
|
72 | pathInInstallDir = | |
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
74 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |
75 | return pathInInstallDir; |
|
75 | return pathInInstallDir; | |
76 | #endif |
|
76 | #endif | |
77 | return path; |
|
77 | return path; | |
78 | } |
|
78 | } | |
79 |
|
79 | |||
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |
81 | : QDeclarativeView(parent) |
|
81 | : QDeclarativeView(parent) | |
82 | , d(new QmlApplicationViewerPrivate()) |
|
82 | , d(new QmlApplicationViewerPrivate()) | |
83 | { |
|
83 | { | |
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
86 |
|
86 | |||
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
89 | #if !defined(NO_JSDEBUGGER) |
|
89 | #if !defined(NO_JSDEBUGGER) | |
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); |
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
91 | #endif |
|
91 | #endif | |
92 | #if !defined(NO_QMLOBSERVER) |
|
92 | #if !defined(NO_QMLOBSERVER) | |
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); |
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
94 | #endif |
|
94 | #endif | |
95 | #endif |
|
95 | #endif | |
96 | addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); |
|
|||
97 | } |
|
96 | } | |
98 |
|
97 | |||
99 | QmlApplicationViewer::~QmlApplicationViewer() |
|
98 | QmlApplicationViewer::~QmlApplicationViewer() | |
100 | { |
|
99 | { | |
101 | delete d; |
|
100 | delete d; | |
102 | } |
|
101 | } | |
103 |
|
102 | |||
104 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
103 | QmlApplicationViewer *QmlApplicationViewer::create() | |
105 | { |
|
104 | { | |
106 | return new QmlApplicationViewer(); |
|
105 | return new QmlApplicationViewer(); | |
107 | } |
|
106 | } | |
108 |
|
107 | |||
109 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
110 | { |
|
109 | { | |
111 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); |
|
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
112 | #ifdef Q_OS_ANDROID |
|
111 | #ifdef Q_OS_ANDROID | |
113 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
114 | #else |
|
113 | #else | |
115 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
116 | #endif |
|
115 | #endif | |
117 | } |
|
116 | } | |
118 |
|
117 | |||
119 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
118 | void QmlApplicationViewer::addImportPath(const QString &path) | |
120 | { |
|
119 | { | |
121 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); |
|
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
122 | } |
|
121 | } | |
123 |
|
122 | |||
124 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
125 | { |
|
124 | { | |
126 | #if QT_VERSION < 0x050000 |
|
125 | #if QT_VERSION < 0x050000 | |
127 | Qt::WidgetAttribute attribute; |
|
126 | Qt::WidgetAttribute attribute; | |
128 | switch (orientation) { |
|
127 | switch (orientation) { | |
129 | #if QT_VERSION < 0x040702 |
|
128 | #if QT_VERSION < 0x040702 | |
130 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
131 | case ScreenOrientationLockPortrait: |
|
130 | case ScreenOrientationLockPortrait: | |
132 | attribute = static_cast<Qt::WidgetAttribute>(128); |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
133 | break; |
|
132 | break; | |
134 | case ScreenOrientationLockLandscape: |
|
133 | case ScreenOrientationLockLandscape: | |
135 | attribute = static_cast<Qt::WidgetAttribute>(129); |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
136 | break; |
|
135 | break; | |
137 | default: |
|
136 | default: | |
138 | case ScreenOrientationAuto: |
|
137 | case ScreenOrientationAuto: | |
139 | attribute = static_cast<Qt::WidgetAttribute>(130); |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
140 | break; |
|
139 | break; | |
141 | #else // QT_VERSION < 0x040702 |
|
140 | #else // QT_VERSION < 0x040702 | |
142 | case ScreenOrientationLockPortrait: |
|
141 | case ScreenOrientationLockPortrait: | |
143 | attribute = Qt::WA_LockPortraitOrientation; |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
144 | break; |
|
143 | break; | |
145 | case ScreenOrientationLockLandscape: |
|
144 | case ScreenOrientationLockLandscape: | |
146 | attribute = Qt::WA_LockLandscapeOrientation; |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
147 | break; |
|
146 | break; | |
148 | default: |
|
147 | default: | |
149 | case ScreenOrientationAuto: |
|
148 | case ScreenOrientationAuto: | |
150 | attribute = Qt::WA_AutoOrientation; |
|
149 | attribute = Qt::WA_AutoOrientation; | |
151 | break; |
|
150 | break; | |
152 | #endif // QT_VERSION < 0x040702 |
|
151 | #endif // QT_VERSION < 0x040702 | |
153 | }; |
|
152 | }; | |
154 | setAttribute(attribute, true); |
|
153 | setAttribute(attribute, true); | |
155 | #else // QT_VERSION < 0x050000 |
|
154 | #else // QT_VERSION < 0x050000 | |
156 | Q_UNUSED(orientation) |
|
155 | Q_UNUSED(orientation) | |
157 | #endif // QT_VERSION < 0x050000 |
|
156 | #endif // QT_VERSION < 0x050000 | |
158 | } |
|
157 | } | |
159 |
|
158 | |||
160 | void QmlApplicationViewer::showExpanded() |
|
159 | void QmlApplicationViewer::showExpanded() | |
161 | { |
|
160 | { | |
162 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
163 | showFullScreen(); |
|
162 | showFullScreen(); | |
164 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
165 | showMaximized(); |
|
164 | showMaximized(); | |
166 | #else |
|
165 | #else | |
167 | show(); |
|
166 | show(); | |
168 | #endif |
|
167 | #endif | |
169 | } |
|
168 | } | |
170 |
|
169 | |||
171 | QApplication *createApplication(int &argc, char **argv) |
|
170 | QApplication *createApplication(int &argc, char **argv) | |
172 | { |
|
171 | { | |
173 | #ifdef HARMATTAN_BOOSTER |
|
172 | #ifdef HARMATTAN_BOOSTER | |
174 | return MDeclarativeCache::qApplication(argc, argv); |
|
173 | return MDeclarativeCache::qApplication(argc, argv); | |
175 | #else |
|
174 | #else | |
176 | return new QApplication(argc, argv); |
|
175 | return new QApplication(argc, argv); | |
177 | #endif |
|
176 | #endif | |
178 | } |
|
177 | } |
@@ -1,36 +1,37 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QApplication> |
|
21 | #include <QApplication> | |
22 | #include <QtDeclarative/QDeclarativeEngine> |
|
22 | #include <QtDeclarative/QDeclarativeEngine> | |
23 | #include "qmlapplicationviewer.h" |
|
23 | #include "qmlapplicationviewer.h" | |
24 |
|
24 | |||
25 | Q_DECL_EXPORT int main(int argc, char *argv[]) |
|
25 | Q_DECL_EXPORT int main(int argc, char *argv[]) | |
26 | { |
|
26 | { | |
27 | QScopedPointer<QApplication> app(createApplication(argc, argv)); |
|
27 | QScopedPointer<QApplication> app(createApplication(argc, argv)); | |
28 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); |
|
28 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); | |
|
29 | viewer->addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); | |||
29 |
|
30 | |||
30 | //viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); |
|
31 | //viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); | |
31 | viewer->setSource(QUrl("qrc:/qml/qmlcustomlegend/loader.qml")); |
|
32 | viewer->setSource(QUrl("qrc:/qml/qmlcustomlegend/loader.qml")); | |
32 | viewer->setRenderHint(QPainter::Antialiasing, true); |
|
33 | viewer->setRenderHint(QPainter::Antialiasing, true); | |
33 | viewer->showExpanded(); |
|
34 | viewer->showExpanded(); | |
34 |
|
35 | |||
35 | return app->exec(); |
|
36 | return app->exec(); | |
36 | } |
|
37 | } |
@@ -1,178 +1,177 | |||||
1 | // checksum 0xbd34 version 0x80016 |
|
1 | // checksum 0xbd34 version 0x80016 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #include "qmlapplicationviewer.h" |
|
11 | #include "qmlapplicationviewer.h" | |
12 |
|
12 | |||
13 | #include <QDir> |
|
13 | #include <QDir> | |
14 | #include <QFileInfo> |
|
14 | #include <QFileInfo> | |
15 | #include <QApplication> |
|
15 | #include <QApplication> | |
16 | #include <QDeclarativeComponent> |
|
16 | #include <QDeclarativeComponent> | |
17 | #include <QDeclarativeEngine> |
|
17 | #include <QDeclarativeEngine> | |
18 | #include <QDeclarativeContext> |
|
18 | #include <QDeclarativeContext> | |
19 |
|
19 | |||
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |
21 |
|
21 | |||
22 | #ifdef HARMATTAN_BOOSTER |
|
22 | #ifdef HARMATTAN_BOOSTER | |
23 | #include <MDeclarativeCache> |
|
23 | #include <MDeclarativeCache> | |
24 | #endif |
|
24 | #endif | |
25 |
|
25 | |||
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
27 |
|
27 | |||
28 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |
29 |
|
29 | |||
30 | #if !defined(NO_JSDEBUGGER) |
|
30 | #if !defined(NO_JSDEBUGGER) | |
31 | #include <jsdebuggeragent.h> |
|
31 | #include <jsdebuggeragent.h> | |
32 | #endif |
|
32 | #endif | |
33 | #if !defined(NO_QMLOBSERVER) |
|
33 | #if !defined(NO_QMLOBSERVER) | |
34 | #include <qdeclarativeviewobserver.h> |
|
34 | #include <qdeclarativeviewobserver.h> | |
35 | #endif |
|
35 | #endif | |
36 |
|
36 | |||
37 | // Enable debugging before any QDeclarativeEngine is created |
|
37 | // Enable debugging before any QDeclarativeEngine is created | |
38 | struct QmlJsDebuggingEnabler |
|
38 | struct QmlJsDebuggingEnabler | |
39 | { |
|
39 | { | |
40 | QmlJsDebuggingEnabler() |
|
40 | QmlJsDebuggingEnabler() | |
41 | { |
|
41 | { | |
42 | QDeclarativeDebugHelper::enableDebugging(); |
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |
43 | } |
|
43 | } | |
44 | }; |
|
44 | }; | |
45 |
|
45 | |||
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |
48 |
|
48 | |||
49 | #endif // QMLJSDEBUGGER |
|
49 | #endif // QMLJSDEBUGGER | |
50 |
|
50 | |||
51 | class QmlApplicationViewerPrivate |
|
51 | class QmlApplicationViewerPrivate | |
52 | { |
|
52 | { | |
53 | QString mainQmlFile; |
|
53 | QString mainQmlFile; | |
54 | friend class QmlApplicationViewer; |
|
54 | friend class QmlApplicationViewer; | |
55 | static QString adjustPath(const QString &path); |
|
55 | static QString adjustPath(const QString &path); | |
56 | }; |
|
56 | }; | |
57 |
|
57 | |||
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |
59 | { |
|
59 | { | |
60 | #ifdef Q_OS_MAC |
|
60 | #ifdef Q_OS_MAC | |
61 | if (!QDir::isAbsolutePath(path)) |
|
61 | if (!QDir::isAbsolutePath(path)) | |
62 | return QString::fromLatin1("%1/../Resources/%2") |
|
62 | return QString::fromLatin1("%1/../Resources/%2") | |
63 | .arg(QCoreApplication::applicationDirPath(), path); |
|
63 | .arg(QCoreApplication::applicationDirPath(), path); | |
64 | #elif defined(Q_OS_QNX) |
|
64 | #elif defined(Q_OS_QNX) | |
65 | if (!QDir::isAbsolutePath(path)) |
|
65 | if (!QDir::isAbsolutePath(path)) | |
66 | return QString::fromLatin1("app/native/%1").arg(path); |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
67 | #elif !defined(Q_OS_ANDROID) |
|
67 | #elif !defined(Q_OS_ANDROID) | |
68 | QString pathInInstallDir = |
|
68 | QString pathInInstallDir = | |
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); |
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
70 | if (QFileInfo(pathInInstallDir).exists()) |
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |
71 | return pathInInstallDir; |
|
71 | return pathInInstallDir; | |
72 | pathInInstallDir = |
|
72 | pathInInstallDir = | |
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
74 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |
75 | return pathInInstallDir; |
|
75 | return pathInInstallDir; | |
76 | #endif |
|
76 | #endif | |
77 | return path; |
|
77 | return path; | |
78 | } |
|
78 | } | |
79 |
|
79 | |||
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |
81 | : QDeclarativeView(parent) |
|
81 | : QDeclarativeView(parent) | |
82 | , d(new QmlApplicationViewerPrivate()) |
|
82 | , d(new QmlApplicationViewerPrivate()) | |
83 | { |
|
83 | { | |
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
86 |
|
86 | |||
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
89 | #if !defined(NO_JSDEBUGGER) |
|
89 | #if !defined(NO_JSDEBUGGER) | |
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); |
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
91 | #endif |
|
91 | #endif | |
92 | #if !defined(NO_QMLOBSERVER) |
|
92 | #if !defined(NO_QMLOBSERVER) | |
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); |
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
94 | #endif |
|
94 | #endif | |
95 | #endif |
|
95 | #endif | |
96 | addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); |
|
|||
97 | } |
|
96 | } | |
98 |
|
97 | |||
99 | QmlApplicationViewer::~QmlApplicationViewer() |
|
98 | QmlApplicationViewer::~QmlApplicationViewer() | |
100 | { |
|
99 | { | |
101 | delete d; |
|
100 | delete d; | |
102 | } |
|
101 | } | |
103 |
|
102 | |||
104 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
103 | QmlApplicationViewer *QmlApplicationViewer::create() | |
105 | { |
|
104 | { | |
106 | return new QmlApplicationViewer(); |
|
105 | return new QmlApplicationViewer(); | |
107 | } |
|
106 | } | |
108 |
|
107 | |||
109 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
110 | { |
|
109 | { | |
111 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); |
|
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
112 | #ifdef Q_OS_ANDROID |
|
111 | #ifdef Q_OS_ANDROID | |
113 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
114 | #else |
|
113 | #else | |
115 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
116 | #endif |
|
115 | #endif | |
117 | } |
|
116 | } | |
118 |
|
117 | |||
119 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
118 | void QmlApplicationViewer::addImportPath(const QString &path) | |
120 | { |
|
119 | { | |
121 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); |
|
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
122 | } |
|
121 | } | |
123 |
|
122 | |||
124 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
125 | { |
|
124 | { | |
126 | #if QT_VERSION < 0x050000 |
|
125 | #if QT_VERSION < 0x050000 | |
127 | Qt::WidgetAttribute attribute; |
|
126 | Qt::WidgetAttribute attribute; | |
128 | switch (orientation) { |
|
127 | switch (orientation) { | |
129 | #if QT_VERSION < 0x040702 |
|
128 | #if QT_VERSION < 0x040702 | |
130 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
131 | case ScreenOrientationLockPortrait: |
|
130 | case ScreenOrientationLockPortrait: | |
132 | attribute = static_cast<Qt::WidgetAttribute>(128); |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
133 | break; |
|
132 | break; | |
134 | case ScreenOrientationLockLandscape: |
|
133 | case ScreenOrientationLockLandscape: | |
135 | attribute = static_cast<Qt::WidgetAttribute>(129); |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
136 | break; |
|
135 | break; | |
137 | default: |
|
136 | default: | |
138 | case ScreenOrientationAuto: |
|
137 | case ScreenOrientationAuto: | |
139 | attribute = static_cast<Qt::WidgetAttribute>(130); |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
140 | break; |
|
139 | break; | |
141 | #else // QT_VERSION < 0x040702 |
|
140 | #else // QT_VERSION < 0x040702 | |
142 | case ScreenOrientationLockPortrait: |
|
141 | case ScreenOrientationLockPortrait: | |
143 | attribute = Qt::WA_LockPortraitOrientation; |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
144 | break; |
|
143 | break; | |
145 | case ScreenOrientationLockLandscape: |
|
144 | case ScreenOrientationLockLandscape: | |
146 | attribute = Qt::WA_LockLandscapeOrientation; |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
147 | break; |
|
146 | break; | |
148 | default: |
|
147 | default: | |
149 | case ScreenOrientationAuto: |
|
148 | case ScreenOrientationAuto: | |
150 | attribute = Qt::WA_AutoOrientation; |
|
149 | attribute = Qt::WA_AutoOrientation; | |
151 | break; |
|
150 | break; | |
152 | #endif // QT_VERSION < 0x040702 |
|
151 | #endif // QT_VERSION < 0x040702 | |
153 | }; |
|
152 | }; | |
154 | setAttribute(attribute, true); |
|
153 | setAttribute(attribute, true); | |
155 | #else // QT_VERSION < 0x050000 |
|
154 | #else // QT_VERSION < 0x050000 | |
156 | Q_UNUSED(orientation) |
|
155 | Q_UNUSED(orientation) | |
157 | #endif // QT_VERSION < 0x050000 |
|
156 | #endif // QT_VERSION < 0x050000 | |
158 | } |
|
157 | } | |
159 |
|
158 | |||
160 | void QmlApplicationViewer::showExpanded() |
|
159 | void QmlApplicationViewer::showExpanded() | |
161 | { |
|
160 | { | |
162 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
163 | showFullScreen(); |
|
162 | showFullScreen(); | |
164 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
165 | showMaximized(); |
|
164 | showMaximized(); | |
166 | #else |
|
165 | #else | |
167 | show(); |
|
166 | show(); | |
168 | #endif |
|
167 | #endif | |
169 | } |
|
168 | } | |
170 |
|
169 | |||
171 | QApplication *createApplication(int &argc, char **argv) |
|
170 | QApplication *createApplication(int &argc, char **argv) | |
172 | { |
|
171 | { | |
173 | #ifdef HARMATTAN_BOOSTER |
|
172 | #ifdef HARMATTAN_BOOSTER | |
174 | return MDeclarativeCache::qApplication(argc, argv); |
|
173 | return MDeclarativeCache::qApplication(argc, argv); | |
175 | #else |
|
174 | #else | |
176 | return new QApplication(argc, argv); |
|
175 | return new QApplication(argc, argv); | |
177 | #endif |
|
176 | #endif | |
178 | } |
|
177 | } |
@@ -1,48 +1,49 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QApplication> |
|
21 | #include <QApplication> | |
22 | #include <QtDeclarative> |
|
22 | #include <QtDeclarative> | |
23 | #include <QtDeclarative/QDeclarativeEngine> |
|
23 | #include <QtDeclarative/QDeclarativeEngine> | |
24 | #include <QAbstractItemModel> |
|
24 | #include <QAbstractItemModel> | |
25 | #include "declarativemodel.h" |
|
25 | #include "declarativemodel.h" | |
26 | #include "customtablemodel.h" |
|
26 | #include "customtablemodel.h" | |
27 | #include "qmlapplicationviewer.h" |
|
27 | #include "qmlapplicationviewer.h" | |
28 |
|
28 | |||
29 | const char *uri = "QmlCustomModel"; |
|
29 | const char *uri = "QmlCustomModel"; | |
30 |
|
30 | |||
31 | Q_DECL_EXPORT int main(int argc, char *argv[]) |
|
31 | Q_DECL_EXPORT int main(int argc, char *argv[]) | |
32 | { |
|
32 | { | |
33 | QScopedPointer<QApplication> app(createApplication(argc, argv)); |
|
33 | QScopedPointer<QApplication> app(createApplication(argc, argv)); | |
34 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); |
|
34 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); | |
|
35 | viewer->addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); | |||
35 |
|
36 | |||
36 | // @uri QmlCustomModel |
|
37 | // @uri QmlCustomModel | |
37 | qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel", |
|
38 | qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel", | |
38 | QLatin1String("Trying to create uncreatable: AbstractItemModel.")); |
|
39 | QLatin1String("Trying to create uncreatable: AbstractItemModel.")); | |
39 | qmlRegisterType<DeclarativeTableModel>(uri, 1, 0, "CustomModel"); |
|
40 | qmlRegisterType<DeclarativeTableModel>(uri, 1, 0, "CustomModel"); | |
40 | qmlRegisterType<DeclarativeTableModelElement>(uri, 1, 0, "CustomModelElement"); |
|
41 | qmlRegisterType<DeclarativeTableModelElement>(uri, 1, 0, "CustomModelElement"); | |
41 |
|
42 | |||
42 | // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); |
|
43 | // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); | |
43 | viewer->setSource(QUrl("qrc:/qml/qmlcustommodel/loader.qml")); |
|
44 | viewer->setSource(QUrl("qrc:/qml/qmlcustommodel/loader.qml")); | |
44 | viewer->setRenderHint(QPainter::Antialiasing, true); |
|
45 | viewer->setRenderHint(QPainter::Antialiasing, true); | |
45 | viewer->showExpanded(); |
|
46 | viewer->showExpanded(); | |
46 |
|
47 | |||
47 | return app->exec(); |
|
48 | return app->exec(); | |
48 | } |
|
49 | } |
@@ -1,178 +1,177 | |||||
1 | // checksum 0xbd34 version 0x80016 |
|
1 | // checksum 0xbd34 version 0x80016 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #include "qmlapplicationviewer.h" |
|
11 | #include "qmlapplicationviewer.h" | |
12 |
|
12 | |||
13 | #include <QDir> |
|
13 | #include <QDir> | |
14 | #include <QFileInfo> |
|
14 | #include <QFileInfo> | |
15 | #include <QApplication> |
|
15 | #include <QApplication> | |
16 | #include <QDeclarativeComponent> |
|
16 | #include <QDeclarativeComponent> | |
17 | #include <QDeclarativeEngine> |
|
17 | #include <QDeclarativeEngine> | |
18 | #include <QDeclarativeContext> |
|
18 | #include <QDeclarativeContext> | |
19 |
|
19 | |||
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |
21 |
|
21 | |||
22 | #ifdef HARMATTAN_BOOSTER |
|
22 | #ifdef HARMATTAN_BOOSTER | |
23 | #include <MDeclarativeCache> |
|
23 | #include <MDeclarativeCache> | |
24 | #endif |
|
24 | #endif | |
25 |
|
25 | |||
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
27 |
|
27 | |||
28 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |
29 |
|
29 | |||
30 | #if !defined(NO_JSDEBUGGER) |
|
30 | #if !defined(NO_JSDEBUGGER) | |
31 | #include <jsdebuggeragent.h> |
|
31 | #include <jsdebuggeragent.h> | |
32 | #endif |
|
32 | #endif | |
33 | #if !defined(NO_QMLOBSERVER) |
|
33 | #if !defined(NO_QMLOBSERVER) | |
34 | #include <qdeclarativeviewobserver.h> |
|
34 | #include <qdeclarativeviewobserver.h> | |
35 | #endif |
|
35 | #endif | |
36 |
|
36 | |||
37 | // Enable debugging before any QDeclarativeEngine is created |
|
37 | // Enable debugging before any QDeclarativeEngine is created | |
38 | struct QmlJsDebuggingEnabler |
|
38 | struct QmlJsDebuggingEnabler | |
39 | { |
|
39 | { | |
40 | QmlJsDebuggingEnabler() |
|
40 | QmlJsDebuggingEnabler() | |
41 | { |
|
41 | { | |
42 | QDeclarativeDebugHelper::enableDebugging(); |
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |
43 | } |
|
43 | } | |
44 | }; |
|
44 | }; | |
45 |
|
45 | |||
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |
48 |
|
48 | |||
49 | #endif // QMLJSDEBUGGER |
|
49 | #endif // QMLJSDEBUGGER | |
50 |
|
50 | |||
51 | class QmlApplicationViewerPrivate |
|
51 | class QmlApplicationViewerPrivate | |
52 | { |
|
52 | { | |
53 | QString mainQmlFile; |
|
53 | QString mainQmlFile; | |
54 | friend class QmlApplicationViewer; |
|
54 | friend class QmlApplicationViewer; | |
55 | static QString adjustPath(const QString &path); |
|
55 | static QString adjustPath(const QString &path); | |
56 | }; |
|
56 | }; | |
57 |
|
57 | |||
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |
59 | { |
|
59 | { | |
60 | #ifdef Q_OS_MAC |
|
60 | #ifdef Q_OS_MAC | |
61 | if (!QDir::isAbsolutePath(path)) |
|
61 | if (!QDir::isAbsolutePath(path)) | |
62 | return QString::fromLatin1("%1/../Resources/%2") |
|
62 | return QString::fromLatin1("%1/../Resources/%2") | |
63 | .arg(QCoreApplication::applicationDirPath(), path); |
|
63 | .arg(QCoreApplication::applicationDirPath(), path); | |
64 | #elif defined(Q_OS_QNX) |
|
64 | #elif defined(Q_OS_QNX) | |
65 | if (!QDir::isAbsolutePath(path)) |
|
65 | if (!QDir::isAbsolutePath(path)) | |
66 | return QString::fromLatin1("app/native/%1").arg(path); |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
67 | #elif !defined(Q_OS_ANDROID) |
|
67 | #elif !defined(Q_OS_ANDROID) | |
68 | QString pathInInstallDir = |
|
68 | QString pathInInstallDir = | |
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); |
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
70 | if (QFileInfo(pathInInstallDir).exists()) |
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |
71 | return pathInInstallDir; |
|
71 | return pathInInstallDir; | |
72 | pathInInstallDir = |
|
72 | pathInInstallDir = | |
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
74 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |
75 | return pathInInstallDir; |
|
75 | return pathInInstallDir; | |
76 | #endif |
|
76 | #endif | |
77 | return path; |
|
77 | return path; | |
78 | } |
|
78 | } | |
79 |
|
79 | |||
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |
81 | : QDeclarativeView(parent) |
|
81 | : QDeclarativeView(parent) | |
82 | , d(new QmlApplicationViewerPrivate()) |
|
82 | , d(new QmlApplicationViewerPrivate()) | |
83 | { |
|
83 | { | |
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
86 |
|
86 | |||
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
89 | #if !defined(NO_JSDEBUGGER) |
|
89 | #if !defined(NO_JSDEBUGGER) | |
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); |
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
91 | #endif |
|
91 | #endif | |
92 | #if !defined(NO_QMLOBSERVER) |
|
92 | #if !defined(NO_QMLOBSERVER) | |
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); |
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
94 | #endif |
|
94 | #endif | |
95 | #endif |
|
95 | #endif | |
96 | addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); |
|
|||
97 | } |
|
96 | } | |
98 |
|
97 | |||
99 | QmlApplicationViewer::~QmlApplicationViewer() |
|
98 | QmlApplicationViewer::~QmlApplicationViewer() | |
100 | { |
|
99 | { | |
101 | delete d; |
|
100 | delete d; | |
102 | } |
|
101 | } | |
103 |
|
102 | |||
104 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
103 | QmlApplicationViewer *QmlApplicationViewer::create() | |
105 | { |
|
104 | { | |
106 | return new QmlApplicationViewer(); |
|
105 | return new QmlApplicationViewer(); | |
107 | } |
|
106 | } | |
108 |
|
107 | |||
109 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
110 | { |
|
109 | { | |
111 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); |
|
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
112 | #ifdef Q_OS_ANDROID |
|
111 | #ifdef Q_OS_ANDROID | |
113 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
114 | #else |
|
113 | #else | |
115 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
116 | #endif |
|
115 | #endif | |
117 | } |
|
116 | } | |
118 |
|
117 | |||
119 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
118 | void QmlApplicationViewer::addImportPath(const QString &path) | |
120 | { |
|
119 | { | |
121 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); |
|
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
122 | } |
|
121 | } | |
123 |
|
122 | |||
124 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
125 | { |
|
124 | { | |
126 | #if QT_VERSION < 0x050000 |
|
125 | #if QT_VERSION < 0x050000 | |
127 | Qt::WidgetAttribute attribute; |
|
126 | Qt::WidgetAttribute attribute; | |
128 | switch (orientation) { |
|
127 | switch (orientation) { | |
129 | #if QT_VERSION < 0x040702 |
|
128 | #if QT_VERSION < 0x040702 | |
130 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
131 | case ScreenOrientationLockPortrait: |
|
130 | case ScreenOrientationLockPortrait: | |
132 | attribute = static_cast<Qt::WidgetAttribute>(128); |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
133 | break; |
|
132 | break; | |
134 | case ScreenOrientationLockLandscape: |
|
133 | case ScreenOrientationLockLandscape: | |
135 | attribute = static_cast<Qt::WidgetAttribute>(129); |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
136 | break; |
|
135 | break; | |
137 | default: |
|
136 | default: | |
138 | case ScreenOrientationAuto: |
|
137 | case ScreenOrientationAuto: | |
139 | attribute = static_cast<Qt::WidgetAttribute>(130); |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
140 | break; |
|
139 | break; | |
141 | #else // QT_VERSION < 0x040702 |
|
140 | #else // QT_VERSION < 0x040702 | |
142 | case ScreenOrientationLockPortrait: |
|
141 | case ScreenOrientationLockPortrait: | |
143 | attribute = Qt::WA_LockPortraitOrientation; |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
144 | break; |
|
143 | break; | |
145 | case ScreenOrientationLockLandscape: |
|
144 | case ScreenOrientationLockLandscape: | |
146 | attribute = Qt::WA_LockLandscapeOrientation; |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
147 | break; |
|
146 | break; | |
148 | default: |
|
147 | default: | |
149 | case ScreenOrientationAuto: |
|
148 | case ScreenOrientationAuto: | |
150 | attribute = Qt::WA_AutoOrientation; |
|
149 | attribute = Qt::WA_AutoOrientation; | |
151 | break; |
|
150 | break; | |
152 | #endif // QT_VERSION < 0x040702 |
|
151 | #endif // QT_VERSION < 0x040702 | |
153 | }; |
|
152 | }; | |
154 | setAttribute(attribute, true); |
|
153 | setAttribute(attribute, true); | |
155 | #else // QT_VERSION < 0x050000 |
|
154 | #else // QT_VERSION < 0x050000 | |
156 | Q_UNUSED(orientation) |
|
155 | Q_UNUSED(orientation) | |
157 | #endif // QT_VERSION < 0x050000 |
|
156 | #endif // QT_VERSION < 0x050000 | |
158 | } |
|
157 | } | |
159 |
|
158 | |||
160 | void QmlApplicationViewer::showExpanded() |
|
159 | void QmlApplicationViewer::showExpanded() | |
161 | { |
|
160 | { | |
162 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
163 | showFullScreen(); |
|
162 | showFullScreen(); | |
164 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
165 | showMaximized(); |
|
164 | showMaximized(); | |
166 | #else |
|
165 | #else | |
167 | show(); |
|
166 | show(); | |
168 | #endif |
|
167 | #endif | |
169 | } |
|
168 | } | |
170 |
|
169 | |||
171 | QApplication *createApplication(int &argc, char **argv) |
|
170 | QApplication *createApplication(int &argc, char **argv) | |
172 | { |
|
171 | { | |
173 | #ifdef HARMATTAN_BOOSTER |
|
172 | #ifdef HARMATTAN_BOOSTER | |
174 | return MDeclarativeCache::qApplication(argc, argv); |
|
173 | return MDeclarativeCache::qApplication(argc, argv); | |
175 | #else |
|
174 | #else | |
176 | return new QApplication(argc, argv); |
|
175 | return new QApplication(argc, argv); | |
177 | #endif |
|
176 | #endif | |
178 | } |
|
177 | } |
@@ -1,36 +1,37 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QApplication> |
|
21 | #include <QApplication> | |
22 | //#include <QDeclarativeContext> |
|
22 | //#include <QDeclarativeContext> | |
23 | #include <QDebug> |
|
23 | #include <QDebug> | |
24 | #include "qmlapplicationviewer.h" |
|
24 | #include "qmlapplicationviewer.h" | |
25 |
|
25 | |||
26 | Q_DECL_EXPORT int main(int argc, char *argv[]) |
|
26 | Q_DECL_EXPORT int main(int argc, char *argv[]) | |
27 | { |
|
27 | { | |
28 | QScopedPointer<QApplication> app(createApplication(argc, argv)); |
|
28 | QScopedPointer<QApplication> app(createApplication(argc, argv)); | |
29 |
|
29 | |||
30 | QmlApplicationViewer viewer; |
|
30 | QmlApplicationViewer viewer; | |
|
31 | viewer.addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); | |||
31 | // viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); |
|
32 | // viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); | |
32 | viewer.setSource(QUrl("qrc:/qml/qmlf1legends/main.qml")); |
|
33 | viewer.setSource(QUrl("qrc:/qml/qmlf1legends/main.qml")); | |
33 | viewer.setRenderHint(QPainter::Antialiasing, true); |
|
34 | viewer.setRenderHint(QPainter::Antialiasing, true); | |
34 | viewer.showExpanded(); |
|
35 | viewer.showExpanded(); | |
35 | return app->exec(); |
|
36 | return app->exec(); | |
36 | } |
|
37 | } |
@@ -1,178 +1,177 | |||||
1 | // checksum 0xbd34 version 0x80016 |
|
1 | // checksum 0xbd34 version 0x80016 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #include "qmlapplicationviewer.h" |
|
11 | #include "qmlapplicationviewer.h" | |
12 |
|
12 | |||
13 | #include <QDir> |
|
13 | #include <QDir> | |
14 | #include <QFileInfo> |
|
14 | #include <QFileInfo> | |
15 | #include <QApplication> |
|
15 | #include <QApplication> | |
16 | #include <QDeclarativeComponent> |
|
16 | #include <QDeclarativeComponent> | |
17 | #include <QDeclarativeEngine> |
|
17 | #include <QDeclarativeEngine> | |
18 | #include <QDeclarativeContext> |
|
18 | #include <QDeclarativeContext> | |
19 |
|
19 | |||
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |
21 |
|
21 | |||
22 | #ifdef HARMATTAN_BOOSTER |
|
22 | #ifdef HARMATTAN_BOOSTER | |
23 | #include <MDeclarativeCache> |
|
23 | #include <MDeclarativeCache> | |
24 | #endif |
|
24 | #endif | |
25 |
|
25 | |||
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
27 |
|
27 | |||
28 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |
29 |
|
29 | |||
30 | #if !defined(NO_JSDEBUGGER) |
|
30 | #if !defined(NO_JSDEBUGGER) | |
31 | #include <jsdebuggeragent.h> |
|
31 | #include <jsdebuggeragent.h> | |
32 | #endif |
|
32 | #endif | |
33 | #if !defined(NO_QMLOBSERVER) |
|
33 | #if !defined(NO_QMLOBSERVER) | |
34 | #include <qdeclarativeviewobserver.h> |
|
34 | #include <qdeclarativeviewobserver.h> | |
35 | #endif |
|
35 | #endif | |
36 |
|
36 | |||
37 | // Enable debugging before any QDeclarativeEngine is created |
|
37 | // Enable debugging before any QDeclarativeEngine is created | |
38 | struct QmlJsDebuggingEnabler |
|
38 | struct QmlJsDebuggingEnabler | |
39 | { |
|
39 | { | |
40 | QmlJsDebuggingEnabler() |
|
40 | QmlJsDebuggingEnabler() | |
41 | { |
|
41 | { | |
42 | QDeclarativeDebugHelper::enableDebugging(); |
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |
43 | } |
|
43 | } | |
44 | }; |
|
44 | }; | |
45 |
|
45 | |||
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |
48 |
|
48 | |||
49 | #endif // QMLJSDEBUGGER |
|
49 | #endif // QMLJSDEBUGGER | |
50 |
|
50 | |||
51 | class QmlApplicationViewerPrivate |
|
51 | class QmlApplicationViewerPrivate | |
52 | { |
|
52 | { | |
53 | QString mainQmlFile; |
|
53 | QString mainQmlFile; | |
54 | friend class QmlApplicationViewer; |
|
54 | friend class QmlApplicationViewer; | |
55 | static QString adjustPath(const QString &path); |
|
55 | static QString adjustPath(const QString &path); | |
56 | }; |
|
56 | }; | |
57 |
|
57 | |||
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |
59 | { |
|
59 | { | |
60 | #ifdef Q_OS_MAC |
|
60 | #ifdef Q_OS_MAC | |
61 | if (!QDir::isAbsolutePath(path)) |
|
61 | if (!QDir::isAbsolutePath(path)) | |
62 | return QString::fromLatin1("%1/../Resources/%2") |
|
62 | return QString::fromLatin1("%1/../Resources/%2") | |
63 | .arg(QCoreApplication::applicationDirPath(), path); |
|
63 | .arg(QCoreApplication::applicationDirPath(), path); | |
64 | #elif defined(Q_OS_QNX) |
|
64 | #elif defined(Q_OS_QNX) | |
65 | if (!QDir::isAbsolutePath(path)) |
|
65 | if (!QDir::isAbsolutePath(path)) | |
66 | return QString::fromLatin1("app/native/%1").arg(path); |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
67 | #elif !defined(Q_OS_ANDROID) |
|
67 | #elif !defined(Q_OS_ANDROID) | |
68 | QString pathInInstallDir = |
|
68 | QString pathInInstallDir = | |
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); |
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
70 | if (QFileInfo(pathInInstallDir).exists()) |
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |
71 | return pathInInstallDir; |
|
71 | return pathInInstallDir; | |
72 | pathInInstallDir = |
|
72 | pathInInstallDir = | |
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
74 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |
75 | return pathInInstallDir; |
|
75 | return pathInInstallDir; | |
76 | #endif |
|
76 | #endif | |
77 | return path; |
|
77 | return path; | |
78 | } |
|
78 | } | |
79 |
|
79 | |||
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |
81 | : QDeclarativeView(parent) |
|
81 | : QDeclarativeView(parent) | |
82 | , d(new QmlApplicationViewerPrivate()) |
|
82 | , d(new QmlApplicationViewerPrivate()) | |
83 | { |
|
83 | { | |
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
86 |
|
86 | |||
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
89 | #if !defined(NO_JSDEBUGGER) |
|
89 | #if !defined(NO_JSDEBUGGER) | |
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); |
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
91 | #endif |
|
91 | #endif | |
92 | #if !defined(NO_QMLOBSERVER) |
|
92 | #if !defined(NO_QMLOBSERVER) | |
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); |
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
94 | #endif |
|
94 | #endif | |
95 | #endif |
|
95 | #endif | |
96 | addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); |
|
|||
97 | } |
|
96 | } | |
98 |
|
97 | |||
99 | QmlApplicationViewer::~QmlApplicationViewer() |
|
98 | QmlApplicationViewer::~QmlApplicationViewer() | |
100 | { |
|
99 | { | |
101 | delete d; |
|
100 | delete d; | |
102 | } |
|
101 | } | |
103 |
|
102 | |||
104 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
103 | QmlApplicationViewer *QmlApplicationViewer::create() | |
105 | { |
|
104 | { | |
106 | return new QmlApplicationViewer(); |
|
105 | return new QmlApplicationViewer(); | |
107 | } |
|
106 | } | |
108 |
|
107 | |||
109 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
110 | { |
|
109 | { | |
111 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); |
|
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
112 | #ifdef Q_OS_ANDROID |
|
111 | #ifdef Q_OS_ANDROID | |
113 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
114 | #else |
|
113 | #else | |
115 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
116 | #endif |
|
115 | #endif | |
117 | } |
|
116 | } | |
118 |
|
117 | |||
119 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
118 | void QmlApplicationViewer::addImportPath(const QString &path) | |
120 | { |
|
119 | { | |
121 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); |
|
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
122 | } |
|
121 | } | |
123 |
|
122 | |||
124 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
125 | { |
|
124 | { | |
126 | #if QT_VERSION < 0x050000 |
|
125 | #if QT_VERSION < 0x050000 | |
127 | Qt::WidgetAttribute attribute; |
|
126 | Qt::WidgetAttribute attribute; | |
128 | switch (orientation) { |
|
127 | switch (orientation) { | |
129 | #if QT_VERSION < 0x040702 |
|
128 | #if QT_VERSION < 0x040702 | |
130 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
131 | case ScreenOrientationLockPortrait: |
|
130 | case ScreenOrientationLockPortrait: | |
132 | attribute = static_cast<Qt::WidgetAttribute>(128); |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
133 | break; |
|
132 | break; | |
134 | case ScreenOrientationLockLandscape: |
|
133 | case ScreenOrientationLockLandscape: | |
135 | attribute = static_cast<Qt::WidgetAttribute>(129); |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
136 | break; |
|
135 | break; | |
137 | default: |
|
136 | default: | |
138 | case ScreenOrientationAuto: |
|
137 | case ScreenOrientationAuto: | |
139 | attribute = static_cast<Qt::WidgetAttribute>(130); |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
140 | break; |
|
139 | break; | |
141 | #else // QT_VERSION < 0x040702 |
|
140 | #else // QT_VERSION < 0x040702 | |
142 | case ScreenOrientationLockPortrait: |
|
141 | case ScreenOrientationLockPortrait: | |
143 | attribute = Qt::WA_LockPortraitOrientation; |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
144 | break; |
|
143 | break; | |
145 | case ScreenOrientationLockLandscape: |
|
144 | case ScreenOrientationLockLandscape: | |
146 | attribute = Qt::WA_LockLandscapeOrientation; |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
147 | break; |
|
146 | break; | |
148 | default: |
|
147 | default: | |
149 | case ScreenOrientationAuto: |
|
148 | case ScreenOrientationAuto: | |
150 | attribute = Qt::WA_AutoOrientation; |
|
149 | attribute = Qt::WA_AutoOrientation; | |
151 | break; |
|
150 | break; | |
152 | #endif // QT_VERSION < 0x040702 |
|
151 | #endif // QT_VERSION < 0x040702 | |
153 | }; |
|
152 | }; | |
154 | setAttribute(attribute, true); |
|
153 | setAttribute(attribute, true); | |
155 | #else // QT_VERSION < 0x050000 |
|
154 | #else // QT_VERSION < 0x050000 | |
156 | Q_UNUSED(orientation) |
|
155 | Q_UNUSED(orientation) | |
157 | #endif // QT_VERSION < 0x050000 |
|
156 | #endif // QT_VERSION < 0x050000 | |
158 | } |
|
157 | } | |
159 |
|
158 | |||
160 | void QmlApplicationViewer::showExpanded() |
|
159 | void QmlApplicationViewer::showExpanded() | |
161 | { |
|
160 | { | |
162 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
163 | showFullScreen(); |
|
162 | showFullScreen(); | |
164 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
165 | showMaximized(); |
|
164 | showMaximized(); | |
166 | #else |
|
165 | #else | |
167 | show(); |
|
166 | show(); | |
168 | #endif |
|
167 | #endif | |
169 | } |
|
168 | } | |
170 |
|
169 | |||
171 | QApplication *createApplication(int &argc, char **argv) |
|
170 | QApplication *createApplication(int &argc, char **argv) | |
172 | { |
|
171 | { | |
173 | #ifdef HARMATTAN_BOOSTER |
|
172 | #ifdef HARMATTAN_BOOSTER | |
174 | return MDeclarativeCache::qApplication(argc, argv); |
|
173 | return MDeclarativeCache::qApplication(argc, argv); | |
175 | #else |
|
174 | #else | |
176 | return new QApplication(argc, argv); |
|
175 | return new QApplication(argc, argv); | |
177 | #endif |
|
176 | #endif | |
178 | } |
|
177 | } |
@@ -1,39 +1,40 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QApplication> |
|
21 | #include <QApplication> | |
22 | #include <QtDeclarative/QDeclarativeContext> |
|
22 | #include <QtDeclarative/QDeclarativeContext> | |
23 | #include "qmlapplicationviewer.h" |
|
23 | #include "qmlapplicationviewer.h" | |
24 | #include "datasource.h" |
|
24 | #include "datasource.h" | |
25 |
|
25 | |||
26 | Q_DECL_EXPORT int main(int argc, char *argv[]) |
|
26 | Q_DECL_EXPORT int main(int argc, char *argv[]) | |
27 | { |
|
27 | { | |
28 | QScopedPointer<QApplication> app(createApplication(argc, argv)); |
|
28 | QScopedPointer<QApplication> app(createApplication(argc, argv)); | |
29 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); |
|
29 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); | |
|
30 | viewer->addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); | |||
30 |
|
31 | |||
31 | DataSource dataSource(viewer.data()); |
|
32 | DataSource dataSource(viewer.data()); | |
32 | viewer->rootContext()->setContextProperty("dataSource", &dataSource); |
|
33 | viewer->rootContext()->setContextProperty("dataSource", &dataSource); | |
33 |
|
34 | |||
34 | // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); |
|
35 | // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); | |
35 | viewer->setSource(QUrl("qrc:/qml/qmloscilloscope/main.qml")); |
|
36 | viewer->setSource(QUrl("qrc:/qml/qmloscilloscope/main.qml")); | |
36 | viewer->showExpanded(); |
|
37 | viewer->showExpanded(); | |
37 |
|
38 | |||
38 | return app->exec(); |
|
39 | return app->exec(); | |
39 | } |
|
40 | } |
@@ -1,178 +1,177 | |||||
1 | // checksum 0xbd34 version 0x80016 |
|
1 | // checksum 0xbd34 version 0x80016 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #include "qmlapplicationviewer.h" |
|
11 | #include "qmlapplicationviewer.h" | |
12 |
|
12 | |||
13 | #include <QDir> |
|
13 | #include <QDir> | |
14 | #include <QFileInfo> |
|
14 | #include <QFileInfo> | |
15 | #include <QApplication> |
|
15 | #include <QApplication> | |
16 | #include <QDeclarativeComponent> |
|
16 | #include <QDeclarativeComponent> | |
17 | #include <QDeclarativeEngine> |
|
17 | #include <QDeclarativeEngine> | |
18 | #include <QDeclarativeContext> |
|
18 | #include <QDeclarativeContext> | |
19 |
|
19 | |||
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |
21 |
|
21 | |||
22 | #ifdef HARMATTAN_BOOSTER |
|
22 | #ifdef HARMATTAN_BOOSTER | |
23 | #include <MDeclarativeCache> |
|
23 | #include <MDeclarativeCache> | |
24 | #endif |
|
24 | #endif | |
25 |
|
25 | |||
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
27 |
|
27 | |||
28 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |
29 |
|
29 | |||
30 | #if !defined(NO_JSDEBUGGER) |
|
30 | #if !defined(NO_JSDEBUGGER) | |
31 | #include <jsdebuggeragent.h> |
|
31 | #include <jsdebuggeragent.h> | |
32 | #endif |
|
32 | #endif | |
33 | #if !defined(NO_QMLOBSERVER) |
|
33 | #if !defined(NO_QMLOBSERVER) | |
34 | #include <qdeclarativeviewobserver.h> |
|
34 | #include <qdeclarativeviewobserver.h> | |
35 | #endif |
|
35 | #endif | |
36 |
|
36 | |||
37 | // Enable debugging before any QDeclarativeEngine is created |
|
37 | // Enable debugging before any QDeclarativeEngine is created | |
38 | struct QmlJsDebuggingEnabler |
|
38 | struct QmlJsDebuggingEnabler | |
39 | { |
|
39 | { | |
40 | QmlJsDebuggingEnabler() |
|
40 | QmlJsDebuggingEnabler() | |
41 | { |
|
41 | { | |
42 | QDeclarativeDebugHelper::enableDebugging(); |
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |
43 | } |
|
43 | } | |
44 | }; |
|
44 | }; | |
45 |
|
45 | |||
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |
48 |
|
48 | |||
49 | #endif // QMLJSDEBUGGER |
|
49 | #endif // QMLJSDEBUGGER | |
50 |
|
50 | |||
51 | class QmlApplicationViewerPrivate |
|
51 | class QmlApplicationViewerPrivate | |
52 | { |
|
52 | { | |
53 | QString mainQmlFile; |
|
53 | QString mainQmlFile; | |
54 | friend class QmlApplicationViewer; |
|
54 | friend class QmlApplicationViewer; | |
55 | static QString adjustPath(const QString &path); |
|
55 | static QString adjustPath(const QString &path); | |
56 | }; |
|
56 | }; | |
57 |
|
57 | |||
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |
59 | { |
|
59 | { | |
60 | #ifdef Q_OS_MAC |
|
60 | #ifdef Q_OS_MAC | |
61 | if (!QDir::isAbsolutePath(path)) |
|
61 | if (!QDir::isAbsolutePath(path)) | |
62 | return QString::fromLatin1("%1/../Resources/%2") |
|
62 | return QString::fromLatin1("%1/../Resources/%2") | |
63 | .arg(QCoreApplication::applicationDirPath(), path); |
|
63 | .arg(QCoreApplication::applicationDirPath(), path); | |
64 | #elif defined(Q_OS_QNX) |
|
64 | #elif defined(Q_OS_QNX) | |
65 | if (!QDir::isAbsolutePath(path)) |
|
65 | if (!QDir::isAbsolutePath(path)) | |
66 | return QString::fromLatin1("app/native/%1").arg(path); |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
67 | #elif !defined(Q_OS_ANDROID) |
|
67 | #elif !defined(Q_OS_ANDROID) | |
68 | QString pathInInstallDir = |
|
68 | QString pathInInstallDir = | |
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); |
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
70 | if (QFileInfo(pathInInstallDir).exists()) |
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |
71 | return pathInInstallDir; |
|
71 | return pathInInstallDir; | |
72 | pathInInstallDir = |
|
72 | pathInInstallDir = | |
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
74 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |
75 | return pathInInstallDir; |
|
75 | return pathInInstallDir; | |
76 | #endif |
|
76 | #endif | |
77 | return path; |
|
77 | return path; | |
78 | } |
|
78 | } | |
79 |
|
79 | |||
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |
81 | : QDeclarativeView(parent) |
|
81 | : QDeclarativeView(parent) | |
82 | , d(new QmlApplicationViewerPrivate()) |
|
82 | , d(new QmlApplicationViewerPrivate()) | |
83 | { |
|
83 | { | |
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
86 |
|
86 | |||
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
89 | #if !defined(NO_JSDEBUGGER) |
|
89 | #if !defined(NO_JSDEBUGGER) | |
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); |
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
91 | #endif |
|
91 | #endif | |
92 | #if !defined(NO_QMLOBSERVER) |
|
92 | #if !defined(NO_QMLOBSERVER) | |
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); |
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
94 | #endif |
|
94 | #endif | |
95 | #endif |
|
95 | #endif | |
96 | addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); |
|
|||
97 | } |
|
96 | } | |
98 |
|
97 | |||
99 | QmlApplicationViewer::~QmlApplicationViewer() |
|
98 | QmlApplicationViewer::~QmlApplicationViewer() | |
100 | { |
|
99 | { | |
101 | delete d; |
|
100 | delete d; | |
102 | } |
|
101 | } | |
103 |
|
102 | |||
104 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
103 | QmlApplicationViewer *QmlApplicationViewer::create() | |
105 | { |
|
104 | { | |
106 | return new QmlApplicationViewer(); |
|
105 | return new QmlApplicationViewer(); | |
107 | } |
|
106 | } | |
108 |
|
107 | |||
109 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
110 | { |
|
109 | { | |
111 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); |
|
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
112 | #ifdef Q_OS_ANDROID |
|
111 | #ifdef Q_OS_ANDROID | |
113 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
114 | #else |
|
113 | #else | |
115 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
116 | #endif |
|
115 | #endif | |
117 | } |
|
116 | } | |
118 |
|
117 | |||
119 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
118 | void QmlApplicationViewer::addImportPath(const QString &path) | |
120 | { |
|
119 | { | |
121 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); |
|
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
122 | } |
|
121 | } | |
123 |
|
122 | |||
124 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
125 | { |
|
124 | { | |
126 | #if QT_VERSION < 0x050000 |
|
125 | #if QT_VERSION < 0x050000 | |
127 | Qt::WidgetAttribute attribute; |
|
126 | Qt::WidgetAttribute attribute; | |
128 | switch (orientation) { |
|
127 | switch (orientation) { | |
129 | #if QT_VERSION < 0x040702 |
|
128 | #if QT_VERSION < 0x040702 | |
130 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
131 | case ScreenOrientationLockPortrait: |
|
130 | case ScreenOrientationLockPortrait: | |
132 | attribute = static_cast<Qt::WidgetAttribute>(128); |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
133 | break; |
|
132 | break; | |
134 | case ScreenOrientationLockLandscape: |
|
133 | case ScreenOrientationLockLandscape: | |
135 | attribute = static_cast<Qt::WidgetAttribute>(129); |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
136 | break; |
|
135 | break; | |
137 | default: |
|
136 | default: | |
138 | case ScreenOrientationAuto: |
|
137 | case ScreenOrientationAuto: | |
139 | attribute = static_cast<Qt::WidgetAttribute>(130); |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
140 | break; |
|
139 | break; | |
141 | #else // QT_VERSION < 0x040702 |
|
140 | #else // QT_VERSION < 0x040702 | |
142 | case ScreenOrientationLockPortrait: |
|
141 | case ScreenOrientationLockPortrait: | |
143 | attribute = Qt::WA_LockPortraitOrientation; |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
144 | break; |
|
143 | break; | |
145 | case ScreenOrientationLockLandscape: |
|
144 | case ScreenOrientationLockLandscape: | |
146 | attribute = Qt::WA_LockLandscapeOrientation; |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
147 | break; |
|
146 | break; | |
148 | default: |
|
147 | default: | |
149 | case ScreenOrientationAuto: |
|
148 | case ScreenOrientationAuto: | |
150 | attribute = Qt::WA_AutoOrientation; |
|
149 | attribute = Qt::WA_AutoOrientation; | |
151 | break; |
|
150 | break; | |
152 | #endif // QT_VERSION < 0x040702 |
|
151 | #endif // QT_VERSION < 0x040702 | |
153 | }; |
|
152 | }; | |
154 | setAttribute(attribute, true); |
|
153 | setAttribute(attribute, true); | |
155 | #else // QT_VERSION < 0x050000 |
|
154 | #else // QT_VERSION < 0x050000 | |
156 | Q_UNUSED(orientation) |
|
155 | Q_UNUSED(orientation) | |
157 | #endif // QT_VERSION < 0x050000 |
|
156 | #endif // QT_VERSION < 0x050000 | |
158 | } |
|
157 | } | |
159 |
|
158 | |||
160 | void QmlApplicationViewer::showExpanded() |
|
159 | void QmlApplicationViewer::showExpanded() | |
161 | { |
|
160 | { | |
162 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
163 | showFullScreen(); |
|
162 | showFullScreen(); | |
164 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
165 | showMaximized(); |
|
164 | showMaximized(); | |
166 | #else |
|
165 | #else | |
167 | show(); |
|
166 | show(); | |
168 | #endif |
|
167 | #endif | |
169 | } |
|
168 | } | |
170 |
|
169 | |||
171 | QApplication *createApplication(int &argc, char **argv) |
|
170 | QApplication *createApplication(int &argc, char **argv) | |
172 | { |
|
171 | { | |
173 | #ifdef HARMATTAN_BOOSTER |
|
172 | #ifdef HARMATTAN_BOOSTER | |
174 | return MDeclarativeCache::qApplication(argc, argv); |
|
173 | return MDeclarativeCache::qApplication(argc, argv); | |
175 | #else |
|
174 | #else | |
176 | return new QApplication(argc, argv); |
|
175 | return new QApplication(argc, argv); | |
177 | #endif |
|
176 | #endif | |
178 | } |
|
177 | } |
@@ -1,36 +1,37 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QApplication> |
|
21 | #include <QApplication> | |
22 | #include <QtDeclarative/QDeclarativeEngine> |
|
22 | #include <QtDeclarative/QDeclarativeEngine> | |
23 | #include "qmlapplicationviewer.h" |
|
23 | #include "qmlapplicationviewer.h" | |
24 |
|
24 | |||
25 | Q_DECL_EXPORT int main(int argc, char *argv[]) |
|
25 | Q_DECL_EXPORT int main(int argc, char *argv[]) | |
26 | { |
|
26 | { | |
27 | QScopedPointer<QApplication> app(createApplication(argc, argv)); |
|
27 | QScopedPointer<QApplication> app(createApplication(argc, argv)); | |
28 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); |
|
28 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); | |
|
29 | viewer->addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); | |||
29 |
|
30 | |||
30 | // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); |
|
31 | // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); | |
31 | viewer->setSource(QUrl("qrc:/qml/qmlpolarchart/loader.qml")); |
|
32 | viewer->setSource(QUrl("qrc:/qml/qmlpolarchart/loader.qml")); | |
32 | viewer->setRenderHint(QPainter::Antialiasing, true); |
|
33 | viewer->setRenderHint(QPainter::Antialiasing, true); | |
33 | viewer->showExpanded(); |
|
34 | viewer->showExpanded(); | |
34 |
|
35 | |||
35 | return app->exec(); |
|
36 | return app->exec(); | |
36 | } |
|
37 | } |
@@ -1,178 +1,177 | |||||
1 | // checksum 0xbd34 version 0x80016 |
|
1 | // checksum 0xbd34 version 0x80016 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #include "qmlapplicationviewer.h" |
|
11 | #include "qmlapplicationviewer.h" | |
12 |
|
12 | |||
13 | #include <QDir> |
|
13 | #include <QDir> | |
14 | #include <QFileInfo> |
|
14 | #include <QFileInfo> | |
15 | #include <QApplication> |
|
15 | #include <QApplication> | |
16 | #include <QDeclarativeComponent> |
|
16 | #include <QDeclarativeComponent> | |
17 | #include <QDeclarativeEngine> |
|
17 | #include <QDeclarativeEngine> | |
18 | #include <QDeclarativeContext> |
|
18 | #include <QDeclarativeContext> | |
19 |
|
19 | |||
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |
21 |
|
21 | |||
22 | #ifdef HARMATTAN_BOOSTER |
|
22 | #ifdef HARMATTAN_BOOSTER | |
23 | #include <MDeclarativeCache> |
|
23 | #include <MDeclarativeCache> | |
24 | #endif |
|
24 | #endif | |
25 |
|
25 | |||
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
27 |
|
27 | |||
28 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |
29 |
|
29 | |||
30 | #if !defined(NO_JSDEBUGGER) |
|
30 | #if !defined(NO_JSDEBUGGER) | |
31 | #include <jsdebuggeragent.h> |
|
31 | #include <jsdebuggeragent.h> | |
32 | #endif |
|
32 | #endif | |
33 | #if !defined(NO_QMLOBSERVER) |
|
33 | #if !defined(NO_QMLOBSERVER) | |
34 | #include <qdeclarativeviewobserver.h> |
|
34 | #include <qdeclarativeviewobserver.h> | |
35 | #endif |
|
35 | #endif | |
36 |
|
36 | |||
37 | // Enable debugging before any QDeclarativeEngine is created |
|
37 | // Enable debugging before any QDeclarativeEngine is created | |
38 | struct QmlJsDebuggingEnabler |
|
38 | struct QmlJsDebuggingEnabler | |
39 | { |
|
39 | { | |
40 | QmlJsDebuggingEnabler() |
|
40 | QmlJsDebuggingEnabler() | |
41 | { |
|
41 | { | |
42 | QDeclarativeDebugHelper::enableDebugging(); |
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |
43 | } |
|
43 | } | |
44 | }; |
|
44 | }; | |
45 |
|
45 | |||
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |
48 |
|
48 | |||
49 | #endif // QMLJSDEBUGGER |
|
49 | #endif // QMLJSDEBUGGER | |
50 |
|
50 | |||
51 | class QmlApplicationViewerPrivate |
|
51 | class QmlApplicationViewerPrivate | |
52 | { |
|
52 | { | |
53 | QString mainQmlFile; |
|
53 | QString mainQmlFile; | |
54 | friend class QmlApplicationViewer; |
|
54 | friend class QmlApplicationViewer; | |
55 | static QString adjustPath(const QString &path); |
|
55 | static QString adjustPath(const QString &path); | |
56 | }; |
|
56 | }; | |
57 |
|
57 | |||
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |
59 | { |
|
59 | { | |
60 | #ifdef Q_OS_MAC |
|
60 | #ifdef Q_OS_MAC | |
61 | if (!QDir::isAbsolutePath(path)) |
|
61 | if (!QDir::isAbsolutePath(path)) | |
62 | return QString::fromLatin1("%1/../Resources/%2") |
|
62 | return QString::fromLatin1("%1/../Resources/%2") | |
63 | .arg(QCoreApplication::applicationDirPath(), path); |
|
63 | .arg(QCoreApplication::applicationDirPath(), path); | |
64 | #elif defined(Q_OS_QNX) |
|
64 | #elif defined(Q_OS_QNX) | |
65 | if (!QDir::isAbsolutePath(path)) |
|
65 | if (!QDir::isAbsolutePath(path)) | |
66 | return QString::fromLatin1("app/native/%1").arg(path); |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
67 | #elif !defined(Q_OS_ANDROID) |
|
67 | #elif !defined(Q_OS_ANDROID) | |
68 | QString pathInInstallDir = |
|
68 | QString pathInInstallDir = | |
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); |
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
70 | if (QFileInfo(pathInInstallDir).exists()) |
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |
71 | return pathInInstallDir; |
|
71 | return pathInInstallDir; | |
72 | pathInInstallDir = |
|
72 | pathInInstallDir = | |
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
74 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |
75 | return pathInInstallDir; |
|
75 | return pathInInstallDir; | |
76 | #endif |
|
76 | #endif | |
77 | return path; |
|
77 | return path; | |
78 | } |
|
78 | } | |
79 |
|
79 | |||
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |
81 | : QDeclarativeView(parent) |
|
81 | : QDeclarativeView(parent) | |
82 | , d(new QmlApplicationViewerPrivate()) |
|
82 | , d(new QmlApplicationViewerPrivate()) | |
83 | { |
|
83 | { | |
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
86 |
|
86 | |||
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
89 | #if !defined(NO_JSDEBUGGER) |
|
89 | #if !defined(NO_JSDEBUGGER) | |
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); |
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
91 | #endif |
|
91 | #endif | |
92 | #if !defined(NO_QMLOBSERVER) |
|
92 | #if !defined(NO_QMLOBSERVER) | |
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); |
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
94 | #endif |
|
94 | #endif | |
95 | #endif |
|
95 | #endif | |
96 | addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); |
|
|||
97 | } |
|
96 | } | |
98 |
|
97 | |||
99 | QmlApplicationViewer::~QmlApplicationViewer() |
|
98 | QmlApplicationViewer::~QmlApplicationViewer() | |
100 | { |
|
99 | { | |
101 | delete d; |
|
100 | delete d; | |
102 | } |
|
101 | } | |
103 |
|
102 | |||
104 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
103 | QmlApplicationViewer *QmlApplicationViewer::create() | |
105 | { |
|
104 | { | |
106 | return new QmlApplicationViewer(); |
|
105 | return new QmlApplicationViewer(); | |
107 | } |
|
106 | } | |
108 |
|
107 | |||
109 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
110 | { |
|
109 | { | |
111 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); |
|
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
112 | #ifdef Q_OS_ANDROID |
|
111 | #ifdef Q_OS_ANDROID | |
113 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
114 | #else |
|
113 | #else | |
115 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
116 | #endif |
|
115 | #endif | |
117 | } |
|
116 | } | |
118 |
|
117 | |||
119 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
118 | void QmlApplicationViewer::addImportPath(const QString &path) | |
120 | { |
|
119 | { | |
121 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); |
|
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
122 | } |
|
121 | } | |
123 |
|
122 | |||
124 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
125 | { |
|
124 | { | |
126 | #if QT_VERSION < 0x050000 |
|
125 | #if QT_VERSION < 0x050000 | |
127 | Qt::WidgetAttribute attribute; |
|
126 | Qt::WidgetAttribute attribute; | |
128 | switch (orientation) { |
|
127 | switch (orientation) { | |
129 | #if QT_VERSION < 0x040702 |
|
128 | #if QT_VERSION < 0x040702 | |
130 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
131 | case ScreenOrientationLockPortrait: |
|
130 | case ScreenOrientationLockPortrait: | |
132 | attribute = static_cast<Qt::WidgetAttribute>(128); |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
133 | break; |
|
132 | break; | |
134 | case ScreenOrientationLockLandscape: |
|
133 | case ScreenOrientationLockLandscape: | |
135 | attribute = static_cast<Qt::WidgetAttribute>(129); |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
136 | break; |
|
135 | break; | |
137 | default: |
|
136 | default: | |
138 | case ScreenOrientationAuto: |
|
137 | case ScreenOrientationAuto: | |
139 | attribute = static_cast<Qt::WidgetAttribute>(130); |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
140 | break; |
|
139 | break; | |
141 | #else // QT_VERSION < 0x040702 |
|
140 | #else // QT_VERSION < 0x040702 | |
142 | case ScreenOrientationLockPortrait: |
|
141 | case ScreenOrientationLockPortrait: | |
143 | attribute = Qt::WA_LockPortraitOrientation; |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
144 | break; |
|
143 | break; | |
145 | case ScreenOrientationLockLandscape: |
|
144 | case ScreenOrientationLockLandscape: | |
146 | attribute = Qt::WA_LockLandscapeOrientation; |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
147 | break; |
|
146 | break; | |
148 | default: |
|
147 | default: | |
149 | case ScreenOrientationAuto: |
|
148 | case ScreenOrientationAuto: | |
150 | attribute = Qt::WA_AutoOrientation; |
|
149 | attribute = Qt::WA_AutoOrientation; | |
151 | break; |
|
150 | break; | |
152 | #endif // QT_VERSION < 0x040702 |
|
151 | #endif // QT_VERSION < 0x040702 | |
153 | }; |
|
152 | }; | |
154 | setAttribute(attribute, true); |
|
153 | setAttribute(attribute, true); | |
155 | #else // QT_VERSION < 0x050000 |
|
154 | #else // QT_VERSION < 0x050000 | |
156 | Q_UNUSED(orientation) |
|
155 | Q_UNUSED(orientation) | |
157 | #endif // QT_VERSION < 0x050000 |
|
156 | #endif // QT_VERSION < 0x050000 | |
158 | } |
|
157 | } | |
159 |
|
158 | |||
160 | void QmlApplicationViewer::showExpanded() |
|
159 | void QmlApplicationViewer::showExpanded() | |
161 | { |
|
160 | { | |
162 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
163 | showFullScreen(); |
|
162 | showFullScreen(); | |
164 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
165 | showMaximized(); |
|
164 | showMaximized(); | |
166 | #else |
|
165 | #else | |
167 | show(); |
|
166 | show(); | |
168 | #endif |
|
167 | #endif | |
169 | } |
|
168 | } | |
170 |
|
169 | |||
171 | QApplication *createApplication(int &argc, char **argv) |
|
170 | QApplication *createApplication(int &argc, char **argv) | |
172 | { |
|
171 | { | |
173 | #ifdef HARMATTAN_BOOSTER |
|
172 | #ifdef HARMATTAN_BOOSTER | |
174 | return MDeclarativeCache::qApplication(argc, argv); |
|
173 | return MDeclarativeCache::qApplication(argc, argv); | |
175 | #else |
|
174 | #else | |
176 | return new QApplication(argc, argv); |
|
175 | return new QApplication(argc, argv); | |
177 | #endif |
|
176 | #endif | |
178 | } |
|
177 | } |
@@ -1,44 +1,45 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QApplication> |
|
21 | #include <QApplication> | |
22 | #include <QtDeclarative/QDeclarativeContext> |
|
22 | #include <QtDeclarative/QDeclarativeContext> | |
23 | #include <QDebug> |
|
23 | #include <QDebug> | |
24 | #include "qmlapplicationviewer.h" |
|
24 | #include "qmlapplicationviewer.h" | |
25 |
|
25 | |||
26 | Q_DECL_EXPORT int main(int argc, char *argv[]) |
|
26 | Q_DECL_EXPORT int main(int argc, char *argv[]) | |
27 | { |
|
27 | { | |
28 | QScopedPointer<QApplication> app(createApplication(argc, argv)); |
|
28 | QScopedPointer<QApplication> app(createApplication(argc, argv)); | |
29 |
|
29 | |||
30 | QmlApplicationViewer viewer; |
|
30 | QmlApplicationViewer viewer; | |
|
31 | viewer.addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); | |||
31 | // viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); |
|
32 | // viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); | |
32 | QString appKey; |
|
33 | QString appKey; | |
33 | if (argc > 1) { |
|
34 | if (argc > 1) { | |
34 | appKey = argv[1]; |
|
35 | appKey = argv[1]; | |
35 | qDebug() << "App key for worldweatheronline.com:" << appKey; |
|
36 | qDebug() << "App key for worldweatheronline.com:" << appKey; | |
36 | } else { |
|
37 | } else { | |
37 | qWarning() << "No app key for worldweatheronline.com given. Using static test data instead of live data."; |
|
38 | qWarning() << "No app key for worldweatheronline.com given. Using static test data instead of live data."; | |
38 | } |
|
39 | } | |
39 | viewer.rootContext()->setContextProperty("weatherAppKey", appKey); |
|
40 | viewer.rootContext()->setContextProperty("weatherAppKey", appKey); | |
40 | viewer.setSource(QUrl("qrc:/qml/qmlweather/main.qml")); |
|
41 | viewer.setSource(QUrl("qrc:/qml/qmlweather/main.qml")); | |
41 | viewer.setRenderHint(QPainter::Antialiasing, true); |
|
42 | viewer.setRenderHint(QPainter::Antialiasing, true); | |
42 | viewer.showExpanded(); |
|
43 | viewer.showExpanded(); | |
43 | return app->exec(); |
|
44 | return app->exec(); | |
44 | } |
|
45 | } |
@@ -1,178 +1,177 | |||||
1 | // checksum 0xbd34 version 0x80016 |
|
1 | // checksum 0xbd34 version 0x80016 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #include "qmlapplicationviewer.h" |
|
11 | #include "qmlapplicationviewer.h" | |
12 |
|
12 | |||
13 | #include <QDir> |
|
13 | #include <QDir> | |
14 | #include <QFileInfo> |
|
14 | #include <QFileInfo> | |
15 | #include <QApplication> |
|
15 | #include <QApplication> | |
16 | #include <QDeclarativeComponent> |
|
16 | #include <QDeclarativeComponent> | |
17 | #include <QDeclarativeEngine> |
|
17 | #include <QDeclarativeEngine> | |
18 | #include <QDeclarativeContext> |
|
18 | #include <QDeclarativeContext> | |
19 |
|
19 | |||
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |
21 |
|
21 | |||
22 | #ifdef HARMATTAN_BOOSTER |
|
22 | #ifdef HARMATTAN_BOOSTER | |
23 | #include <MDeclarativeCache> |
|
23 | #include <MDeclarativeCache> | |
24 | #endif |
|
24 | #endif | |
25 |
|
25 | |||
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
27 |
|
27 | |||
28 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |
29 |
|
29 | |||
30 | #if !defined(NO_JSDEBUGGER) |
|
30 | #if !defined(NO_JSDEBUGGER) | |
31 | #include <jsdebuggeragent.h> |
|
31 | #include <jsdebuggeragent.h> | |
32 | #endif |
|
32 | #endif | |
33 | #if !defined(NO_QMLOBSERVER) |
|
33 | #if !defined(NO_QMLOBSERVER) | |
34 | #include <qdeclarativeviewobserver.h> |
|
34 | #include <qdeclarativeviewobserver.h> | |
35 | #endif |
|
35 | #endif | |
36 |
|
36 | |||
37 | // Enable debugging before any QDeclarativeEngine is created |
|
37 | // Enable debugging before any QDeclarativeEngine is created | |
38 | struct QmlJsDebuggingEnabler |
|
38 | struct QmlJsDebuggingEnabler | |
39 | { |
|
39 | { | |
40 | QmlJsDebuggingEnabler() |
|
40 | QmlJsDebuggingEnabler() | |
41 | { |
|
41 | { | |
42 | QDeclarativeDebugHelper::enableDebugging(); |
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |
43 | } |
|
43 | } | |
44 | }; |
|
44 | }; | |
45 |
|
45 | |||
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |
48 |
|
48 | |||
49 | #endif // QMLJSDEBUGGER |
|
49 | #endif // QMLJSDEBUGGER | |
50 |
|
50 | |||
51 | class QmlApplicationViewerPrivate |
|
51 | class QmlApplicationViewerPrivate | |
52 | { |
|
52 | { | |
53 | QString mainQmlFile; |
|
53 | QString mainQmlFile; | |
54 | friend class QmlApplicationViewer; |
|
54 | friend class QmlApplicationViewer; | |
55 | static QString adjustPath(const QString &path); |
|
55 | static QString adjustPath(const QString &path); | |
56 | }; |
|
56 | }; | |
57 |
|
57 | |||
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |
59 | { |
|
59 | { | |
60 | #ifdef Q_OS_MAC |
|
60 | #ifdef Q_OS_MAC | |
61 | if (!QDir::isAbsolutePath(path)) |
|
61 | if (!QDir::isAbsolutePath(path)) | |
62 | return QString::fromLatin1("%1/../Resources/%2") |
|
62 | return QString::fromLatin1("%1/../Resources/%2") | |
63 | .arg(QCoreApplication::applicationDirPath(), path); |
|
63 | .arg(QCoreApplication::applicationDirPath(), path); | |
64 | #elif defined(Q_OS_QNX) |
|
64 | #elif defined(Q_OS_QNX) | |
65 | if (!QDir::isAbsolutePath(path)) |
|
65 | if (!QDir::isAbsolutePath(path)) | |
66 | return QString::fromLatin1("app/native/%1").arg(path); |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
67 | #elif !defined(Q_OS_ANDROID) |
|
67 | #elif !defined(Q_OS_ANDROID) | |
68 | QString pathInInstallDir = |
|
68 | QString pathInInstallDir = | |
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); |
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
70 | if (QFileInfo(pathInInstallDir).exists()) |
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |
71 | return pathInInstallDir; |
|
71 | return pathInInstallDir; | |
72 | pathInInstallDir = |
|
72 | pathInInstallDir = | |
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
74 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |
75 | return pathInInstallDir; |
|
75 | return pathInInstallDir; | |
76 | #endif |
|
76 | #endif | |
77 | return path; |
|
77 | return path; | |
78 | } |
|
78 | } | |
79 |
|
79 | |||
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |
81 | : QDeclarativeView(parent) |
|
81 | : QDeclarativeView(parent) | |
82 | , d(new QmlApplicationViewerPrivate()) |
|
82 | , d(new QmlApplicationViewerPrivate()) | |
83 | { |
|
83 | { | |
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
86 |
|
86 | |||
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
89 | #if !defined(NO_JSDEBUGGER) |
|
89 | #if !defined(NO_JSDEBUGGER) | |
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); |
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
91 | #endif |
|
91 | #endif | |
92 | #if !defined(NO_QMLOBSERVER) |
|
92 | #if !defined(NO_QMLOBSERVER) | |
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); |
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
94 | #endif |
|
94 | #endif | |
95 | #endif |
|
95 | #endif | |
96 | addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); |
|
|||
97 | } |
|
96 | } | |
98 |
|
97 | |||
99 | QmlApplicationViewer::~QmlApplicationViewer() |
|
98 | QmlApplicationViewer::~QmlApplicationViewer() | |
100 | { |
|
99 | { | |
101 | delete d; |
|
100 | delete d; | |
102 | } |
|
101 | } | |
103 |
|
102 | |||
104 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
103 | QmlApplicationViewer *QmlApplicationViewer::create() | |
105 | { |
|
104 | { | |
106 | return new QmlApplicationViewer(); |
|
105 | return new QmlApplicationViewer(); | |
107 | } |
|
106 | } | |
108 |
|
107 | |||
109 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
110 | { |
|
109 | { | |
111 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); |
|
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
112 | #ifdef Q_OS_ANDROID |
|
111 | #ifdef Q_OS_ANDROID | |
113 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
114 | #else |
|
113 | #else | |
115 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
116 | #endif |
|
115 | #endif | |
117 | } |
|
116 | } | |
118 |
|
117 | |||
119 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
118 | void QmlApplicationViewer::addImportPath(const QString &path) | |
120 | { |
|
119 | { | |
121 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); |
|
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
122 | } |
|
121 | } | |
123 |
|
122 | |||
124 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
125 | { |
|
124 | { | |
126 | #if QT_VERSION < 0x050000 |
|
125 | #if QT_VERSION < 0x050000 | |
127 | Qt::WidgetAttribute attribute; |
|
126 | Qt::WidgetAttribute attribute; | |
128 | switch (orientation) { |
|
127 | switch (orientation) { | |
129 | #if QT_VERSION < 0x040702 |
|
128 | #if QT_VERSION < 0x040702 | |
130 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
131 | case ScreenOrientationLockPortrait: |
|
130 | case ScreenOrientationLockPortrait: | |
132 | attribute = static_cast<Qt::WidgetAttribute>(128); |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
133 | break; |
|
132 | break; | |
134 | case ScreenOrientationLockLandscape: |
|
133 | case ScreenOrientationLockLandscape: | |
135 | attribute = static_cast<Qt::WidgetAttribute>(129); |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
136 | break; |
|
135 | break; | |
137 | default: |
|
136 | default: | |
138 | case ScreenOrientationAuto: |
|
137 | case ScreenOrientationAuto: | |
139 | attribute = static_cast<Qt::WidgetAttribute>(130); |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
140 | break; |
|
139 | break; | |
141 | #else // QT_VERSION < 0x040702 |
|
140 | #else // QT_VERSION < 0x040702 | |
142 | case ScreenOrientationLockPortrait: |
|
141 | case ScreenOrientationLockPortrait: | |
143 | attribute = Qt::WA_LockPortraitOrientation; |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
144 | break; |
|
143 | break; | |
145 | case ScreenOrientationLockLandscape: |
|
144 | case ScreenOrientationLockLandscape: | |
146 | attribute = Qt::WA_LockLandscapeOrientation; |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
147 | break; |
|
146 | break; | |
148 | default: |
|
147 | default: | |
149 | case ScreenOrientationAuto: |
|
148 | case ScreenOrientationAuto: | |
150 | attribute = Qt::WA_AutoOrientation; |
|
149 | attribute = Qt::WA_AutoOrientation; | |
151 | break; |
|
150 | break; | |
152 | #endif // QT_VERSION < 0x040702 |
|
151 | #endif // QT_VERSION < 0x040702 | |
153 | }; |
|
152 | }; | |
154 | setAttribute(attribute, true); |
|
153 | setAttribute(attribute, true); | |
155 | #else // QT_VERSION < 0x050000 |
|
154 | #else // QT_VERSION < 0x050000 | |
156 | Q_UNUSED(orientation) |
|
155 | Q_UNUSED(orientation) | |
157 | #endif // QT_VERSION < 0x050000 |
|
156 | #endif // QT_VERSION < 0x050000 | |
158 | } |
|
157 | } | |
159 |
|
158 | |||
160 | void QmlApplicationViewer::showExpanded() |
|
159 | void QmlApplicationViewer::showExpanded() | |
161 | { |
|
160 | { | |
162 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
163 | showFullScreen(); |
|
162 | showFullScreen(); | |
164 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
165 | showMaximized(); |
|
164 | showMaximized(); | |
166 | #else |
|
165 | #else | |
167 | show(); |
|
166 | show(); | |
168 | #endif |
|
167 | #endif | |
169 | } |
|
168 | } | |
170 |
|
169 | |||
171 | QApplication *createApplication(int &argc, char **argv) |
|
170 | QApplication *createApplication(int &argc, char **argv) | |
172 | { |
|
171 | { | |
173 | #ifdef HARMATTAN_BOOSTER |
|
172 | #ifdef HARMATTAN_BOOSTER | |
174 | return MDeclarativeCache::qApplication(argc, argv); |
|
173 | return MDeclarativeCache::qApplication(argc, argv); | |
175 | #else |
|
174 | #else | |
176 | return new QApplication(argc, argv); |
|
175 | return new QApplication(argc, argv); | |
177 | #endif |
|
176 | #endif | |
178 | } |
|
177 | } |
@@ -1,34 +1,35 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QtWidgets/QApplication> |
|
21 | #include <QtWidgets/QApplication> | |
22 | #include <QtQuick/QQuickItem> |
|
22 | #include <QtQuick/QQuickItem> | |
23 | #include "qtquick2applicationviewer.h" |
|
23 | #include "qtquick2applicationviewer.h" | |
24 |
|
24 | |||
25 | int main(int argc, char *argv[]) |
|
25 | int main(int argc, char *argv[]) | |
26 | { |
|
26 | { | |
27 | QApplication app(argc, argv); |
|
27 | QApplication app(argc, argv); | |
28 |
|
28 | |||
29 | QtQuick2ApplicationViewer viewer; |
|
29 | QtQuick2ApplicationViewer viewer; | |
|
30 | viewer.addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QString::fromLatin1("qml"))); | |||
30 | viewer.setSource(QUrl("qrc:/qml/quick2chart/main.qml")); |
|
31 | viewer.setSource(QUrl("qrc:/qml/quick2chart/main.qml")); | |
31 | viewer.showExpanded(); |
|
32 | viewer.showExpanded(); | |
32 |
|
33 | |||
33 | return app.exec(); |
|
34 | return app.exec(); | |
34 | } |
|
35 | } |
@@ -1,71 +1,70 | |||||
1 | // checksum 0x56a9 version 0x80001 |
|
1 | // checksum 0x56a9 version 0x80001 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick 2 Application wizard of Qt Creator. |
|
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 |
|
4 | QtQuick2ApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #include "qtquick2applicationviewer.h" |
|
11 | #include "qtquick2applicationviewer.h" | |
12 |
|
12 | |||
13 | #include <QtCore/QCoreApplication> |
|
13 | #include <QtCore/QCoreApplication> | |
14 | #include <QtCore/QDir> |
|
14 | #include <QtCore/QDir> | |
15 | #include <QtQml/QQmlEngine> |
|
15 | #include <QtQml/QQmlEngine> | |
16 |
|
16 | |||
17 | class QtQuick2ApplicationViewerPrivate |
|
17 | class QtQuick2ApplicationViewerPrivate | |
18 | { |
|
18 | { | |
19 | QString mainQmlFile; |
|
19 | QString mainQmlFile; | |
20 | friend class QtQuick2ApplicationViewer; |
|
20 | friend class QtQuick2ApplicationViewer; | |
21 | static QString adjustPath(const QString &path); |
|
21 | static QString adjustPath(const QString &path); | |
22 | }; |
|
22 | }; | |
23 |
|
23 | |||
24 | QString QtQuick2ApplicationViewerPrivate::adjustPath(const QString &path) |
|
24 | QString QtQuick2ApplicationViewerPrivate::adjustPath(const QString &path) | |
25 | { |
|
25 | { | |
26 | #if defined(Q_OS_MAC) |
|
26 | #if defined(Q_OS_MAC) | |
27 | if (!QDir::isAbsolutePath(path)) |
|
27 | if (!QDir::isAbsolutePath(path)) | |
28 | return QString::fromLatin1("%1/../Resources/%2") |
|
28 | return QString::fromLatin1("%1/../Resources/%2") | |
29 | .arg(QCoreApplication::applicationDirPath(), path); |
|
29 | .arg(QCoreApplication::applicationDirPath(), path); | |
30 | #elif defined(Q_OS_UNIX) |
|
30 | #elif defined(Q_OS_UNIX) | |
31 | const QString pathInInstallDir = |
|
31 | const QString pathInInstallDir = | |
32 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); |
|
32 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
33 | if (QFileInfo(pathInInstallDir).exists()) |
|
33 | if (QFileInfo(pathInInstallDir).exists()) | |
34 | return pathInInstallDir; |
|
34 | return pathInInstallDir; | |
35 | #endif |
|
35 | #endif | |
36 | return path; |
|
36 | return path; | |
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 | QtQuick2ApplicationViewer::QtQuick2ApplicationViewer(QWindow *parent) |
|
39 | QtQuick2ApplicationViewer::QtQuick2ApplicationViewer(QWindow *parent) | |
40 | : QQuickView(parent) |
|
40 | : QQuickView(parent) | |
41 | , d(new QtQuick2ApplicationViewerPrivate()) |
|
41 | , d(new QtQuick2ApplicationViewerPrivate()) | |
42 | { |
|
42 | { | |
43 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
43 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |
44 | setResizeMode(QQuickView::SizeRootObjectToView); |
|
44 | setResizeMode(QQuickView::SizeRootObjectToView); | |
45 | addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QString::fromLatin1("qml"))); |
|
|||
46 | } |
|
45 | } | |
47 |
|
46 | |||
48 | QtQuick2ApplicationViewer::~QtQuick2ApplicationViewer() |
|
47 | QtQuick2ApplicationViewer::~QtQuick2ApplicationViewer() | |
49 | { |
|
48 | { | |
50 | delete d; |
|
49 | delete d; | |
51 | } |
|
50 | } | |
52 |
|
51 | |||
53 | void QtQuick2ApplicationViewer::setMainQmlFile(const QString &file) |
|
52 | void QtQuick2ApplicationViewer::setMainQmlFile(const QString &file) | |
54 | { |
|
53 | { | |
55 | d->mainQmlFile = QtQuick2ApplicationViewerPrivate::adjustPath(file); |
|
54 | d->mainQmlFile = QtQuick2ApplicationViewerPrivate::adjustPath(file); | |
56 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
55 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
57 | } |
|
56 | } | |
58 |
|
57 | |||
59 | void QtQuick2ApplicationViewer::addImportPath(const QString &path) |
|
58 | void QtQuick2ApplicationViewer::addImportPath(const QString &path) | |
60 | { |
|
59 | { | |
61 | engine()->addImportPath(QtQuick2ApplicationViewerPrivate::adjustPath(path)); |
|
60 | engine()->addImportPath(QtQuick2ApplicationViewerPrivate::adjustPath(path)); | |
62 | } |
|
61 | } | |
63 |
|
62 | |||
64 | void QtQuick2ApplicationViewer::showExpanded() |
|
63 | void QtQuick2ApplicationViewer::showExpanded() | |
65 | { |
|
64 | { | |
66 | #if defined(Q_WS_SIMULATOR) |
|
65 | #if defined(Q_WS_SIMULATOR) | |
67 | showFullScreen(); |
|
66 | showFullScreen(); | |
68 | #else |
|
67 | #else | |
69 | show(); |
|
68 | show(); | |
70 | #endif |
|
69 | #endif | |
71 | } |
|
70 | } |
@@ -1,40 +1,41 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QtWidgets/QApplication> |
|
21 | #include <QtWidgets/QApplication> | |
22 | #include <QtQuick/QQuickItem> |
|
22 | #include <QtQuick/QQuickItem> | |
23 | #include <QtQml/QQmlContext> |
|
23 | #include <QtQml/QQmlContext> | |
24 | #include "qtquick2applicationviewer.h" |
|
24 | #include "qtquick2applicationviewer.h" | |
25 | #include "datasource.h" |
|
25 | #include "datasource.h" | |
26 |
|
26 | |||
27 | int main(int argc, char *argv[]) |
|
27 | int main(int argc, char *argv[]) | |
28 | { |
|
28 | { | |
29 | QApplication app(argc, argv); |
|
29 | QApplication app(argc, argv); | |
30 |
|
30 | |||
31 | QtQuick2ApplicationViewer viewer; |
|
31 | QtQuick2ApplicationViewer viewer; | |
|
32 | viewer.addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QString::fromLatin1("qml"))); | |||
32 |
|
33 | |||
33 | DataSource dataSource(&viewer); |
|
34 | DataSource dataSource(&viewer); | |
34 | viewer.rootContext()->setContextProperty("dataSource", &dataSource); |
|
35 | viewer.rootContext()->setContextProperty("dataSource", &dataSource); | |
35 |
|
36 | |||
36 | viewer.setSource(QUrl("qrc:/qml/quick2oscilloscope/main.qml")); |
|
37 | viewer.setSource(QUrl("qrc:/qml/quick2oscilloscope/main.qml")); | |
37 | viewer.showExpanded(); |
|
38 | viewer.showExpanded(); | |
38 |
|
39 | |||
39 | return app.exec(); |
|
40 | return app.exec(); | |
40 | } |
|
41 | } |
@@ -1,71 +1,70 | |||||
1 | // checksum 0x56a9 version 0x80001 |
|
1 | // checksum 0x56a9 version 0x80001 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick 2 Application wizard of Qt Creator. |
|
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 |
|
4 | QtQuick2ApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #include "qtquick2applicationviewer.h" |
|
11 | #include "qtquick2applicationviewer.h" | |
12 |
|
12 | |||
13 | #include <QtCore/QCoreApplication> |
|
13 | #include <QtCore/QCoreApplication> | |
14 | #include <QtCore/QDir> |
|
14 | #include <QtCore/QDir> | |
15 | #include <QtQml/QQmlEngine> |
|
15 | #include <QtQml/QQmlEngine> | |
16 |
|
16 | |||
17 | class QtQuick2ApplicationViewerPrivate |
|
17 | class QtQuick2ApplicationViewerPrivate | |
18 | { |
|
18 | { | |
19 | QString mainQmlFile; |
|
19 | QString mainQmlFile; | |
20 | friend class QtQuick2ApplicationViewer; |
|
20 | friend class QtQuick2ApplicationViewer; | |
21 | static QString adjustPath(const QString &path); |
|
21 | static QString adjustPath(const QString &path); | |
22 | }; |
|
22 | }; | |
23 |
|
23 | |||
24 | QString QtQuick2ApplicationViewerPrivate::adjustPath(const QString &path) |
|
24 | QString QtQuick2ApplicationViewerPrivate::adjustPath(const QString &path) | |
25 | { |
|
25 | { | |
26 | #if defined(Q_OS_MAC) |
|
26 | #if defined(Q_OS_MAC) | |
27 | if (!QDir::isAbsolutePath(path)) |
|
27 | if (!QDir::isAbsolutePath(path)) | |
28 | return QString::fromLatin1("%1/../Resources/%2") |
|
28 | return QString::fromLatin1("%1/../Resources/%2") | |
29 | .arg(QCoreApplication::applicationDirPath(), path); |
|
29 | .arg(QCoreApplication::applicationDirPath(), path); | |
30 | #elif defined(Q_OS_UNIX) |
|
30 | #elif defined(Q_OS_UNIX) | |
31 | const QString pathInInstallDir = |
|
31 | const QString pathInInstallDir = | |
32 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); |
|
32 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
33 | if (QFileInfo(pathInInstallDir).exists()) |
|
33 | if (QFileInfo(pathInInstallDir).exists()) | |
34 | return pathInInstallDir; |
|
34 | return pathInInstallDir; | |
35 | #endif |
|
35 | #endif | |
36 | return path; |
|
36 | return path; | |
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 | QtQuick2ApplicationViewer::QtQuick2ApplicationViewer(QWindow *parent) |
|
39 | QtQuick2ApplicationViewer::QtQuick2ApplicationViewer(QWindow *parent) | |
40 | : QQuickView(parent) |
|
40 | : QQuickView(parent) | |
41 | , d(new QtQuick2ApplicationViewerPrivate()) |
|
41 | , d(new QtQuick2ApplicationViewerPrivate()) | |
42 | { |
|
42 | { | |
43 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
43 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |
44 | setResizeMode(QQuickView::SizeRootObjectToView); |
|
44 | setResizeMode(QQuickView::SizeRootObjectToView); | |
45 | addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QString::fromLatin1("qml"))); |
|
|||
46 | } |
|
45 | } | |
47 |
|
46 | |||
48 | QtQuick2ApplicationViewer::~QtQuick2ApplicationViewer() |
|
47 | QtQuick2ApplicationViewer::~QtQuick2ApplicationViewer() | |
49 | { |
|
48 | { | |
50 | delete d; |
|
49 | delete d; | |
51 | } |
|
50 | } | |
52 |
|
51 | |||
53 | void QtQuick2ApplicationViewer::setMainQmlFile(const QString &file) |
|
52 | void QtQuick2ApplicationViewer::setMainQmlFile(const QString &file) | |
54 | { |
|
53 | { | |
55 | d->mainQmlFile = QtQuick2ApplicationViewerPrivate::adjustPath(file); |
|
54 | d->mainQmlFile = QtQuick2ApplicationViewerPrivate::adjustPath(file); | |
56 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
55 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
57 | } |
|
56 | } | |
58 |
|
57 | |||
59 | void QtQuick2ApplicationViewer::addImportPath(const QString &path) |
|
58 | void QtQuick2ApplicationViewer::addImportPath(const QString &path) | |
60 | { |
|
59 | { | |
61 | engine()->addImportPath(QtQuick2ApplicationViewerPrivate::adjustPath(path)); |
|
60 | engine()->addImportPath(QtQuick2ApplicationViewerPrivate::adjustPath(path)); | |
62 | } |
|
61 | } | |
63 |
|
62 | |||
64 | void QtQuick2ApplicationViewer::showExpanded() |
|
63 | void QtQuick2ApplicationViewer::showExpanded() | |
65 | { |
|
64 | { | |
66 | #if defined(Q_WS_SIMULATOR) |
|
65 | #if defined(Q_WS_SIMULATOR) | |
67 | showFullScreen(); |
|
66 | showFullScreen(); | |
68 | #else |
|
67 | #else | |
69 | show(); |
|
68 | show(); | |
70 | #endif |
|
69 | #endif | |
71 | } |
|
70 | } |
@@ -1,36 +1,37 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QApplication> |
|
21 | #include <QApplication> | |
22 | #include <QtDeclarative/QDeclarativeEngine> |
|
22 | #include <QtDeclarative/QDeclarativeEngine> | |
23 | #include "qmlapplicationviewer.h" |
|
23 | #include "qmlapplicationviewer.h" | |
24 |
|
24 | |||
25 | Q_DECL_EXPORT int main(int argc, char *argv[]) |
|
25 | Q_DECL_EXPORT int main(int argc, char *argv[]) | |
26 | { |
|
26 | { | |
27 | QScopedPointer<QApplication> app(createApplication(argc, argv)); |
|
27 | QScopedPointer<QApplication> app(createApplication(argc, argv)); | |
28 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); |
|
28 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); | |
|
29 | viewer->addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); | |||
29 |
|
30 | |||
30 | // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); |
|
31 | // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); | |
31 | viewer->setSource(QUrl("qrc:/qml/qmlpiechart/main.qml")); |
|
32 | viewer->setSource(QUrl("qrc:/qml/qmlpiechart/main.qml")); | |
32 | viewer->setRenderHint(QPainter::Antialiasing, true); |
|
33 | viewer->setRenderHint(QPainter::Antialiasing, true); | |
33 | viewer->showExpanded(); |
|
34 | viewer->showExpanded(); | |
34 |
|
35 | |||
35 | return app->exec(); |
|
36 | return app->exec(); | |
36 | } |
|
37 | } |
@@ -1,178 +1,177 | |||||
1 | // checksum 0xbd34 version 0x80016 |
|
1 | // checksum 0xbd34 version 0x80016 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #include "qmlapplicationviewer.h" |
|
11 | #include "qmlapplicationviewer.h" | |
12 |
|
12 | |||
13 | #include <QDir> |
|
13 | #include <QDir> | |
14 | #include <QFileInfo> |
|
14 | #include <QFileInfo> | |
15 | #include <QApplication> |
|
15 | #include <QApplication> | |
16 | #include <QDeclarativeComponent> |
|
16 | #include <QDeclarativeComponent> | |
17 | #include <QDeclarativeEngine> |
|
17 | #include <QDeclarativeEngine> | |
18 | #include <QDeclarativeContext> |
|
18 | #include <QDeclarativeContext> | |
19 |
|
19 | |||
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |
21 |
|
21 | |||
22 | #ifdef HARMATTAN_BOOSTER |
|
22 | #ifdef HARMATTAN_BOOSTER | |
23 | #include <MDeclarativeCache> |
|
23 | #include <MDeclarativeCache> | |
24 | #endif |
|
24 | #endif | |
25 |
|
25 | |||
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
27 |
|
27 | |||
28 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |
29 |
|
29 | |||
30 | #if !defined(NO_JSDEBUGGER) |
|
30 | #if !defined(NO_JSDEBUGGER) | |
31 | #include <jsdebuggeragent.h> |
|
31 | #include <jsdebuggeragent.h> | |
32 | #endif |
|
32 | #endif | |
33 | #if !defined(NO_QMLOBSERVER) |
|
33 | #if !defined(NO_QMLOBSERVER) | |
34 | #include <qdeclarativeviewobserver.h> |
|
34 | #include <qdeclarativeviewobserver.h> | |
35 | #endif |
|
35 | #endif | |
36 |
|
36 | |||
37 | // Enable debugging before any QDeclarativeEngine is created |
|
37 | // Enable debugging before any QDeclarativeEngine is created | |
38 | struct QmlJsDebuggingEnabler |
|
38 | struct QmlJsDebuggingEnabler | |
39 | { |
|
39 | { | |
40 | QmlJsDebuggingEnabler() |
|
40 | QmlJsDebuggingEnabler() | |
41 | { |
|
41 | { | |
42 | QDeclarativeDebugHelper::enableDebugging(); |
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |
43 | } |
|
43 | } | |
44 | }; |
|
44 | }; | |
45 |
|
45 | |||
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |
48 |
|
48 | |||
49 | #endif // QMLJSDEBUGGER |
|
49 | #endif // QMLJSDEBUGGER | |
50 |
|
50 | |||
51 | class QmlApplicationViewerPrivate |
|
51 | class QmlApplicationViewerPrivate | |
52 | { |
|
52 | { | |
53 | QString mainQmlFile; |
|
53 | QString mainQmlFile; | |
54 | friend class QmlApplicationViewer; |
|
54 | friend class QmlApplicationViewer; | |
55 | static QString adjustPath(const QString &path); |
|
55 | static QString adjustPath(const QString &path); | |
56 | }; |
|
56 | }; | |
57 |
|
57 | |||
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |
59 | { |
|
59 | { | |
60 | #ifdef Q_OS_MAC |
|
60 | #ifdef Q_OS_MAC | |
61 | if (!QDir::isAbsolutePath(path)) |
|
61 | if (!QDir::isAbsolutePath(path)) | |
62 | return QString::fromLatin1("%1/../Resources/%2") |
|
62 | return QString::fromLatin1("%1/../Resources/%2") | |
63 | .arg(QCoreApplication::applicationDirPath(), path); |
|
63 | .arg(QCoreApplication::applicationDirPath(), path); | |
64 | #elif defined(Q_OS_QNX) |
|
64 | #elif defined(Q_OS_QNX) | |
65 | if (!QDir::isAbsolutePath(path)) |
|
65 | if (!QDir::isAbsolutePath(path)) | |
66 | return QString::fromLatin1("app/native/%1").arg(path); |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
67 | #elif !defined(Q_OS_ANDROID) |
|
67 | #elif !defined(Q_OS_ANDROID) | |
68 | QString pathInInstallDir = |
|
68 | QString pathInInstallDir = | |
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); |
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
70 | if (QFileInfo(pathInInstallDir).exists()) |
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |
71 | return pathInInstallDir; |
|
71 | return pathInInstallDir; | |
72 | pathInInstallDir = |
|
72 | pathInInstallDir = | |
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
74 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |
75 | return pathInInstallDir; |
|
75 | return pathInInstallDir; | |
76 | #endif |
|
76 | #endif | |
77 | return path; |
|
77 | return path; | |
78 | } |
|
78 | } | |
79 |
|
79 | |||
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |
81 | : QDeclarativeView(parent) |
|
81 | : QDeclarativeView(parent) | |
82 | , d(new QmlApplicationViewerPrivate()) |
|
82 | , d(new QmlApplicationViewerPrivate()) | |
83 | { |
|
83 | { | |
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
86 |
|
86 | |||
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
89 | #if !defined(NO_JSDEBUGGER) |
|
89 | #if !defined(NO_JSDEBUGGER) | |
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); |
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
91 | #endif |
|
91 | #endif | |
92 | #if !defined(NO_QMLOBSERVER) |
|
92 | #if !defined(NO_QMLOBSERVER) | |
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); |
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
94 | #endif |
|
94 | #endif | |
95 | #endif |
|
95 | #endif | |
96 | addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); |
|
|||
97 | } |
|
96 | } | |
98 |
|
97 | |||
99 | QmlApplicationViewer::~QmlApplicationViewer() |
|
98 | QmlApplicationViewer::~QmlApplicationViewer() | |
100 | { |
|
99 | { | |
101 | delete d; |
|
100 | delete d; | |
102 | } |
|
101 | } | |
103 |
|
102 | |||
104 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
103 | QmlApplicationViewer *QmlApplicationViewer::create() | |
105 | { |
|
104 | { | |
106 | return new QmlApplicationViewer(); |
|
105 | return new QmlApplicationViewer(); | |
107 | } |
|
106 | } | |
108 |
|
107 | |||
109 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
110 | { |
|
109 | { | |
111 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); |
|
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
112 | #ifdef Q_OS_ANDROID |
|
111 | #ifdef Q_OS_ANDROID | |
113 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
114 | #else |
|
113 | #else | |
115 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
116 | #endif |
|
115 | #endif | |
117 | } |
|
116 | } | |
118 |
|
117 | |||
119 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
118 | void QmlApplicationViewer::addImportPath(const QString &path) | |
120 | { |
|
119 | { | |
121 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); |
|
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
122 | } |
|
121 | } | |
123 |
|
122 | |||
124 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
125 | { |
|
124 | { | |
126 | #if QT_VERSION < 0x050000 |
|
125 | #if QT_VERSION < 0x050000 | |
127 | Qt::WidgetAttribute attribute; |
|
126 | Qt::WidgetAttribute attribute; | |
128 | switch (orientation) { |
|
127 | switch (orientation) { | |
129 | #if QT_VERSION < 0x040702 |
|
128 | #if QT_VERSION < 0x040702 | |
130 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
131 | case ScreenOrientationLockPortrait: |
|
130 | case ScreenOrientationLockPortrait: | |
132 | attribute = static_cast<Qt::WidgetAttribute>(128); |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
133 | break; |
|
132 | break; | |
134 | case ScreenOrientationLockLandscape: |
|
133 | case ScreenOrientationLockLandscape: | |
135 | attribute = static_cast<Qt::WidgetAttribute>(129); |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
136 | break; |
|
135 | break; | |
137 | default: |
|
136 | default: | |
138 | case ScreenOrientationAuto: |
|
137 | case ScreenOrientationAuto: | |
139 | attribute = static_cast<Qt::WidgetAttribute>(130); |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
140 | break; |
|
139 | break; | |
141 | #else // QT_VERSION < 0x040702 |
|
140 | #else // QT_VERSION < 0x040702 | |
142 | case ScreenOrientationLockPortrait: |
|
141 | case ScreenOrientationLockPortrait: | |
143 | attribute = Qt::WA_LockPortraitOrientation; |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
144 | break; |
|
143 | break; | |
145 | case ScreenOrientationLockLandscape: |
|
144 | case ScreenOrientationLockLandscape: | |
146 | attribute = Qt::WA_LockLandscapeOrientation; |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
147 | break; |
|
146 | break; | |
148 | default: |
|
147 | default: | |
149 | case ScreenOrientationAuto: |
|
148 | case ScreenOrientationAuto: | |
150 | attribute = Qt::WA_AutoOrientation; |
|
149 | attribute = Qt::WA_AutoOrientation; | |
151 | break; |
|
150 | break; | |
152 | #endif // QT_VERSION < 0x040702 |
|
151 | #endif // QT_VERSION < 0x040702 | |
153 | }; |
|
152 | }; | |
154 | setAttribute(attribute, true); |
|
153 | setAttribute(attribute, true); | |
155 | #else // QT_VERSION < 0x050000 |
|
154 | #else // QT_VERSION < 0x050000 | |
156 | Q_UNUSED(orientation) |
|
155 | Q_UNUSED(orientation) | |
157 | #endif // QT_VERSION < 0x050000 |
|
156 | #endif // QT_VERSION < 0x050000 | |
158 | } |
|
157 | } | |
159 |
|
158 | |||
160 | void QmlApplicationViewer::showExpanded() |
|
159 | void QmlApplicationViewer::showExpanded() | |
161 | { |
|
160 | { | |
162 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
163 | showFullScreen(); |
|
162 | showFullScreen(); | |
164 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
165 | showMaximized(); |
|
164 | showMaximized(); | |
166 | #else |
|
165 | #else | |
167 | show(); |
|
166 | show(); | |
168 | #endif |
|
167 | #endif | |
169 | } |
|
168 | } | |
170 |
|
169 | |||
171 | QApplication *createApplication(int &argc, char **argv) |
|
170 | QApplication *createApplication(int &argc, char **argv) | |
172 | { |
|
171 | { | |
173 | #ifdef HARMATTAN_BOOSTER |
|
172 | #ifdef HARMATTAN_BOOSTER | |
174 | return MDeclarativeCache::qApplication(argc, argv); |
|
173 | return MDeclarativeCache::qApplication(argc, argv); | |
175 | #else |
|
174 | #else | |
176 | return new QApplication(argc, argv); |
|
175 | return new QApplication(argc, argv); | |
177 | #endif |
|
176 | #endif | |
178 | } |
|
177 | } |
@@ -1,35 +1,36 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QApplication> |
|
21 | #include <QApplication> | |
22 | #include <QDeclarativeEngine> |
|
22 | #include <QDeclarativeEngine> | |
23 | #include "qmlapplicationviewer.h" |
|
23 | #include "qmlapplicationviewer.h" | |
24 |
|
24 | |||
25 | Q_DECL_EXPORT int main(int argc, char *argv[]) |
|
25 | Q_DECL_EXPORT int main(int argc, char *argv[]) | |
26 | { |
|
26 | { | |
27 | QScopedPointer<QApplication> app(createApplication(argc, argv)); |
|
27 | QScopedPointer<QApplication> app(createApplication(argc, argv)); | |
28 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); |
|
28 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); | |
|
29 | viewer->addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); | |||
29 |
|
30 | |||
30 | // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); |
|
31 | // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); | |
31 | viewer->setSource(QUrl("qrc:/qml/qmlchartaxis/main.qml")); |
|
32 | viewer->setSource(QUrl("qrc:/qml/qmlchartaxis/main.qml")); | |
32 | viewer->showExpanded(); |
|
33 | viewer->showExpanded(); | |
33 |
|
34 | |||
34 | return app->exec(); |
|
35 | return app->exec(); | |
35 | } |
|
36 | } |
@@ -1,178 +1,177 | |||||
1 | // checksum 0xbd34 version 0x80016 |
|
1 | // checksum 0xbd34 version 0x80016 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #include "qmlapplicationviewer.h" |
|
11 | #include "qmlapplicationviewer.h" | |
12 |
|
12 | |||
13 | #include <QDir> |
|
13 | #include <QDir> | |
14 | #include <QFileInfo> |
|
14 | #include <QFileInfo> | |
15 | #include <QApplication> |
|
15 | #include <QApplication> | |
16 | #include <QDeclarativeComponent> |
|
16 | #include <QDeclarativeComponent> | |
17 | #include <QDeclarativeEngine> |
|
17 | #include <QDeclarativeEngine> | |
18 | #include <QDeclarativeContext> |
|
18 | #include <QDeclarativeContext> | |
19 |
|
19 | |||
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |
21 |
|
21 | |||
22 | #ifdef HARMATTAN_BOOSTER |
|
22 | #ifdef HARMATTAN_BOOSTER | |
23 | #include <MDeclarativeCache> |
|
23 | #include <MDeclarativeCache> | |
24 | #endif |
|
24 | #endif | |
25 |
|
25 | |||
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
27 |
|
27 | |||
28 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |
29 |
|
29 | |||
30 | #if !defined(NO_JSDEBUGGER) |
|
30 | #if !defined(NO_JSDEBUGGER) | |
31 | #include <jsdebuggeragent.h> |
|
31 | #include <jsdebuggeragent.h> | |
32 | #endif |
|
32 | #endif | |
33 | #if !defined(NO_QMLOBSERVER) |
|
33 | #if !defined(NO_QMLOBSERVER) | |
34 | #include <qdeclarativeviewobserver.h> |
|
34 | #include <qdeclarativeviewobserver.h> | |
35 | #endif |
|
35 | #endif | |
36 |
|
36 | |||
37 | // Enable debugging before any QDeclarativeEngine is created |
|
37 | // Enable debugging before any QDeclarativeEngine is created | |
38 | struct QmlJsDebuggingEnabler |
|
38 | struct QmlJsDebuggingEnabler | |
39 | { |
|
39 | { | |
40 | QmlJsDebuggingEnabler() |
|
40 | QmlJsDebuggingEnabler() | |
41 | { |
|
41 | { | |
42 | QDeclarativeDebugHelper::enableDebugging(); |
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |
43 | } |
|
43 | } | |
44 | }; |
|
44 | }; | |
45 |
|
45 | |||
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |
48 |
|
48 | |||
49 | #endif // QMLJSDEBUGGER |
|
49 | #endif // QMLJSDEBUGGER | |
50 |
|
50 | |||
51 | class QmlApplicationViewerPrivate |
|
51 | class QmlApplicationViewerPrivate | |
52 | { |
|
52 | { | |
53 | QString mainQmlFile; |
|
53 | QString mainQmlFile; | |
54 | friend class QmlApplicationViewer; |
|
54 | friend class QmlApplicationViewer; | |
55 | static QString adjustPath(const QString &path); |
|
55 | static QString adjustPath(const QString &path); | |
56 | }; |
|
56 | }; | |
57 |
|
57 | |||
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |
59 | { |
|
59 | { | |
60 | #ifdef Q_OS_MAC |
|
60 | #ifdef Q_OS_MAC | |
61 | if (!QDir::isAbsolutePath(path)) |
|
61 | if (!QDir::isAbsolutePath(path)) | |
62 | return QString::fromLatin1("%1/../Resources/%2") |
|
62 | return QString::fromLatin1("%1/../Resources/%2") | |
63 | .arg(QCoreApplication::applicationDirPath(), path); |
|
63 | .arg(QCoreApplication::applicationDirPath(), path); | |
64 | #elif defined(Q_OS_QNX) |
|
64 | #elif defined(Q_OS_QNX) | |
65 | if (!QDir::isAbsolutePath(path)) |
|
65 | if (!QDir::isAbsolutePath(path)) | |
66 | return QString::fromLatin1("app/native/%1").arg(path); |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
67 | #elif !defined(Q_OS_ANDROID) |
|
67 | #elif !defined(Q_OS_ANDROID) | |
68 | QString pathInInstallDir = |
|
68 | QString pathInInstallDir = | |
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); |
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
70 | if (QFileInfo(pathInInstallDir).exists()) |
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |
71 | return pathInInstallDir; |
|
71 | return pathInInstallDir; | |
72 | pathInInstallDir = |
|
72 | pathInInstallDir = | |
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
74 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |
75 | return pathInInstallDir; |
|
75 | return pathInInstallDir; | |
76 | #endif |
|
76 | #endif | |
77 | return path; |
|
77 | return path; | |
78 | } |
|
78 | } | |
79 |
|
79 | |||
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |
81 | : QDeclarativeView(parent) |
|
81 | : QDeclarativeView(parent) | |
82 | , d(new QmlApplicationViewerPrivate()) |
|
82 | , d(new QmlApplicationViewerPrivate()) | |
83 | { |
|
83 | { | |
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
86 |
|
86 | |||
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
89 | #if !defined(NO_JSDEBUGGER) |
|
89 | #if !defined(NO_JSDEBUGGER) | |
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); |
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
91 | #endif |
|
91 | #endif | |
92 | #if !defined(NO_QMLOBSERVER) |
|
92 | #if !defined(NO_QMLOBSERVER) | |
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); |
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
94 | #endif |
|
94 | #endif | |
95 | #endif |
|
95 | #endif | |
96 | addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); |
|
|||
97 | } |
|
96 | } | |
98 |
|
97 | |||
99 | QmlApplicationViewer::~QmlApplicationViewer() |
|
98 | QmlApplicationViewer::~QmlApplicationViewer() | |
100 | { |
|
99 | { | |
101 | delete d; |
|
100 | delete d; | |
102 | } |
|
101 | } | |
103 |
|
102 | |||
104 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
103 | QmlApplicationViewer *QmlApplicationViewer::create() | |
105 | { |
|
104 | { | |
106 | return new QmlApplicationViewer(); |
|
105 | return new QmlApplicationViewer(); | |
107 | } |
|
106 | } | |
108 |
|
107 | |||
109 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
110 | { |
|
109 | { | |
111 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); |
|
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
112 | #ifdef Q_OS_ANDROID |
|
111 | #ifdef Q_OS_ANDROID | |
113 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
114 | #else |
|
113 | #else | |
115 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
116 | #endif |
|
115 | #endif | |
117 | } |
|
116 | } | |
118 |
|
117 | |||
119 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
118 | void QmlApplicationViewer::addImportPath(const QString &path) | |
120 | { |
|
119 | { | |
121 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); |
|
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
122 | } |
|
121 | } | |
123 |
|
122 | |||
124 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
125 | { |
|
124 | { | |
126 | #if QT_VERSION < 0x050000 |
|
125 | #if QT_VERSION < 0x050000 | |
127 | Qt::WidgetAttribute attribute; |
|
126 | Qt::WidgetAttribute attribute; | |
128 | switch (orientation) { |
|
127 | switch (orientation) { | |
129 | #if QT_VERSION < 0x040702 |
|
128 | #if QT_VERSION < 0x040702 | |
130 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
131 | case ScreenOrientationLockPortrait: |
|
130 | case ScreenOrientationLockPortrait: | |
132 | attribute = static_cast<Qt::WidgetAttribute>(128); |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
133 | break; |
|
132 | break; | |
134 | case ScreenOrientationLockLandscape: |
|
133 | case ScreenOrientationLockLandscape: | |
135 | attribute = static_cast<Qt::WidgetAttribute>(129); |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
136 | break; |
|
135 | break; | |
137 | default: |
|
136 | default: | |
138 | case ScreenOrientationAuto: |
|
137 | case ScreenOrientationAuto: | |
139 | attribute = static_cast<Qt::WidgetAttribute>(130); |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
140 | break; |
|
139 | break; | |
141 | #else // QT_VERSION < 0x040702 |
|
140 | #else // QT_VERSION < 0x040702 | |
142 | case ScreenOrientationLockPortrait: |
|
141 | case ScreenOrientationLockPortrait: | |
143 | attribute = Qt::WA_LockPortraitOrientation; |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
144 | break; |
|
143 | break; | |
145 | case ScreenOrientationLockLandscape: |
|
144 | case ScreenOrientationLockLandscape: | |
146 | attribute = Qt::WA_LockLandscapeOrientation; |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
147 | break; |
|
146 | break; | |
148 | default: |
|
147 | default: | |
149 | case ScreenOrientationAuto: |
|
148 | case ScreenOrientationAuto: | |
150 | attribute = Qt::WA_AutoOrientation; |
|
149 | attribute = Qt::WA_AutoOrientation; | |
151 | break; |
|
150 | break; | |
152 | #endif // QT_VERSION < 0x040702 |
|
151 | #endif // QT_VERSION < 0x040702 | |
153 | }; |
|
152 | }; | |
154 | setAttribute(attribute, true); |
|
153 | setAttribute(attribute, true); | |
155 | #else // QT_VERSION < 0x050000 |
|
154 | #else // QT_VERSION < 0x050000 | |
156 | Q_UNUSED(orientation) |
|
155 | Q_UNUSED(orientation) | |
157 | #endif // QT_VERSION < 0x050000 |
|
156 | #endif // QT_VERSION < 0x050000 | |
158 | } |
|
157 | } | |
159 |
|
158 | |||
160 | void QmlApplicationViewer::showExpanded() |
|
159 | void QmlApplicationViewer::showExpanded() | |
161 | { |
|
160 | { | |
162 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
163 | showFullScreen(); |
|
162 | showFullScreen(); | |
164 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
165 | showMaximized(); |
|
164 | showMaximized(); | |
166 | #else |
|
165 | #else | |
167 | show(); |
|
166 | show(); | |
168 | #endif |
|
167 | #endif | |
169 | } |
|
168 | } | |
170 |
|
169 | |||
171 | QApplication *createApplication(int &argc, char **argv) |
|
170 | QApplication *createApplication(int &argc, char **argv) | |
172 | { |
|
171 | { | |
173 | #ifdef HARMATTAN_BOOSTER |
|
172 | #ifdef HARMATTAN_BOOSTER | |
174 | return MDeclarativeCache::qApplication(argc, argv); |
|
173 | return MDeclarativeCache::qApplication(argc, argv); | |
175 | #else |
|
174 | #else | |
176 | return new QApplication(argc, argv); |
|
175 | return new QApplication(argc, argv); | |
177 | #endif |
|
176 | #endif | |
178 | } |
|
177 | } |
@@ -1,36 +1,37 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QApplication> |
|
21 | #include <QApplication> | |
22 | #include <QDeclarativeEngine> |
|
22 | #include <QDeclarativeEngine> | |
23 | #include "qmlapplicationviewer.h" |
|
23 | #include "qmlapplicationviewer.h" | |
24 |
|
24 | |||
25 | Q_DECL_EXPORT int main(int argc, char *argv[]) |
|
25 | Q_DECL_EXPORT int main(int argc, char *argv[]) | |
26 | { |
|
26 | { | |
27 | QScopedPointer<QApplication> app(createApplication(argc, argv)); |
|
27 | QScopedPointer<QApplication> app(createApplication(argc, argv)); | |
28 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); |
|
28 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); | |
|
29 | viewer->addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); | |||
29 |
|
30 | |||
30 | // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); |
|
31 | // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); | |
31 | viewer->setSource(QUrl("qrc:/qml/qmlchartproperties/loader.qml")); |
|
32 | viewer->setSource(QUrl("qrc:/qml/qmlchartproperties/loader.qml")); | |
32 | viewer->setRenderHint(QPainter::Antialiasing, true); |
|
33 | viewer->setRenderHint(QPainter::Antialiasing, true); | |
33 | viewer->showExpanded(); |
|
34 | viewer->showExpanded(); | |
34 |
|
35 | |||
35 | return app->exec(); |
|
36 | return app->exec(); | |
36 | } |
|
37 | } |
@@ -1,178 +1,177 | |||||
1 | // checksum 0xbd34 version 0x80016 |
|
1 | // checksum 0xbd34 version 0x80016 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |
4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #include "qmlapplicationviewer.h" |
|
11 | #include "qmlapplicationviewer.h" | |
12 |
|
12 | |||
13 | #include <QDir> |
|
13 | #include <QDir> | |
14 | #include <QFileInfo> |
|
14 | #include <QFileInfo> | |
15 | #include <QApplication> |
|
15 | #include <QApplication> | |
16 | #include <QDeclarativeComponent> |
|
16 | #include <QDeclarativeComponent> | |
17 | #include <QDeclarativeEngine> |
|
17 | #include <QDeclarativeEngine> | |
18 | #include <QDeclarativeContext> |
|
18 | #include <QDeclarativeContext> | |
19 |
|
19 | |||
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |
21 |
|
21 | |||
22 | #ifdef HARMATTAN_BOOSTER |
|
22 | #ifdef HARMATTAN_BOOSTER | |
23 | #include <MDeclarativeCache> |
|
23 | #include <MDeclarativeCache> | |
24 | #endif |
|
24 | #endif | |
25 |
|
25 | |||
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
27 |
|
27 | |||
28 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |
29 |
|
29 | |||
30 | #if !defined(NO_JSDEBUGGER) |
|
30 | #if !defined(NO_JSDEBUGGER) | |
31 | #include <jsdebuggeragent.h> |
|
31 | #include <jsdebuggeragent.h> | |
32 | #endif |
|
32 | #endif | |
33 | #if !defined(NO_QMLOBSERVER) |
|
33 | #if !defined(NO_QMLOBSERVER) | |
34 | #include <qdeclarativeviewobserver.h> |
|
34 | #include <qdeclarativeviewobserver.h> | |
35 | #endif |
|
35 | #endif | |
36 |
|
36 | |||
37 | // Enable debugging before any QDeclarativeEngine is created |
|
37 | // Enable debugging before any QDeclarativeEngine is created | |
38 | struct QmlJsDebuggingEnabler |
|
38 | struct QmlJsDebuggingEnabler | |
39 | { |
|
39 | { | |
40 | QmlJsDebuggingEnabler() |
|
40 | QmlJsDebuggingEnabler() | |
41 | { |
|
41 | { | |
42 | QDeclarativeDebugHelper::enableDebugging(); |
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |
43 | } |
|
43 | } | |
44 | }; |
|
44 | }; | |
45 |
|
45 | |||
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |
48 |
|
48 | |||
49 | #endif // QMLJSDEBUGGER |
|
49 | #endif // QMLJSDEBUGGER | |
50 |
|
50 | |||
51 | class QmlApplicationViewerPrivate |
|
51 | class QmlApplicationViewerPrivate | |
52 | { |
|
52 | { | |
53 | QString mainQmlFile; |
|
53 | QString mainQmlFile; | |
54 | friend class QmlApplicationViewer; |
|
54 | friend class QmlApplicationViewer; | |
55 | static QString adjustPath(const QString &path); |
|
55 | static QString adjustPath(const QString &path); | |
56 | }; |
|
56 | }; | |
57 |
|
57 | |||
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
58 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |
59 | { |
|
59 | { | |
60 | #ifdef Q_OS_MAC |
|
60 | #ifdef Q_OS_MAC | |
61 | if (!QDir::isAbsolutePath(path)) |
|
61 | if (!QDir::isAbsolutePath(path)) | |
62 | return QString::fromLatin1("%1/../Resources/%2") |
|
62 | return QString::fromLatin1("%1/../Resources/%2") | |
63 | .arg(QCoreApplication::applicationDirPath(), path); |
|
63 | .arg(QCoreApplication::applicationDirPath(), path); | |
64 | #elif defined(Q_OS_QNX) |
|
64 | #elif defined(Q_OS_QNX) | |
65 | if (!QDir::isAbsolutePath(path)) |
|
65 | if (!QDir::isAbsolutePath(path)) | |
66 | return QString::fromLatin1("app/native/%1").arg(path); |
|
66 | return QString::fromLatin1("app/native/%1").arg(path); | |
67 | #elif !defined(Q_OS_ANDROID) |
|
67 | #elif !defined(Q_OS_ANDROID) | |
68 | QString pathInInstallDir = |
|
68 | QString pathInInstallDir = | |
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); |
|
69 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
70 | if (QFileInfo(pathInInstallDir).exists()) |
|
70 | if (QFileInfo(pathInInstallDir).exists()) | |
71 | return pathInInstallDir; |
|
71 | return pathInInstallDir; | |
72 | pathInInstallDir = |
|
72 | pathInInstallDir = | |
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); |
|
73 | QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); | |
74 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | if (QFileInfo(pathInInstallDir).exists()) | |
75 | return pathInInstallDir; |
|
75 | return pathInInstallDir; | |
76 | #endif |
|
76 | #endif | |
77 | return path; |
|
77 | return path; | |
78 | } |
|
78 | } | |
79 |
|
79 | |||
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |
81 | : QDeclarativeView(parent) |
|
81 | : QDeclarativeView(parent) | |
82 | , d(new QmlApplicationViewerPrivate()) |
|
82 | , d(new QmlApplicationViewerPrivate()) | |
83 | { |
|
83 | { | |
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |
86 |
|
86 | |||
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
87 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
88 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |
89 | #if !defined(NO_JSDEBUGGER) |
|
89 | #if !defined(NO_JSDEBUGGER) | |
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); |
|
90 | new QmlJSDebugger::JSDebuggerAgent(engine()); | |
91 | #endif |
|
91 | #endif | |
92 | #if !defined(NO_QMLOBSERVER) |
|
92 | #if !defined(NO_QMLOBSERVER) | |
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); |
|
93 | new QmlJSDebugger::QDeclarativeViewObserver(this, this); | |
94 | #endif |
|
94 | #endif | |
95 | #endif |
|
95 | #endif | |
96 | addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports"))); |
|
|||
97 | } |
|
96 | } | |
98 |
|
97 | |||
99 | QmlApplicationViewer::~QmlApplicationViewer() |
|
98 | QmlApplicationViewer::~QmlApplicationViewer() | |
100 | { |
|
99 | { | |
101 | delete d; |
|
100 | delete d; | |
102 | } |
|
101 | } | |
103 |
|
102 | |||
104 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
103 | QmlApplicationViewer *QmlApplicationViewer::create() | |
105 | { |
|
104 | { | |
106 | return new QmlApplicationViewer(); |
|
105 | return new QmlApplicationViewer(); | |
107 | } |
|
106 | } | |
108 |
|
107 | |||
109 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
108 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |
110 | { |
|
109 | { | |
111 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); |
|
110 | d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); | |
112 | #ifdef Q_OS_ANDROID |
|
111 | #ifdef Q_OS_ANDROID | |
113 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); |
|
112 | setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); | |
114 | #else |
|
113 | #else | |
115 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
114 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
116 | #endif |
|
115 | #endif | |
117 | } |
|
116 | } | |
118 |
|
117 | |||
119 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
118 | void QmlApplicationViewer::addImportPath(const QString &path) | |
120 | { |
|
119 | { | |
121 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); |
|
120 | engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); | |
122 | } |
|
121 | } | |
123 |
|
122 | |||
124 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
123 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |
125 | { |
|
124 | { | |
126 | #if QT_VERSION < 0x050000 |
|
125 | #if QT_VERSION < 0x050000 | |
127 | Qt::WidgetAttribute attribute; |
|
126 | Qt::WidgetAttribute attribute; | |
128 | switch (orientation) { |
|
127 | switch (orientation) { | |
129 | #if QT_VERSION < 0x040702 |
|
128 | #if QT_VERSION < 0x040702 | |
130 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
129 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |
131 | case ScreenOrientationLockPortrait: |
|
130 | case ScreenOrientationLockPortrait: | |
132 | attribute = static_cast<Qt::WidgetAttribute>(128); |
|
131 | attribute = static_cast<Qt::WidgetAttribute>(128); | |
133 | break; |
|
132 | break; | |
134 | case ScreenOrientationLockLandscape: |
|
133 | case ScreenOrientationLockLandscape: | |
135 | attribute = static_cast<Qt::WidgetAttribute>(129); |
|
134 | attribute = static_cast<Qt::WidgetAttribute>(129); | |
136 | break; |
|
135 | break; | |
137 | default: |
|
136 | default: | |
138 | case ScreenOrientationAuto: |
|
137 | case ScreenOrientationAuto: | |
139 | attribute = static_cast<Qt::WidgetAttribute>(130); |
|
138 | attribute = static_cast<Qt::WidgetAttribute>(130); | |
140 | break; |
|
139 | break; | |
141 | #else // QT_VERSION < 0x040702 |
|
140 | #else // QT_VERSION < 0x040702 | |
142 | case ScreenOrientationLockPortrait: |
|
141 | case ScreenOrientationLockPortrait: | |
143 | attribute = Qt::WA_LockPortraitOrientation; |
|
142 | attribute = Qt::WA_LockPortraitOrientation; | |
144 | break; |
|
143 | break; | |
145 | case ScreenOrientationLockLandscape: |
|
144 | case ScreenOrientationLockLandscape: | |
146 | attribute = Qt::WA_LockLandscapeOrientation; |
|
145 | attribute = Qt::WA_LockLandscapeOrientation; | |
147 | break; |
|
146 | break; | |
148 | default: |
|
147 | default: | |
149 | case ScreenOrientationAuto: |
|
148 | case ScreenOrientationAuto: | |
150 | attribute = Qt::WA_AutoOrientation; |
|
149 | attribute = Qt::WA_AutoOrientation; | |
151 | break; |
|
150 | break; | |
152 | #endif // QT_VERSION < 0x040702 |
|
151 | #endif // QT_VERSION < 0x040702 | |
153 | }; |
|
152 | }; | |
154 | setAttribute(attribute, true); |
|
153 | setAttribute(attribute, true); | |
155 | #else // QT_VERSION < 0x050000 |
|
154 | #else // QT_VERSION < 0x050000 | |
156 | Q_UNUSED(orientation) |
|
155 | Q_UNUSED(orientation) | |
157 | #endif // QT_VERSION < 0x050000 |
|
156 | #endif // QT_VERSION < 0x050000 | |
158 | } |
|
157 | } | |
159 |
|
158 | |||
160 | void QmlApplicationViewer::showExpanded() |
|
159 | void QmlApplicationViewer::showExpanded() | |
161 | { |
|
160 | { | |
162 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
161 | #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |
163 | showFullScreen(); |
|
162 | showFullScreen(); | |
164 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) |
|
163 | #elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) | |
165 | showMaximized(); |
|
164 | showMaximized(); | |
166 | #else |
|
165 | #else | |
167 | show(); |
|
166 | show(); | |
168 | #endif |
|
167 | #endif | |
169 | } |
|
168 | } | |
170 |
|
169 | |||
171 | QApplication *createApplication(int &argc, char **argv) |
|
170 | QApplication *createApplication(int &argc, char **argv) | |
172 | { |
|
171 | { | |
173 | #ifdef HARMATTAN_BOOSTER |
|
172 | #ifdef HARMATTAN_BOOSTER | |
174 | return MDeclarativeCache::qApplication(argc, argv); |
|
173 | return MDeclarativeCache::qApplication(argc, argv); | |
175 | #else |
|
174 | #else | |
176 | return new QApplication(argc, argv); |
|
175 | return new QApplication(argc, argv); | |
177 | #endif |
|
176 | #endif | |
178 | } |
|
177 | } |
@@ -1,34 +1,35 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QtWidgets/QApplication> |
|
21 | #include <QtWidgets/QApplication> | |
22 | #include <QtQuick/QQuickItem> |
|
22 | #include <QtQuick/QQuickItem> | |
23 | #include "qtquick2applicationviewer.h" |
|
23 | #include "qtquick2applicationviewer.h" | |
24 |
|
24 | |||
25 | int main(int argc, char *argv[]) |
|
25 | int main(int argc, char *argv[]) | |
26 | { |
|
26 | { | |
27 | QApplication app(argc, argv); |
|
27 | QApplication app(argc, argv); | |
28 |
|
28 | |||
29 | QtQuick2ApplicationViewer viewer; |
|
29 | QtQuick2ApplicationViewer viewer; | |
|
30 | viewer.addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QString::fromLatin1("qml"))); | |||
30 | viewer.setSource(QUrl("qrc:/qml/quick2chartproperties/main.qml")); |
|
31 | viewer.setSource(QUrl("qrc:/qml/quick2chartproperties/main.qml")); | |
31 | viewer.showExpanded(); |
|
32 | viewer.showExpanded(); | |
32 |
|
33 | |||
33 | return app.exec(); |
|
34 | return app.exec(); | |
34 | } |
|
35 | } |
@@ -1,71 +1,70 | |||||
1 | // checksum 0x56a9 version 0x80001 |
|
1 | // checksum 0x56a9 version 0x80001 | |
2 | /* |
|
2 | /* | |
3 | This file was generated by the Qt Quick 2 Application wizard of Qt Creator. |
|
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 |
|
4 | QtQuick2ApplicationViewer is a convenience class containing mobile device specific | |
5 | code such as screen orientation handling. Also QML paths and debugging are |
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |
6 | handled here. |
|
6 | handled here. | |
7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |
8 | may offer an updated version of it. |
|
8 | may offer an updated version of it. | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | #include "qtquick2applicationviewer.h" |
|
11 | #include "qtquick2applicationviewer.h" | |
12 |
|
12 | |||
13 | #include <QtCore/QCoreApplication> |
|
13 | #include <QtCore/QCoreApplication> | |
14 | #include <QtCore/QDir> |
|
14 | #include <QtCore/QDir> | |
15 | #include <QtQml/QQmlEngine> |
|
15 | #include <QtQml/QQmlEngine> | |
16 |
|
16 | |||
17 | class QtQuick2ApplicationViewerPrivate |
|
17 | class QtQuick2ApplicationViewerPrivate | |
18 | { |
|
18 | { | |
19 | QString mainQmlFile; |
|
19 | QString mainQmlFile; | |
20 | friend class QtQuick2ApplicationViewer; |
|
20 | friend class QtQuick2ApplicationViewer; | |
21 | static QString adjustPath(const QString &path); |
|
21 | static QString adjustPath(const QString &path); | |
22 | }; |
|
22 | }; | |
23 |
|
23 | |||
24 | QString QtQuick2ApplicationViewerPrivate::adjustPath(const QString &path) |
|
24 | QString QtQuick2ApplicationViewerPrivate::adjustPath(const QString &path) | |
25 | { |
|
25 | { | |
26 | #if defined(Q_OS_MAC) |
|
26 | #if defined(Q_OS_MAC) | |
27 | if (!QDir::isAbsolutePath(path)) |
|
27 | if (!QDir::isAbsolutePath(path)) | |
28 | return QString::fromLatin1("%1/../Resources/%2") |
|
28 | return QString::fromLatin1("%1/../Resources/%2") | |
29 | .arg(QCoreApplication::applicationDirPath(), path); |
|
29 | .arg(QCoreApplication::applicationDirPath(), path); | |
30 | #elif defined(Q_OS_UNIX) |
|
30 | #elif defined(Q_OS_UNIX) | |
31 | const QString pathInInstallDir = |
|
31 | const QString pathInInstallDir = | |
32 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); |
|
32 | QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); | |
33 | if (QFileInfo(pathInInstallDir).exists()) |
|
33 | if (QFileInfo(pathInInstallDir).exists()) | |
34 | return pathInInstallDir; |
|
34 | return pathInInstallDir; | |
35 | #endif |
|
35 | #endif | |
36 | return path; |
|
36 | return path; | |
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 | QtQuick2ApplicationViewer::QtQuick2ApplicationViewer(QWindow *parent) |
|
39 | QtQuick2ApplicationViewer::QtQuick2ApplicationViewer(QWindow *parent) | |
40 | : QQuickView(parent) |
|
40 | : QQuickView(parent) | |
41 | , d(new QtQuick2ApplicationViewerPrivate()) |
|
41 | , d(new QtQuick2ApplicationViewerPrivate()) | |
42 | { |
|
42 | { | |
43 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
43 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |
44 | setResizeMode(QQuickView::SizeRootObjectToView); |
|
44 | setResizeMode(QQuickView::SizeRootObjectToView); | |
45 | addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QString::fromLatin1("qml"))); |
|
|||
46 | } |
|
45 | } | |
47 |
|
46 | |||
48 | QtQuick2ApplicationViewer::~QtQuick2ApplicationViewer() |
|
47 | QtQuick2ApplicationViewer::~QtQuick2ApplicationViewer() | |
49 | { |
|
48 | { | |
50 | delete d; |
|
49 | delete d; | |
51 | } |
|
50 | } | |
52 |
|
51 | |||
53 | void QtQuick2ApplicationViewer::setMainQmlFile(const QString &file) |
|
52 | void QtQuick2ApplicationViewer::setMainQmlFile(const QString &file) | |
54 | { |
|
53 | { | |
55 | d->mainQmlFile = QtQuick2ApplicationViewerPrivate::adjustPath(file); |
|
54 | d->mainQmlFile = QtQuick2ApplicationViewerPrivate::adjustPath(file); | |
56 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
55 | setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |
57 | } |
|
56 | } | |
58 |
|
57 | |||
59 | void QtQuick2ApplicationViewer::addImportPath(const QString &path) |
|
58 | void QtQuick2ApplicationViewer::addImportPath(const QString &path) | |
60 | { |
|
59 | { | |
61 | engine()->addImportPath(QtQuick2ApplicationViewerPrivate::adjustPath(path)); |
|
60 | engine()->addImportPath(QtQuick2ApplicationViewerPrivate::adjustPath(path)); | |
62 | } |
|
61 | } | |
63 |
|
62 | |||
64 | void QtQuick2ApplicationViewer::showExpanded() |
|
63 | void QtQuick2ApplicationViewer::showExpanded() | |
65 | { |
|
64 | { | |
66 | #if defined(Q_WS_SIMULATOR) |
|
65 | #if defined(Q_WS_SIMULATOR) | |
67 | showFullScreen(); |
|
66 | showFullScreen(); | |
68 | #else |
|
67 | #else | |
69 | show(); |
|
68 | show(); | |
70 | #endif |
|
69 | #endif | |
71 | } |
|
70 | } |
General Comments 0
You need to be logged in to leave comments.
Login now