@@ -1,34 +1,34 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "mainwidget.h" |
|
22 |
#include <Q |
|
|
22 | #include <QApplication> | |
|
23 | 23 | #include <QMainWindow> |
|
24 | 24 | |
|
25 | 25 | int main(int argc, char *argv[]) |
|
26 | 26 | { |
|
27 | 27 | QApplication a(argc, argv); |
|
28 | 28 | QMainWindow window; |
|
29 | 29 | MainWidget widget; |
|
30 | 30 | window.setCentralWidget(&widget); |
|
31 | 31 | window.resize(900, 600); |
|
32 | 32 | window.show(); |
|
33 | 33 | return a.exec(); |
|
34 | 34 | } |
@@ -1,36 +1,36 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 |
#include <Q |
|
|
21 | #include <QApplication> | |
|
22 | 22 | #include <QDeclarativeEngine> |
|
23 | 23 | #include "qmlapplicationviewer.h" |
|
24 | 24 | |
|
25 | 25 | Q_DECL_EXPORT int main(int argc, char *argv[]) |
|
26 | 26 | { |
|
27 | 27 | QScopedPointer<QApplication> app(createApplication(argc, argv)); |
|
28 | 28 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); |
|
29 | 29 | |
|
30 | 30 | viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); |
|
31 | 31 | viewer->setSource(QUrl("qrc:/qml/qmlaxes/loader.qml")); |
|
32 | 32 | viewer->setRenderHint(QPainter::Antialiasing, true); |
|
33 | 33 | viewer->showExpanded(); |
|
34 | 34 | |
|
35 | 35 | return app->exec(); |
|
36 | 36 | } |
@@ -1,200 +1,200 | |||
|
1 | 1 | // checksum 0x78c version 0x60010 |
|
2 | 2 | /* |
|
3 | 3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
4 | 4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
5 | 5 | code such as screen orientation handling. Also QML paths and debugging are |
|
6 | 6 | handled here. |
|
7 | 7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
8 | 8 | may offer an updated version of it. |
|
9 | 9 | */ |
|
10 | 10 | |
|
11 | 11 | #include "qmlapplicationviewer.h" |
|
12 | 12 | |
|
13 | 13 | #include <QtCore/QDir> |
|
14 | 14 | #include <QtCore/QFileInfo> |
|
15 | 15 | #include <QtDeclarative/QDeclarativeComponent> |
|
16 | 16 | #include <QtDeclarative/QDeclarativeEngine> |
|
17 | 17 | #include <QtDeclarative/QDeclarativeContext> |
|
18 |
#include <Q |
|
|
18 | #include <QApplication> | |
|
19 | 19 | |
|
20 | 20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
21 | 21 | |
|
22 | 22 | #ifdef HARMATTAN_BOOSTER |
|
23 | 23 | #include <MDeclarativeCache> |
|
24 | 24 | #endif |
|
25 | 25 | |
|
26 | 26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
27 | 27 | |
|
28 | 28 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
29 | 29 | |
|
30 | 30 | #if !defined(NO_JSDEBUGGER) |
|
31 | 31 | #include <jsdebuggeragent.h> |
|
32 | 32 | #endif |
|
33 | 33 | #if !defined(NO_QMLOBSERVER) |
|
34 | 34 | #include <qdeclarativeviewobserver.h> |
|
35 | 35 | #endif |
|
36 | 36 | |
|
37 | 37 | // Enable debugging before any QDeclarativeEngine is created |
|
38 | 38 | struct QmlJsDebuggingEnabler |
|
39 | 39 | { |
|
40 | 40 | QmlJsDebuggingEnabler() |
|
41 | 41 | { |
|
42 | 42 | QDeclarativeDebugHelper::enableDebugging(); |
|
43 | 43 | } |
|
44 | 44 | }; |
|
45 | 45 | |
|
46 | 46 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
47 | 47 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
48 | 48 | |
|
49 | 49 | #endif // QMLJSDEBUGGER |
|
50 | 50 | |
|
51 | 51 | class QmlApplicationViewerPrivate |
|
52 | 52 | { |
|
53 | 53 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} |
|
54 | 54 | |
|
55 | 55 | QString mainQmlFile; |
|
56 | 56 | QDeclarativeView *view; |
|
57 | 57 | friend class QmlApplicationViewer; |
|
58 | 58 | QString adjustPath(const QString &path); |
|
59 | 59 | }; |
|
60 | 60 | |
|
61 | 61 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
62 | 62 | { |
|
63 | 63 | #ifdef Q_OS_UNIX |
|
64 | 64 | #ifdef Q_OS_MAC |
|
65 | 65 | if (!QDir::isAbsolutePath(path)) |
|
66 | 66 | return QCoreApplication::applicationDirPath() |
|
67 | 67 | + QLatin1String("/../Resources/") + path; |
|
68 | 68 | #else |
|
69 | 69 | QString pathInInstallDir; |
|
70 | 70 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); |
|
71 | 71 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); |
|
72 | 72 | |
|
73 | 73 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | 74 | return pathInInstallDir; |
|
75 | 75 | #endif |
|
76 | 76 | #endif |
|
77 | 77 | return path; |
|
78 | 78 | } |
|
79 | 79 | |
|
80 | 80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
81 | 81 | : QDeclarativeView(parent) |
|
82 | 82 | , d(new QmlApplicationViewerPrivate(this)) |
|
83 | 83 | { |
|
84 | 84 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
85 | 85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
86 | 86 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
87 | 87 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
88 | 88 | #if !defined(NO_JSDEBUGGER) |
|
89 | 89 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
90 | 90 | #endif |
|
91 | 91 | #if !defined(NO_QMLOBSERVER) |
|
92 | 92 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
93 | 93 | #endif |
|
94 | 94 | #endif |
|
95 | 95 | } |
|
96 | 96 | |
|
97 | 97 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) |
|
98 | 98 | : QDeclarativeView(parent) |
|
99 | 99 | , d(new QmlApplicationViewerPrivate(view)) |
|
100 | 100 | { |
|
101 | 101 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); |
|
102 | 102 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
103 | 103 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
104 | 104 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
105 | 105 | #if !defined(NO_JSDEBUGGER) |
|
106 | 106 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
107 | 107 | #endif |
|
108 | 108 | #if !defined(NO_QMLOBSERVER) |
|
109 | 109 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
110 | 110 | #endif |
|
111 | 111 | #endif |
|
112 | 112 | } |
|
113 | 113 | |
|
114 | 114 | QmlApplicationViewer::~QmlApplicationViewer() |
|
115 | 115 | { |
|
116 | 116 | delete d; |
|
117 | 117 | } |
|
118 | 118 | |
|
119 | 119 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
120 | 120 | { |
|
121 | 121 | #ifdef HARMATTAN_BOOSTER |
|
122 | 122 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); |
|
123 | 123 | #else |
|
124 | 124 | return new QmlApplicationViewer(); |
|
125 | 125 | #endif |
|
126 | 126 | } |
|
127 | 127 | |
|
128 | 128 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
129 | 129 | { |
|
130 | 130 | d->mainQmlFile = d->adjustPath(file); |
|
131 | 131 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
132 | 132 | } |
|
133 | 133 | |
|
134 | 134 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
135 | 135 | { |
|
136 | 136 | d->view->engine()->addImportPath(d->adjustPath(path)); |
|
137 | 137 | } |
|
138 | 138 | |
|
139 | 139 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
140 | 140 | { |
|
141 | 141 | #if defined(Q_OS_SYMBIAN) |
|
142 | 142 | // If the version of Qt on the device is < 4.7.2, that attribute won't work |
|
143 | 143 | if (orientation != ScreenOrientationAuto) { |
|
144 | 144 | const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); |
|
145 | 145 | if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { |
|
146 | 146 | qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); |
|
147 | 147 | return; |
|
148 | 148 | } |
|
149 | 149 | } |
|
150 | 150 | #endif // Q_OS_SYMBIAN |
|
151 | 151 | |
|
152 | 152 | Qt::WidgetAttribute attribute; |
|
153 | 153 | switch (orientation) { |
|
154 | 154 | #if QT_VERSION < 0x040702 |
|
155 | 155 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
156 | 156 | case ScreenOrientationLockPortrait: |
|
157 | 157 | attribute = static_cast<Qt::WidgetAttribute>(128); |
|
158 | 158 | break; |
|
159 | 159 | case ScreenOrientationLockLandscape: |
|
160 | 160 | attribute = static_cast<Qt::WidgetAttribute>(129); |
|
161 | 161 | break; |
|
162 | 162 | default: |
|
163 | 163 | case ScreenOrientationAuto: |
|
164 | 164 | attribute = static_cast<Qt::WidgetAttribute>(130); |
|
165 | 165 | break; |
|
166 | 166 | #else // QT_VERSION < 0x040702 |
|
167 | 167 | case ScreenOrientationLockPortrait: |
|
168 | 168 | attribute = Qt::WA_LockPortraitOrientation; |
|
169 | 169 | break; |
|
170 | 170 | case ScreenOrientationLockLandscape: |
|
171 | 171 | attribute = Qt::WA_LockLandscapeOrientation; |
|
172 | 172 | break; |
|
173 | 173 | default: |
|
174 | 174 | case ScreenOrientationAuto: |
|
175 | 175 | attribute = Qt::WA_AutoOrientation; |
|
176 | 176 | break; |
|
177 | 177 | #endif // QT_VERSION < 0x040702 |
|
178 | 178 | }; |
|
179 | 179 | setAttribute(attribute, true); |
|
180 | 180 | } |
|
181 | 181 | |
|
182 | 182 | void QmlApplicationViewer::showExpanded() |
|
183 | 183 | { |
|
184 | 184 | #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
185 | 185 | d->view->showFullScreen(); |
|
186 | 186 | #elif defined(Q_WS_MAEMO_5) |
|
187 | 187 | d->view->showMaximized(); |
|
188 | 188 | #else |
|
189 | 189 | d->view->show(); |
|
190 | 190 | #endif |
|
191 | 191 | } |
|
192 | 192 | |
|
193 | 193 | QApplication *createApplication(int &argc, char **argv) |
|
194 | 194 | { |
|
195 | 195 | #ifdef HARMATTAN_BOOSTER |
|
196 | 196 | return MDeclarativeCache::qApplication(argc, argv); |
|
197 | 197 | #else |
|
198 | 198 | return new QApplication(argc, argv); |
|
199 | 199 | #endif |
|
200 | 200 | } |
@@ -1,36 +1,36 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 |
#include <Q |
|
|
21 | #include <QApplication> | |
|
22 | 22 | #include <QDeclarativeEngine> |
|
23 | 23 | #include "qmlapplicationviewer.h" |
|
24 | 24 | |
|
25 | 25 | Q_DECL_EXPORT int main(int argc, char *argv[]) |
|
26 | 26 | { |
|
27 | 27 | QScopedPointer<QApplication> app(createApplication(argc, argv)); |
|
28 | 28 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); |
|
29 | 29 | |
|
30 | 30 | viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); |
|
31 | 31 | viewer->setSource(QUrl("qrc:/qml/qmlchart/loader.qml")); |
|
32 | 32 | viewer->setRenderHint(QPainter::Antialiasing, true); |
|
33 | 33 | viewer->showExpanded(); |
|
34 | 34 | |
|
35 | 35 | return app->exec(); |
|
36 | 36 | } |
@@ -1,200 +1,200 | |||
|
1 | 1 | // checksum 0x78c version 0x60010 |
|
2 | 2 | /* |
|
3 | 3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
4 | 4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
5 | 5 | code such as screen orientation handling. Also QML paths and debugging are |
|
6 | 6 | handled here. |
|
7 | 7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
8 | 8 | may offer an updated version of it. |
|
9 | 9 | */ |
|
10 | 10 | |
|
11 | 11 | #include "qmlapplicationviewer.h" |
|
12 | 12 | |
|
13 | 13 | #include <QtCore/QDir> |
|
14 | 14 | #include <QtCore/QFileInfo> |
|
15 | 15 | #include <QtDeclarative/QDeclarativeComponent> |
|
16 | 16 | #include <QtDeclarative/QDeclarativeEngine> |
|
17 | 17 | #include <QtDeclarative/QDeclarativeContext> |
|
18 |
#include <Q |
|
|
18 | #include <QApplication> | |
|
19 | 19 | |
|
20 | 20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
21 | 21 | |
|
22 | 22 | #ifdef HARMATTAN_BOOSTER |
|
23 | 23 | #include <MDeclarativeCache> |
|
24 | 24 | #endif |
|
25 | 25 | |
|
26 | 26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
27 | 27 | |
|
28 | 28 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
29 | 29 | |
|
30 | 30 | #if !defined(NO_JSDEBUGGER) |
|
31 | 31 | #include <jsdebuggeragent.h> |
|
32 | 32 | #endif |
|
33 | 33 | #if !defined(NO_QMLOBSERVER) |
|
34 | 34 | #include <qdeclarativeviewobserver.h> |
|
35 | 35 | #endif |
|
36 | 36 | |
|
37 | 37 | // Enable debugging before any QDeclarativeEngine is created |
|
38 | 38 | struct QmlJsDebuggingEnabler |
|
39 | 39 | { |
|
40 | 40 | QmlJsDebuggingEnabler() |
|
41 | 41 | { |
|
42 | 42 | QDeclarativeDebugHelper::enableDebugging(); |
|
43 | 43 | } |
|
44 | 44 | }; |
|
45 | 45 | |
|
46 | 46 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
47 | 47 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
48 | 48 | |
|
49 | 49 | #endif // QMLJSDEBUGGER |
|
50 | 50 | |
|
51 | 51 | class QmlApplicationViewerPrivate |
|
52 | 52 | { |
|
53 | 53 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} |
|
54 | 54 | |
|
55 | 55 | QString mainQmlFile; |
|
56 | 56 | QDeclarativeView *view; |
|
57 | 57 | friend class QmlApplicationViewer; |
|
58 | 58 | QString adjustPath(const QString &path); |
|
59 | 59 | }; |
|
60 | 60 | |
|
61 | 61 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
62 | 62 | { |
|
63 | 63 | #ifdef Q_OS_UNIX |
|
64 | 64 | #ifdef Q_OS_MAC |
|
65 | 65 | if (!QDir::isAbsolutePath(path)) |
|
66 | 66 | return QCoreApplication::applicationDirPath() |
|
67 | 67 | + QLatin1String("/../Resources/") + path; |
|
68 | 68 | #else |
|
69 | 69 | QString pathInInstallDir; |
|
70 | 70 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); |
|
71 | 71 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); |
|
72 | 72 | |
|
73 | 73 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | 74 | return pathInInstallDir; |
|
75 | 75 | #endif |
|
76 | 76 | #endif |
|
77 | 77 | return path; |
|
78 | 78 | } |
|
79 | 79 | |
|
80 | 80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
81 | 81 | : QDeclarativeView(parent) |
|
82 | 82 | , d(new QmlApplicationViewerPrivate(this)) |
|
83 | 83 | { |
|
84 | 84 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
85 | 85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
86 | 86 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
87 | 87 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
88 | 88 | #if !defined(NO_JSDEBUGGER) |
|
89 | 89 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
90 | 90 | #endif |
|
91 | 91 | #if !defined(NO_QMLOBSERVER) |
|
92 | 92 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
93 | 93 | #endif |
|
94 | 94 | #endif |
|
95 | 95 | } |
|
96 | 96 | |
|
97 | 97 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) |
|
98 | 98 | : QDeclarativeView(parent) |
|
99 | 99 | , d(new QmlApplicationViewerPrivate(view)) |
|
100 | 100 | { |
|
101 | 101 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); |
|
102 | 102 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
103 | 103 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
104 | 104 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
105 | 105 | #if !defined(NO_JSDEBUGGER) |
|
106 | 106 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
107 | 107 | #endif |
|
108 | 108 | #if !defined(NO_QMLOBSERVER) |
|
109 | 109 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
110 | 110 | #endif |
|
111 | 111 | #endif |
|
112 | 112 | } |
|
113 | 113 | |
|
114 | 114 | QmlApplicationViewer::~QmlApplicationViewer() |
|
115 | 115 | { |
|
116 | 116 | delete d; |
|
117 | 117 | } |
|
118 | 118 | |
|
119 | 119 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
120 | 120 | { |
|
121 | 121 | #ifdef HARMATTAN_BOOSTER |
|
122 | 122 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); |
|
123 | 123 | #else |
|
124 | 124 | return new QmlApplicationViewer(); |
|
125 | 125 | #endif |
|
126 | 126 | } |
|
127 | 127 | |
|
128 | 128 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
129 | 129 | { |
|
130 | 130 | d->mainQmlFile = d->adjustPath(file); |
|
131 | 131 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
132 | 132 | } |
|
133 | 133 | |
|
134 | 134 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
135 | 135 | { |
|
136 | 136 | d->view->engine()->addImportPath(d->adjustPath(path)); |
|
137 | 137 | } |
|
138 | 138 | |
|
139 | 139 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
140 | 140 | { |
|
141 | 141 | #if defined(Q_OS_SYMBIAN) |
|
142 | 142 | // If the version of Qt on the device is < 4.7.2, that attribute won't work |
|
143 | 143 | if (orientation != ScreenOrientationAuto) { |
|
144 | 144 | const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); |
|
145 | 145 | if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { |
|
146 | 146 | qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); |
|
147 | 147 | return; |
|
148 | 148 | } |
|
149 | 149 | } |
|
150 | 150 | #endif // Q_OS_SYMBIAN |
|
151 | 151 | |
|
152 | 152 | Qt::WidgetAttribute attribute; |
|
153 | 153 | switch (orientation) { |
|
154 | 154 | #if QT_VERSION < 0x040702 |
|
155 | 155 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
156 | 156 | case ScreenOrientationLockPortrait: |
|
157 | 157 | attribute = static_cast<Qt::WidgetAttribute>(128); |
|
158 | 158 | break; |
|
159 | 159 | case ScreenOrientationLockLandscape: |
|
160 | 160 | attribute = static_cast<Qt::WidgetAttribute>(129); |
|
161 | 161 | break; |
|
162 | 162 | default: |
|
163 | 163 | case ScreenOrientationAuto: |
|
164 | 164 | attribute = static_cast<Qt::WidgetAttribute>(130); |
|
165 | 165 | break; |
|
166 | 166 | #else // QT_VERSION < 0x040702 |
|
167 | 167 | case ScreenOrientationLockPortrait: |
|
168 | 168 | attribute = Qt::WA_LockPortraitOrientation; |
|
169 | 169 | break; |
|
170 | 170 | case ScreenOrientationLockLandscape: |
|
171 | 171 | attribute = Qt::WA_LockLandscapeOrientation; |
|
172 | 172 | break; |
|
173 | 173 | default: |
|
174 | 174 | case ScreenOrientationAuto: |
|
175 | 175 | attribute = Qt::WA_AutoOrientation; |
|
176 | 176 | break; |
|
177 | 177 | #endif // QT_VERSION < 0x040702 |
|
178 | 178 | }; |
|
179 | 179 | setAttribute(attribute, true); |
|
180 | 180 | } |
|
181 | 181 | |
|
182 | 182 | void QmlApplicationViewer::showExpanded() |
|
183 | 183 | { |
|
184 | 184 | #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
185 | 185 | d->view->showFullScreen(); |
|
186 | 186 | #elif defined(Q_WS_MAEMO_5) |
|
187 | 187 | d->view->showMaximized(); |
|
188 | 188 | #else |
|
189 | 189 | d->view->show(); |
|
190 | 190 | #endif |
|
191 | 191 | } |
|
192 | 192 | |
|
193 | 193 | QApplication *createApplication(int &argc, char **argv) |
|
194 | 194 | { |
|
195 | 195 | #ifdef HARMATTAN_BOOSTER |
|
196 | 196 | return MDeclarativeCache::qApplication(argc, argv); |
|
197 | 197 | #else |
|
198 | 198 | return new QApplication(argc, argv); |
|
199 | 199 | #endif |
|
200 | 200 | } |
@@ -1,36 +1,36 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 |
#include <Q |
|
|
21 | #include <QApplication> | |
|
22 | 22 | #include <QDeclarativeEngine> |
|
23 | 23 | #include "qmlapplicationviewer.h" |
|
24 | 24 | |
|
25 | 25 | Q_DECL_EXPORT int main(int argc, char *argv[]) |
|
26 | 26 | { |
|
27 | 27 | QScopedPointer<QApplication> app(createApplication(argc, argv)); |
|
28 | 28 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); |
|
29 | 29 | |
|
30 | 30 | viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); |
|
31 | 31 | viewer->setSource(QUrl("qrc:/qml/qmlcustomizations/loader.qml")); |
|
32 | 32 | viewer->setRenderHint(QPainter::Antialiasing, true); |
|
33 | 33 | viewer->showExpanded(); |
|
34 | 34 | |
|
35 | 35 | return app->exec(); |
|
36 | 36 | } |
@@ -1,200 +1,200 | |||
|
1 | 1 | // checksum 0x78c version 0x60010 |
|
2 | 2 | /* |
|
3 | 3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
4 | 4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
5 | 5 | code such as screen orientation handling. Also QML paths and debugging are |
|
6 | 6 | handled here. |
|
7 | 7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
8 | 8 | may offer an updated version of it. |
|
9 | 9 | */ |
|
10 | 10 | |
|
11 | 11 | #include "qmlapplicationviewer.h" |
|
12 | 12 | |
|
13 | 13 | #include <QtCore/QDir> |
|
14 | 14 | #include <QtCore/QFileInfo> |
|
15 | 15 | #include <QtDeclarative/QDeclarativeComponent> |
|
16 | 16 | #include <QtDeclarative/QDeclarativeEngine> |
|
17 | 17 | #include <QtDeclarative/QDeclarativeContext> |
|
18 |
#include <Q |
|
|
18 | #include <QApplication> | |
|
19 | 19 | |
|
20 | 20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
21 | 21 | |
|
22 | 22 | #ifdef HARMATTAN_BOOSTER |
|
23 | 23 | #include <MDeclarativeCache> |
|
24 | 24 | #endif |
|
25 | 25 | |
|
26 | 26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
27 | 27 | |
|
28 | 28 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
29 | 29 | |
|
30 | 30 | #if !defined(NO_JSDEBUGGER) |
|
31 | 31 | #include <jsdebuggeragent.h> |
|
32 | 32 | #endif |
|
33 | 33 | #if !defined(NO_QMLOBSERVER) |
|
34 | 34 | #include <qdeclarativeviewobserver.h> |
|
35 | 35 | #endif |
|
36 | 36 | |
|
37 | 37 | // Enable debugging before any QDeclarativeEngine is created |
|
38 | 38 | struct QmlJsDebuggingEnabler |
|
39 | 39 | { |
|
40 | 40 | QmlJsDebuggingEnabler() |
|
41 | 41 | { |
|
42 | 42 | QDeclarativeDebugHelper::enableDebugging(); |
|
43 | 43 | } |
|
44 | 44 | }; |
|
45 | 45 | |
|
46 | 46 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
47 | 47 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
48 | 48 | |
|
49 | 49 | #endif // QMLJSDEBUGGER |
|
50 | 50 | |
|
51 | 51 | class QmlApplicationViewerPrivate |
|
52 | 52 | { |
|
53 | 53 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} |
|
54 | 54 | |
|
55 | 55 | QString mainQmlFile; |
|
56 | 56 | QDeclarativeView *view; |
|
57 | 57 | friend class QmlApplicationViewer; |
|
58 | 58 | QString adjustPath(const QString &path); |
|
59 | 59 | }; |
|
60 | 60 | |
|
61 | 61 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
62 | 62 | { |
|
63 | 63 | #ifdef Q_OS_UNIX |
|
64 | 64 | #ifdef Q_OS_MAC |
|
65 | 65 | if (!QDir::isAbsolutePath(path)) |
|
66 | 66 | return QCoreApplication::applicationDirPath() |
|
67 | 67 | + QLatin1String("/../Resources/") + path; |
|
68 | 68 | #else |
|
69 | 69 | QString pathInInstallDir; |
|
70 | 70 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); |
|
71 | 71 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); |
|
72 | 72 | |
|
73 | 73 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | 74 | return pathInInstallDir; |
|
75 | 75 | #endif |
|
76 | 76 | #endif |
|
77 | 77 | return path; |
|
78 | 78 | } |
|
79 | 79 | |
|
80 | 80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
81 | 81 | : QDeclarativeView(parent) |
|
82 | 82 | , d(new QmlApplicationViewerPrivate(this)) |
|
83 | 83 | { |
|
84 | 84 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
85 | 85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
86 | 86 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
87 | 87 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
88 | 88 | #if !defined(NO_JSDEBUGGER) |
|
89 | 89 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
90 | 90 | #endif |
|
91 | 91 | #if !defined(NO_QMLOBSERVER) |
|
92 | 92 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
93 | 93 | #endif |
|
94 | 94 | #endif |
|
95 | 95 | } |
|
96 | 96 | |
|
97 | 97 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) |
|
98 | 98 | : QDeclarativeView(parent) |
|
99 | 99 | , d(new QmlApplicationViewerPrivate(view)) |
|
100 | 100 | { |
|
101 | 101 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); |
|
102 | 102 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
103 | 103 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
104 | 104 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
105 | 105 | #if !defined(NO_JSDEBUGGER) |
|
106 | 106 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
107 | 107 | #endif |
|
108 | 108 | #if !defined(NO_QMLOBSERVER) |
|
109 | 109 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
110 | 110 | #endif |
|
111 | 111 | #endif |
|
112 | 112 | } |
|
113 | 113 | |
|
114 | 114 | QmlApplicationViewer::~QmlApplicationViewer() |
|
115 | 115 | { |
|
116 | 116 | delete d; |
|
117 | 117 | } |
|
118 | 118 | |
|
119 | 119 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
120 | 120 | { |
|
121 | 121 | #ifdef HARMATTAN_BOOSTER |
|
122 | 122 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); |
|
123 | 123 | #else |
|
124 | 124 | return new QmlApplicationViewer(); |
|
125 | 125 | #endif |
|
126 | 126 | } |
|
127 | 127 | |
|
128 | 128 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
129 | 129 | { |
|
130 | 130 | d->mainQmlFile = d->adjustPath(file); |
|
131 | 131 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
132 | 132 | } |
|
133 | 133 | |
|
134 | 134 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
135 | 135 | { |
|
136 | 136 | d->view->engine()->addImportPath(d->adjustPath(path)); |
|
137 | 137 | } |
|
138 | 138 | |
|
139 | 139 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
140 | 140 | { |
|
141 | 141 | #if defined(Q_OS_SYMBIAN) |
|
142 | 142 | // If the version of Qt on the device is < 4.7.2, that attribute won't work |
|
143 | 143 | if (orientation != ScreenOrientationAuto) { |
|
144 | 144 | const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); |
|
145 | 145 | if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { |
|
146 | 146 | qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); |
|
147 | 147 | return; |
|
148 | 148 | } |
|
149 | 149 | } |
|
150 | 150 | #endif // Q_OS_SYMBIAN |
|
151 | 151 | |
|
152 | 152 | Qt::WidgetAttribute attribute; |
|
153 | 153 | switch (orientation) { |
|
154 | 154 | #if QT_VERSION < 0x040702 |
|
155 | 155 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
156 | 156 | case ScreenOrientationLockPortrait: |
|
157 | 157 | attribute = static_cast<Qt::WidgetAttribute>(128); |
|
158 | 158 | break; |
|
159 | 159 | case ScreenOrientationLockLandscape: |
|
160 | 160 | attribute = static_cast<Qt::WidgetAttribute>(129); |
|
161 | 161 | break; |
|
162 | 162 | default: |
|
163 | 163 | case ScreenOrientationAuto: |
|
164 | 164 | attribute = static_cast<Qt::WidgetAttribute>(130); |
|
165 | 165 | break; |
|
166 | 166 | #else // QT_VERSION < 0x040702 |
|
167 | 167 | case ScreenOrientationLockPortrait: |
|
168 | 168 | attribute = Qt::WA_LockPortraitOrientation; |
|
169 | 169 | break; |
|
170 | 170 | case ScreenOrientationLockLandscape: |
|
171 | 171 | attribute = Qt::WA_LockLandscapeOrientation; |
|
172 | 172 | break; |
|
173 | 173 | default: |
|
174 | 174 | case ScreenOrientationAuto: |
|
175 | 175 | attribute = Qt::WA_AutoOrientation; |
|
176 | 176 | break; |
|
177 | 177 | #endif // QT_VERSION < 0x040702 |
|
178 | 178 | }; |
|
179 | 179 | setAttribute(attribute, true); |
|
180 | 180 | } |
|
181 | 181 | |
|
182 | 182 | void QmlApplicationViewer::showExpanded() |
|
183 | 183 | { |
|
184 | 184 | #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
185 | 185 | d->view->showFullScreen(); |
|
186 | 186 | #elif defined(Q_WS_MAEMO_5) |
|
187 | 187 | d->view->showMaximized(); |
|
188 | 188 | #else |
|
189 | 189 | d->view->show(); |
|
190 | 190 | #endif |
|
191 | 191 | } |
|
192 | 192 | |
|
193 | 193 | QApplication *createApplication(int &argc, char **argv) |
|
194 | 194 | { |
|
195 | 195 | #ifdef HARMATTAN_BOOSTER |
|
196 | 196 | return MDeclarativeCache::qApplication(argc, argv); |
|
197 | 197 | #else |
|
198 | 198 | return new QApplication(argc, argv); |
|
199 | 199 | #endif |
|
200 | 200 | } |
@@ -1,48 +1,48 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 |
#include <Q |
|
|
21 | #include <QApplication> | |
|
22 | 22 | #include <QDeclarativeEngine> |
|
23 | 23 | #include <QtDeclarative> |
|
24 | 24 | #include <QAbstractItemModel> |
|
25 | 25 | #include "declarativemodel.h" |
|
26 | 26 | #include "customtablemodel.h" |
|
27 | 27 | #include "qmlapplicationviewer.h" |
|
28 | 28 | |
|
29 | 29 | const char *uri = "QmlCustomModel"; |
|
30 | 30 | |
|
31 | 31 | Q_DECL_EXPORT int main(int argc, char *argv[]) |
|
32 | 32 | { |
|
33 | 33 | QScopedPointer<QApplication> app(createApplication(argc, argv)); |
|
34 | 34 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); |
|
35 | 35 | |
|
36 | 36 | // @uri QmlCustomModel |
|
37 | 37 | qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel", |
|
38 | 38 | QLatin1String("Trying to create uncreatable: AbstractItemModel.")); |
|
39 | 39 | qmlRegisterType<DeclarativeTableModel>(uri, 1, 0, "CustomModel"); |
|
40 | 40 | qmlRegisterType<DeclarativeTableModelElement>(uri, 1, 0, "CustomModelElement"); |
|
41 | 41 | |
|
42 | 42 | viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); |
|
43 | 43 | viewer->setSource(QUrl("qrc:/qml/qmlcustommodel/loader.qml")); |
|
44 | 44 | viewer->setRenderHint(QPainter::Antialiasing, true); |
|
45 | 45 | viewer->showExpanded(); |
|
46 | 46 | |
|
47 | 47 | return app->exec(); |
|
48 | 48 | } |
@@ -1,200 +1,200 | |||
|
1 | 1 | // checksum 0x78c version 0x60010 |
|
2 | 2 | /* |
|
3 | 3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
4 | 4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
5 | 5 | code such as screen orientation handling. Also QML paths and debugging are |
|
6 | 6 | handled here. |
|
7 | 7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
8 | 8 | may offer an updated version of it. |
|
9 | 9 | */ |
|
10 | 10 | |
|
11 | 11 | #include "qmlapplicationviewer.h" |
|
12 | 12 | |
|
13 | 13 | #include <QtCore/QDir> |
|
14 | 14 | #include <QtCore/QFileInfo> |
|
15 | 15 | #include <QtDeclarative/QDeclarativeComponent> |
|
16 | 16 | #include <QtDeclarative/QDeclarativeEngine> |
|
17 | 17 | #include <QtDeclarative/QDeclarativeContext> |
|
18 |
#include <Q |
|
|
18 | #include <QApplication> | |
|
19 | 19 | |
|
20 | 20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
21 | 21 | |
|
22 | 22 | #ifdef HARMATTAN_BOOSTER |
|
23 | 23 | #include <MDeclarativeCache> |
|
24 | 24 | #endif |
|
25 | 25 | |
|
26 | 26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
27 | 27 | |
|
28 | 28 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
29 | 29 | |
|
30 | 30 | #if !defined(NO_JSDEBUGGER) |
|
31 | 31 | #include <jsdebuggeragent.h> |
|
32 | 32 | #endif |
|
33 | 33 | #if !defined(NO_QMLOBSERVER) |
|
34 | 34 | #include <qdeclarativeviewobserver.h> |
|
35 | 35 | #endif |
|
36 | 36 | |
|
37 | 37 | // Enable debugging before any QDeclarativeEngine is created |
|
38 | 38 | struct QmlJsDebuggingEnabler |
|
39 | 39 | { |
|
40 | 40 | QmlJsDebuggingEnabler() |
|
41 | 41 | { |
|
42 | 42 | QDeclarativeDebugHelper::enableDebugging(); |
|
43 | 43 | } |
|
44 | 44 | }; |
|
45 | 45 | |
|
46 | 46 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
47 | 47 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
48 | 48 | |
|
49 | 49 | #endif // QMLJSDEBUGGER |
|
50 | 50 | |
|
51 | 51 | class QmlApplicationViewerPrivate |
|
52 | 52 | { |
|
53 | 53 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} |
|
54 | 54 | |
|
55 | 55 | QString mainQmlFile; |
|
56 | 56 | QDeclarativeView *view; |
|
57 | 57 | friend class QmlApplicationViewer; |
|
58 | 58 | QString adjustPath(const QString &path); |
|
59 | 59 | }; |
|
60 | 60 | |
|
61 | 61 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
62 | 62 | { |
|
63 | 63 | #ifdef Q_OS_UNIX |
|
64 | 64 | #ifdef Q_OS_MAC |
|
65 | 65 | if (!QDir::isAbsolutePath(path)) |
|
66 | 66 | return QCoreApplication::applicationDirPath() |
|
67 | 67 | + QLatin1String("/../Resources/") + path; |
|
68 | 68 | #else |
|
69 | 69 | QString pathInInstallDir; |
|
70 | 70 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); |
|
71 | 71 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); |
|
72 | 72 | |
|
73 | 73 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | 74 | return pathInInstallDir; |
|
75 | 75 | #endif |
|
76 | 76 | #endif |
|
77 | 77 | return path; |
|
78 | 78 | } |
|
79 | 79 | |
|
80 | 80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
81 | 81 | : QDeclarativeView(parent) |
|
82 | 82 | , d(new QmlApplicationViewerPrivate(this)) |
|
83 | 83 | { |
|
84 | 84 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
85 | 85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
86 | 86 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
87 | 87 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
88 | 88 | #if !defined(NO_JSDEBUGGER) |
|
89 | 89 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
90 | 90 | #endif |
|
91 | 91 | #if !defined(NO_QMLOBSERVER) |
|
92 | 92 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
93 | 93 | #endif |
|
94 | 94 | #endif |
|
95 | 95 | } |
|
96 | 96 | |
|
97 | 97 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) |
|
98 | 98 | : QDeclarativeView(parent) |
|
99 | 99 | , d(new QmlApplicationViewerPrivate(view)) |
|
100 | 100 | { |
|
101 | 101 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); |
|
102 | 102 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
103 | 103 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
104 | 104 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
105 | 105 | #if !defined(NO_JSDEBUGGER) |
|
106 | 106 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
107 | 107 | #endif |
|
108 | 108 | #if !defined(NO_QMLOBSERVER) |
|
109 | 109 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
110 | 110 | #endif |
|
111 | 111 | #endif |
|
112 | 112 | } |
|
113 | 113 | |
|
114 | 114 | QmlApplicationViewer::~QmlApplicationViewer() |
|
115 | 115 | { |
|
116 | 116 | delete d; |
|
117 | 117 | } |
|
118 | 118 | |
|
119 | 119 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
120 | 120 | { |
|
121 | 121 | #ifdef HARMATTAN_BOOSTER |
|
122 | 122 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); |
|
123 | 123 | #else |
|
124 | 124 | return new QmlApplicationViewer(); |
|
125 | 125 | #endif |
|
126 | 126 | } |
|
127 | 127 | |
|
128 | 128 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
129 | 129 | { |
|
130 | 130 | d->mainQmlFile = d->adjustPath(file); |
|
131 | 131 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
132 | 132 | } |
|
133 | 133 | |
|
134 | 134 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
135 | 135 | { |
|
136 | 136 | d->view->engine()->addImportPath(d->adjustPath(path)); |
|
137 | 137 | } |
|
138 | 138 | |
|
139 | 139 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
140 | 140 | { |
|
141 | 141 | #if defined(Q_OS_SYMBIAN) |
|
142 | 142 | // If the version of Qt on the device is < 4.7.2, that attribute won't work |
|
143 | 143 | if (orientation != ScreenOrientationAuto) { |
|
144 | 144 | const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); |
|
145 | 145 | if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { |
|
146 | 146 | qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); |
|
147 | 147 | return; |
|
148 | 148 | } |
|
149 | 149 | } |
|
150 | 150 | #endif // Q_OS_SYMBIAN |
|
151 | 151 | |
|
152 | 152 | Qt::WidgetAttribute attribute; |
|
153 | 153 | switch (orientation) { |
|
154 | 154 | #if QT_VERSION < 0x040702 |
|
155 | 155 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
156 | 156 | case ScreenOrientationLockPortrait: |
|
157 | 157 | attribute = static_cast<Qt::WidgetAttribute>(128); |
|
158 | 158 | break; |
|
159 | 159 | case ScreenOrientationLockLandscape: |
|
160 | 160 | attribute = static_cast<Qt::WidgetAttribute>(129); |
|
161 | 161 | break; |
|
162 | 162 | default: |
|
163 | 163 | case ScreenOrientationAuto: |
|
164 | 164 | attribute = static_cast<Qt::WidgetAttribute>(130); |
|
165 | 165 | break; |
|
166 | 166 | #else // QT_VERSION < 0x040702 |
|
167 | 167 | case ScreenOrientationLockPortrait: |
|
168 | 168 | attribute = Qt::WA_LockPortraitOrientation; |
|
169 | 169 | break; |
|
170 | 170 | case ScreenOrientationLockLandscape: |
|
171 | 171 | attribute = Qt::WA_LockLandscapeOrientation; |
|
172 | 172 | break; |
|
173 | 173 | default: |
|
174 | 174 | case ScreenOrientationAuto: |
|
175 | 175 | attribute = Qt::WA_AutoOrientation; |
|
176 | 176 | break; |
|
177 | 177 | #endif // QT_VERSION < 0x040702 |
|
178 | 178 | }; |
|
179 | 179 | setAttribute(attribute, true); |
|
180 | 180 | } |
|
181 | 181 | |
|
182 | 182 | void QmlApplicationViewer::showExpanded() |
|
183 | 183 | { |
|
184 | 184 | #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
185 | 185 | d->view->showFullScreen(); |
|
186 | 186 | #elif defined(Q_WS_MAEMO_5) |
|
187 | 187 | d->view->showMaximized(); |
|
188 | 188 | #else |
|
189 | 189 | d->view->show(); |
|
190 | 190 | #endif |
|
191 | 191 | } |
|
192 | 192 | |
|
193 | 193 | QApplication *createApplication(int &argc, char **argv) |
|
194 | 194 | { |
|
195 | 195 | #ifdef HARMATTAN_BOOSTER |
|
196 | 196 | return MDeclarativeCache::qApplication(argc, argv); |
|
197 | 197 | #else |
|
198 | 198 | return new QApplication(argc, argv); |
|
199 | 199 | #endif |
|
200 | 200 | } |
@@ -1,40 +1,40 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 |
#include <Q |
|
|
21 | #include <QApplication> | |
|
22 | 22 | #include <QDeclarativeEngine> |
|
23 | 23 | #include <QDeclarativeContext> |
|
24 | 24 | #include "qmlapplicationviewer.h" |
|
25 | 25 | #include "datasource.h" |
|
26 | 26 | |
|
27 | 27 | Q_DECL_EXPORT int main(int argc, char *argv[]) |
|
28 | 28 | { |
|
29 | 29 | QScopedPointer<QApplication> app(createApplication(argc, argv)); |
|
30 | 30 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); |
|
31 | 31 | |
|
32 | 32 | DataSource dataSource(viewer.data()); |
|
33 | 33 | viewer->rootContext()->setContextProperty("dataSource", &dataSource); |
|
34 | 34 | |
|
35 | 35 | viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); |
|
36 | 36 | viewer->setSource(QUrl("qrc:/qml/qmloscilloscope/main.qml")); |
|
37 | 37 | viewer->showExpanded(); |
|
38 | 38 | |
|
39 | 39 | return app->exec(); |
|
40 | 40 | } |
@@ -1,200 +1,200 | |||
|
1 | 1 | // checksum 0x78c version 0x60010 |
|
2 | 2 | /* |
|
3 | 3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
4 | 4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
5 | 5 | code such as screen orientation handling. Also QML paths and debugging are |
|
6 | 6 | handled here. |
|
7 | 7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
8 | 8 | may offer an updated version of it. |
|
9 | 9 | */ |
|
10 | 10 | |
|
11 | 11 | #include "qmlapplicationviewer.h" |
|
12 | 12 | |
|
13 | 13 | #include <QtCore/QDir> |
|
14 | 14 | #include <QtCore/QFileInfo> |
|
15 | 15 | #include <QtDeclarative/QDeclarativeComponent> |
|
16 | 16 | #include <QtDeclarative/QDeclarativeEngine> |
|
17 | 17 | #include <QtDeclarative/QDeclarativeContext> |
|
18 |
#include <Q |
|
|
18 | #include <QApplication> | |
|
19 | 19 | |
|
20 | 20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
21 | 21 | |
|
22 | 22 | #ifdef HARMATTAN_BOOSTER |
|
23 | 23 | #include <MDeclarativeCache> |
|
24 | 24 | #endif |
|
25 | 25 | |
|
26 | 26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
27 | 27 | |
|
28 | 28 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
29 | 29 | |
|
30 | 30 | #if !defined(NO_JSDEBUGGER) |
|
31 | 31 | #include <jsdebuggeragent.h> |
|
32 | 32 | #endif |
|
33 | 33 | #if !defined(NO_QMLOBSERVER) |
|
34 | 34 | #include <qdeclarativeviewobserver.h> |
|
35 | 35 | #endif |
|
36 | 36 | |
|
37 | 37 | // Enable debugging before any QDeclarativeEngine is created |
|
38 | 38 | struct QmlJsDebuggingEnabler |
|
39 | 39 | { |
|
40 | 40 | QmlJsDebuggingEnabler() |
|
41 | 41 | { |
|
42 | 42 | QDeclarativeDebugHelper::enableDebugging(); |
|
43 | 43 | } |
|
44 | 44 | }; |
|
45 | 45 | |
|
46 | 46 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
47 | 47 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
48 | 48 | |
|
49 | 49 | #endif // QMLJSDEBUGGER |
|
50 | 50 | |
|
51 | 51 | class QmlApplicationViewerPrivate |
|
52 | 52 | { |
|
53 | 53 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} |
|
54 | 54 | |
|
55 | 55 | QString mainQmlFile; |
|
56 | 56 | QDeclarativeView *view; |
|
57 | 57 | friend class QmlApplicationViewer; |
|
58 | 58 | QString adjustPath(const QString &path); |
|
59 | 59 | }; |
|
60 | 60 | |
|
61 | 61 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
62 | 62 | { |
|
63 | 63 | #ifdef Q_OS_UNIX |
|
64 | 64 | #ifdef Q_OS_MAC |
|
65 | 65 | if (!QDir::isAbsolutePath(path)) |
|
66 | 66 | return QCoreApplication::applicationDirPath() |
|
67 | 67 | + QLatin1String("/../Resources/") + path; |
|
68 | 68 | #else |
|
69 | 69 | QString pathInInstallDir; |
|
70 | 70 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); |
|
71 | 71 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); |
|
72 | 72 | |
|
73 | 73 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | 74 | return pathInInstallDir; |
|
75 | 75 | #endif |
|
76 | 76 | #endif |
|
77 | 77 | return path; |
|
78 | 78 | } |
|
79 | 79 | |
|
80 | 80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
81 | 81 | : QDeclarativeView(parent) |
|
82 | 82 | , d(new QmlApplicationViewerPrivate(this)) |
|
83 | 83 | { |
|
84 | 84 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
85 | 85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
86 | 86 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
87 | 87 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
88 | 88 | #if !defined(NO_JSDEBUGGER) |
|
89 | 89 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
90 | 90 | #endif |
|
91 | 91 | #if !defined(NO_QMLOBSERVER) |
|
92 | 92 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
93 | 93 | #endif |
|
94 | 94 | #endif |
|
95 | 95 | } |
|
96 | 96 | |
|
97 | 97 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) |
|
98 | 98 | : QDeclarativeView(parent) |
|
99 | 99 | , d(new QmlApplicationViewerPrivate(view)) |
|
100 | 100 | { |
|
101 | 101 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); |
|
102 | 102 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
103 | 103 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
104 | 104 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
105 | 105 | #if !defined(NO_JSDEBUGGER) |
|
106 | 106 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
107 | 107 | #endif |
|
108 | 108 | #if !defined(NO_QMLOBSERVER) |
|
109 | 109 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
110 | 110 | #endif |
|
111 | 111 | #endif |
|
112 | 112 | } |
|
113 | 113 | |
|
114 | 114 | QmlApplicationViewer::~QmlApplicationViewer() |
|
115 | 115 | { |
|
116 | 116 | delete d; |
|
117 | 117 | } |
|
118 | 118 | |
|
119 | 119 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
120 | 120 | { |
|
121 | 121 | #ifdef HARMATTAN_BOOSTER |
|
122 | 122 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); |
|
123 | 123 | #else |
|
124 | 124 | return new QmlApplicationViewer(); |
|
125 | 125 | #endif |
|
126 | 126 | } |
|
127 | 127 | |
|
128 | 128 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
129 | 129 | { |
|
130 | 130 | d->mainQmlFile = d->adjustPath(file); |
|
131 | 131 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
132 | 132 | } |
|
133 | 133 | |
|
134 | 134 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
135 | 135 | { |
|
136 | 136 | d->view->engine()->addImportPath(d->adjustPath(path)); |
|
137 | 137 | } |
|
138 | 138 | |
|
139 | 139 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
140 | 140 | { |
|
141 | 141 | #if defined(Q_OS_SYMBIAN) |
|
142 | 142 | // If the version of Qt on the device is < 4.7.2, that attribute won't work |
|
143 | 143 | if (orientation != ScreenOrientationAuto) { |
|
144 | 144 | const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); |
|
145 | 145 | if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { |
|
146 | 146 | qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); |
|
147 | 147 | return; |
|
148 | 148 | } |
|
149 | 149 | } |
|
150 | 150 | #endif // Q_OS_SYMBIAN |
|
151 | 151 | |
|
152 | 152 | Qt::WidgetAttribute attribute; |
|
153 | 153 | switch (orientation) { |
|
154 | 154 | #if QT_VERSION < 0x040702 |
|
155 | 155 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
156 | 156 | case ScreenOrientationLockPortrait: |
|
157 | 157 | attribute = static_cast<Qt::WidgetAttribute>(128); |
|
158 | 158 | break; |
|
159 | 159 | case ScreenOrientationLockLandscape: |
|
160 | 160 | attribute = static_cast<Qt::WidgetAttribute>(129); |
|
161 | 161 | break; |
|
162 | 162 | default: |
|
163 | 163 | case ScreenOrientationAuto: |
|
164 | 164 | attribute = static_cast<Qt::WidgetAttribute>(130); |
|
165 | 165 | break; |
|
166 | 166 | #else // QT_VERSION < 0x040702 |
|
167 | 167 | case ScreenOrientationLockPortrait: |
|
168 | 168 | attribute = Qt::WA_LockPortraitOrientation; |
|
169 | 169 | break; |
|
170 | 170 | case ScreenOrientationLockLandscape: |
|
171 | 171 | attribute = Qt::WA_LockLandscapeOrientation; |
|
172 | 172 | break; |
|
173 | 173 | default: |
|
174 | 174 | case ScreenOrientationAuto: |
|
175 | 175 | attribute = Qt::WA_AutoOrientation; |
|
176 | 176 | break; |
|
177 | 177 | #endif // QT_VERSION < 0x040702 |
|
178 | 178 | }; |
|
179 | 179 | setAttribute(attribute, true); |
|
180 | 180 | } |
|
181 | 181 | |
|
182 | 182 | void QmlApplicationViewer::showExpanded() |
|
183 | 183 | { |
|
184 | 184 | #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
185 | 185 | d->view->showFullScreen(); |
|
186 | 186 | #elif defined(Q_WS_MAEMO_5) |
|
187 | 187 | d->view->showMaximized(); |
|
188 | 188 | #else |
|
189 | 189 | d->view->show(); |
|
190 | 190 | #endif |
|
191 | 191 | } |
|
192 | 192 | |
|
193 | 193 | QApplication *createApplication(int &argc, char **argv) |
|
194 | 194 | { |
|
195 | 195 | #ifdef HARMATTAN_BOOSTER |
|
196 | 196 | return MDeclarativeCache::qApplication(argc, argv); |
|
197 | 197 | #else |
|
198 | 198 | return new QApplication(argc, argv); |
|
199 | 199 | #endif |
|
200 | 200 | } |
@@ -1,31 +1,31 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 |
#include <Q |
|
|
21 | #include <QApplication> | |
|
22 | 22 | #include "tablewidget.h" |
|
23 | 23 | |
|
24 | 24 | int main(int argc, char *argv[]) |
|
25 | 25 | { |
|
26 | 26 | QApplication a(argc, argv); |
|
27 | 27 | TableWidget w; |
|
28 | 28 | w.show(); |
|
29 | 29 | |
|
30 | 30 | return a.exec(); |
|
31 | 31 | } |
@@ -1,34 +1,34 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #ifndef TABLEWIDGET_H |
|
22 | 22 | #define TABLEWIDGET_H |
|
23 | 23 | |
|
24 |
#include <Q |
|
|
24 | #include <QWidget> | |
|
25 | 25 | |
|
26 | 26 | class TableWidget : public QWidget |
|
27 | 27 | { |
|
28 | 28 | Q_OBJECT |
|
29 | 29 | |
|
30 | 30 | public: |
|
31 | 31 | TableWidget(QWidget *parent = 0); |
|
32 | 32 | }; |
|
33 | 33 | |
|
34 | 34 | #endif // TABLEWIDGET_H |
@@ -1,31 +1,31 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 |
#include <Q |
|
|
21 | #include <QApplication> | |
|
22 | 22 | #include "tablewidget.h" |
|
23 | 23 | |
|
24 | 24 | int main(int argc, char *argv[]) |
|
25 | 25 | { |
|
26 | 26 | QApplication a(argc, argv); |
|
27 | 27 | TableWidget w; |
|
28 | 28 | w.show(); |
|
29 | 29 | |
|
30 | 30 | return a.exec(); |
|
31 | 31 | } |
@@ -1,34 +1,34 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #ifndef TABLEWIDGET_H |
|
22 | 22 | #define TABLEWIDGET_H |
|
23 | 23 | |
|
24 |
#include <Q |
|
|
24 | #include <QWidget> | |
|
25 | 25 | |
|
26 | 26 | class TableWidget : public QWidget |
|
27 | 27 | { |
|
28 | 28 | Q_OBJECT |
|
29 | 29 | |
|
30 | 30 | public: |
|
31 | 31 | TableWidget(QWidget *parent = 0); |
|
32 | 32 | }; |
|
33 | 33 | |
|
34 | 34 | #endif // TABLEWIDGET_H |
@@ -1,77 +1,77 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "drilldownchart.h" |
|
22 | 22 | #include "drilldownslice.h" |
|
23 |
#include <Q |
|
|
23 | #include <QApplication> | |
|
24 | 24 | #include <QMainWindow> |
|
25 | 25 | #include <QTime> |
|
26 | 26 | #include <QChartView> |
|
27 | 27 | #include <QLegend> |
|
28 | 28 | #include <QPieSeries> |
|
29 | 29 | |
|
30 | 30 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
31 | 31 | |
|
32 | 32 | int main(int argc, char *argv[]) |
|
33 | 33 | { |
|
34 | 34 | QApplication a(argc, argv); |
|
35 | 35 | |
|
36 | 36 | qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); |
|
37 | 37 | |
|
38 | 38 | QMainWindow window; |
|
39 | 39 | |
|
40 | 40 | DrilldownChart* chart = new DrilldownChart(); |
|
41 | 41 | chart->setTheme(QChart::ChartThemeLight); |
|
42 | 42 | chart->setAnimationOptions(QChart::AllAnimations); |
|
43 | 43 | chart->legend()->setVisible(true); |
|
44 | 44 | chart->legend()->setAlignment(Qt::AlignRight); |
|
45 | 45 | |
|
46 | 46 | QPieSeries* yearSeries = new QPieSeries(&window); |
|
47 | 47 | yearSeries->setName("Sales by year - All"); |
|
48 | 48 | |
|
49 | 49 | QList<QString> months; |
|
50 | 50 | months << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec"; |
|
51 | 51 | QList<QString> names; |
|
52 | 52 | names << "Jane" << "John" << "Axel" << "Mary" << "Susan" << "Bob"; |
|
53 | 53 | |
|
54 | 54 | foreach (QString name, names) { |
|
55 | 55 | QPieSeries* series = new QPieSeries(&window); |
|
56 | 56 | series->setName("Sales by month - " + name); |
|
57 | 57 | |
|
58 | 58 | foreach (QString month, months) |
|
59 | 59 | *series << new DrilldownSlice(qrand() % 1000, month, yearSeries); |
|
60 | 60 | |
|
61 | 61 | QObject::connect(series, SIGNAL(clicked(QPieSlice*)), chart, SLOT(handleSliceClicked(QPieSlice*))); |
|
62 | 62 | |
|
63 | 63 | *yearSeries << new DrilldownSlice(series->sum(), name, series); |
|
64 | 64 | } |
|
65 | 65 | |
|
66 | 66 | QObject::connect(yearSeries, SIGNAL(clicked(QPieSlice*)), chart, SLOT(handleSliceClicked(QPieSlice*))); |
|
67 | 67 | |
|
68 | 68 | chart->changeSeries(yearSeries); |
|
69 | 69 | |
|
70 | 70 | QChartView* chartView = new QChartView(chart); |
|
71 | 71 | chartView->setRenderHint(QPainter::Antialiasing); |
|
72 | 72 | window.setCentralWidget(chartView); |
|
73 | 73 | window.resize(800, 500); |
|
74 | 74 | window.show(); |
|
75 | 75 | |
|
76 | 76 | return a.exec(); |
|
77 | 77 | } |
@@ -1,36 +1,36 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 |
#include <Q |
|
|
21 | #include <QApplication> | |
|
22 | 22 | #include <QDeclarativeEngine> |
|
23 | 23 | #include "qmlapplicationviewer.h" |
|
24 | 24 | |
|
25 | 25 | Q_DECL_EXPORT int main(int argc, char *argv[]) |
|
26 | 26 | { |
|
27 | 27 | QScopedPointer<QApplication> app(createApplication(argc, argv)); |
|
28 | 28 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); |
|
29 | 29 | |
|
30 | 30 | viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); |
|
31 | 31 | viewer->setSource(QUrl("qrc:/qml/qmlpiechart/main.qml")); |
|
32 | 32 | viewer->setRenderHint(QPainter::Antialiasing, true); |
|
33 | 33 | viewer->showExpanded(); |
|
34 | 34 | |
|
35 | 35 | return app->exec(); |
|
36 | 36 | } |
@@ -1,200 +1,200 | |||
|
1 | 1 | // checksum 0x78c version 0x60010 |
|
2 | 2 | /* |
|
3 | 3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
4 | 4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
5 | 5 | code such as screen orientation handling. Also QML paths and debugging are |
|
6 | 6 | handled here. |
|
7 | 7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
8 | 8 | may offer an updated version of it. |
|
9 | 9 | */ |
|
10 | 10 | |
|
11 | 11 | #include "qmlapplicationviewer.h" |
|
12 | 12 | |
|
13 | 13 | #include <QtCore/QDir> |
|
14 | 14 | #include <QtCore/QFileInfo> |
|
15 | 15 | #include <QtDeclarative/QDeclarativeComponent> |
|
16 | 16 | #include <QtDeclarative/QDeclarativeEngine> |
|
17 | 17 | #include <QtDeclarative/QDeclarativeContext> |
|
18 |
#include <Q |
|
|
18 | #include <QApplication> | |
|
19 | 19 | |
|
20 | 20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
21 | 21 | |
|
22 | 22 | #ifdef HARMATTAN_BOOSTER |
|
23 | 23 | #include <MDeclarativeCache> |
|
24 | 24 | #endif |
|
25 | 25 | |
|
26 | 26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
27 | 27 | |
|
28 | 28 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
29 | 29 | |
|
30 | 30 | #if !defined(NO_JSDEBUGGER) |
|
31 | 31 | #include <jsdebuggeragent.h> |
|
32 | 32 | #endif |
|
33 | 33 | #if !defined(NO_QMLOBSERVER) |
|
34 | 34 | #include <qdeclarativeviewobserver.h> |
|
35 | 35 | #endif |
|
36 | 36 | |
|
37 | 37 | // Enable debugging before any QDeclarativeEngine is created |
|
38 | 38 | struct QmlJsDebuggingEnabler |
|
39 | 39 | { |
|
40 | 40 | QmlJsDebuggingEnabler() |
|
41 | 41 | { |
|
42 | 42 | QDeclarativeDebugHelper::enableDebugging(); |
|
43 | 43 | } |
|
44 | 44 | }; |
|
45 | 45 | |
|
46 | 46 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
47 | 47 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
48 | 48 | |
|
49 | 49 | #endif // QMLJSDEBUGGER |
|
50 | 50 | |
|
51 | 51 | class QmlApplicationViewerPrivate |
|
52 | 52 | { |
|
53 | 53 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} |
|
54 | 54 | |
|
55 | 55 | QString mainQmlFile; |
|
56 | 56 | QDeclarativeView *view; |
|
57 | 57 | friend class QmlApplicationViewer; |
|
58 | 58 | QString adjustPath(const QString &path); |
|
59 | 59 | }; |
|
60 | 60 | |
|
61 | 61 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
62 | 62 | { |
|
63 | 63 | #ifdef Q_OS_UNIX |
|
64 | 64 | #ifdef Q_OS_MAC |
|
65 | 65 | if (!QDir::isAbsolutePath(path)) |
|
66 | 66 | return QCoreApplication::applicationDirPath() |
|
67 | 67 | + QLatin1String("/../Resources/") + path; |
|
68 | 68 | #else |
|
69 | 69 | QString pathInInstallDir; |
|
70 | 70 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); |
|
71 | 71 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); |
|
72 | 72 | |
|
73 | 73 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | 74 | return pathInInstallDir; |
|
75 | 75 | #endif |
|
76 | 76 | #endif |
|
77 | 77 | return path; |
|
78 | 78 | } |
|
79 | 79 | |
|
80 | 80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
81 | 81 | : QDeclarativeView(parent) |
|
82 | 82 | , d(new QmlApplicationViewerPrivate(this)) |
|
83 | 83 | { |
|
84 | 84 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
85 | 85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
86 | 86 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
87 | 87 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
88 | 88 | #if !defined(NO_JSDEBUGGER) |
|
89 | 89 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
90 | 90 | #endif |
|
91 | 91 | #if !defined(NO_QMLOBSERVER) |
|
92 | 92 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
93 | 93 | #endif |
|
94 | 94 | #endif |
|
95 | 95 | } |
|
96 | 96 | |
|
97 | 97 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) |
|
98 | 98 | : QDeclarativeView(parent) |
|
99 | 99 | , d(new QmlApplicationViewerPrivate(view)) |
|
100 | 100 | { |
|
101 | 101 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); |
|
102 | 102 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
103 | 103 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
104 | 104 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
105 | 105 | #if !defined(NO_JSDEBUGGER) |
|
106 | 106 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
107 | 107 | #endif |
|
108 | 108 | #if !defined(NO_QMLOBSERVER) |
|
109 | 109 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
110 | 110 | #endif |
|
111 | 111 | #endif |
|
112 | 112 | } |
|
113 | 113 | |
|
114 | 114 | QmlApplicationViewer::~QmlApplicationViewer() |
|
115 | 115 | { |
|
116 | 116 | delete d; |
|
117 | 117 | } |
|
118 | 118 | |
|
119 | 119 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
120 | 120 | { |
|
121 | 121 | #ifdef HARMATTAN_BOOSTER |
|
122 | 122 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); |
|
123 | 123 | #else |
|
124 | 124 | return new QmlApplicationViewer(); |
|
125 | 125 | #endif |
|
126 | 126 | } |
|
127 | 127 | |
|
128 | 128 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
129 | 129 | { |
|
130 | 130 | d->mainQmlFile = d->adjustPath(file); |
|
131 | 131 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
132 | 132 | } |
|
133 | 133 | |
|
134 | 134 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
135 | 135 | { |
|
136 | 136 | d->view->engine()->addImportPath(d->adjustPath(path)); |
|
137 | 137 | } |
|
138 | 138 | |
|
139 | 139 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
140 | 140 | { |
|
141 | 141 | #if defined(Q_OS_SYMBIAN) |
|
142 | 142 | // If the version of Qt on the device is < 4.7.2, that attribute won't work |
|
143 | 143 | if (orientation != ScreenOrientationAuto) { |
|
144 | 144 | const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); |
|
145 | 145 | if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { |
|
146 | 146 | qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); |
|
147 | 147 | return; |
|
148 | 148 | } |
|
149 | 149 | } |
|
150 | 150 | #endif // Q_OS_SYMBIAN |
|
151 | 151 | |
|
152 | 152 | Qt::WidgetAttribute attribute; |
|
153 | 153 | switch (orientation) { |
|
154 | 154 | #if QT_VERSION < 0x040702 |
|
155 | 155 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
156 | 156 | case ScreenOrientationLockPortrait: |
|
157 | 157 | attribute = static_cast<Qt::WidgetAttribute>(128); |
|
158 | 158 | break; |
|
159 | 159 | case ScreenOrientationLockLandscape: |
|
160 | 160 | attribute = static_cast<Qt::WidgetAttribute>(129); |
|
161 | 161 | break; |
|
162 | 162 | default: |
|
163 | 163 | case ScreenOrientationAuto: |
|
164 | 164 | attribute = static_cast<Qt::WidgetAttribute>(130); |
|
165 | 165 | break; |
|
166 | 166 | #else // QT_VERSION < 0x040702 |
|
167 | 167 | case ScreenOrientationLockPortrait: |
|
168 | 168 | attribute = Qt::WA_LockPortraitOrientation; |
|
169 | 169 | break; |
|
170 | 170 | case ScreenOrientationLockLandscape: |
|
171 | 171 | attribute = Qt::WA_LockLandscapeOrientation; |
|
172 | 172 | break; |
|
173 | 173 | default: |
|
174 | 174 | case ScreenOrientationAuto: |
|
175 | 175 | attribute = Qt::WA_AutoOrientation; |
|
176 | 176 | break; |
|
177 | 177 | #endif // QT_VERSION < 0x040702 |
|
178 | 178 | }; |
|
179 | 179 | setAttribute(attribute, true); |
|
180 | 180 | } |
|
181 | 181 | |
|
182 | 182 | void QmlApplicationViewer::showExpanded() |
|
183 | 183 | { |
|
184 | 184 | #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
185 | 185 | d->view->showFullScreen(); |
|
186 | 186 | #elif defined(Q_WS_MAEMO_5) |
|
187 | 187 | d->view->showMaximized(); |
|
188 | 188 | #else |
|
189 | 189 | d->view->show(); |
|
190 | 190 | #endif |
|
191 | 191 | } |
|
192 | 192 | |
|
193 | 193 | QApplication *createApplication(int &argc, char **argv) |
|
194 | 194 | { |
|
195 | 195 | #ifdef HARMATTAN_BOOSTER |
|
196 | 196 | return MDeclarativeCache::qApplication(argc, argv); |
|
197 | 197 | #else |
|
198 | 198 | return new QApplication(argc, argv); |
|
199 | 199 | #endif |
|
200 | 200 | } |
@@ -1,40 +1,40 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 |
#include <Q |
|
|
21 | #include <QApplication> | |
|
22 | 22 | #include <QMainWindow> |
|
23 | 23 | #include "chartview.h" |
|
24 | 24 | |
|
25 | 25 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
26 | 26 | |
|
27 | 27 | int main(int argc, char *argv[]) |
|
28 | 28 | { |
|
29 | 29 | QApplication a(argc, argv); |
|
30 | 30 | |
|
31 | 31 | //![4] |
|
32 | 32 | ChartView* chartView = new ChartView(); |
|
33 | 33 | QMainWindow window; |
|
34 | 34 | window.setCentralWidget(chartView); |
|
35 | 35 | window.resize(400, 300); |
|
36 | 36 | window.show(); |
|
37 | 37 | //![4] |
|
38 | 38 | |
|
39 | 39 | return a.exec(); |
|
40 | 40 | } |
@@ -1,35 +1,35 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 |
#include <Q |
|
|
21 | #include <QApplication> | |
|
22 | 22 | #include <QMainWindow> |
|
23 | 23 | #include "chartview.h" |
|
24 | 24 | |
|
25 | 25 | int main(int argc, char *argv[]) |
|
26 | 26 | { |
|
27 | 27 | QApplication a(argc, argv); |
|
28 | 28 | QMainWindow window; |
|
29 | 29 | ChartView chartView(&window); |
|
30 | 30 | window.setCentralWidget(&chartView); |
|
31 | 31 | window.resize(400, 300); |
|
32 | 32 | window.show(); |
|
33 | 33 | |
|
34 | 34 | return a.exec(); |
|
35 | 35 | } |
@@ -1,114 +1,114 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 |
#include <Q |
|
|
21 | #include <QApplication> | |
|
22 | 22 | #include <QMainWindow> |
|
23 | 23 | #include <QChartView> |
|
24 | 24 | #include <QBarSet> |
|
25 | 25 | #include <QLegend> |
|
26 | 26 | #include "drilldownseries.h" |
|
27 | 27 | #include "drilldownchart.h" |
|
28 | 28 | |
|
29 | 29 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
30 | 30 | |
|
31 | 31 | int main(int argc, char *argv[]) |
|
32 | 32 | { |
|
33 | 33 | QApplication a(argc, argv); |
|
34 | 34 | QMainWindow window; |
|
35 | 35 | |
|
36 | 36 | //! [1] |
|
37 | 37 | DrilldownChart* drilldownChart = new DrilldownChart(); |
|
38 | 38 | drilldownChart->setTheme(QChart::ChartThemeBlueIcy); |
|
39 | 39 | drilldownChart->setAnimationOptions(QChart::SeriesAnimations); |
|
40 | 40 | //! [1] |
|
41 | 41 | |
|
42 | 42 | //! [2] |
|
43 | 43 | // Define categories |
|
44 | 44 | QStringList months; |
|
45 | 45 | months << "May" << "Jun" << "Jul" << "Aug" << "Sep"; |
|
46 | 46 | QStringList weeks; |
|
47 | 47 | weeks << "week 1" << "week 2" << "week 3" << "week 4"; |
|
48 | 48 | QStringList plants; |
|
49 | 49 | plants << "Habanero" << "Lemon Drop" << "Starfish" << "Aji Amarillo"; |
|
50 | 50 | //! [2] |
|
51 | 51 | |
|
52 | 52 | //! [3] |
|
53 | 53 | // Create drilldown structure |
|
54 | 54 | DrilldownBarSeries* seasonSeries = new DrilldownBarSeries(months, drilldownChart); |
|
55 | 55 | seasonSeries->setName("Crop by month - Season"); |
|
56 | 56 | |
|
57 | 57 | // Each month in season series has drilldown series for weekly data |
|
58 | 58 | for (int month=0; month < months.count(); month++) { |
|
59 | 59 | |
|
60 | 60 | // Create drilldown series for every week |
|
61 | 61 | DrilldownBarSeries* weeklySeries = new DrilldownBarSeries(weeks, drilldownChart); |
|
62 | 62 | seasonSeries->mapDrilldownSeries(month, weeklySeries); |
|
63 | 63 | |
|
64 | 64 | // Drilling down from weekly data brings us back to season data. |
|
65 | 65 | for (int week=0; week < weeks.count(); week++) { |
|
66 | 66 | weeklySeries->mapDrilldownSeries(week, seasonSeries); |
|
67 | 67 | weeklySeries->setName(QString("Crop by week - " + months.at(month))); |
|
68 | 68 | } |
|
69 | 69 | |
|
70 | 70 | // Use clicked signal to implement drilldown |
|
71 | 71 | QObject::connect(weeklySeries, SIGNAL(clicked(int, QBarSet*)), drilldownChart, SLOT(handleClicked(int, QBarSet*))); |
|
72 | 72 | } |
|
73 | 73 | |
|
74 | 74 | // Enable drilldown from season series using clicked signal |
|
75 | 75 | QObject::connect(seasonSeries, SIGNAL(clicked(int, QBarSet*)), drilldownChart, SLOT(handleClicked(int, QBarSet*))); |
|
76 | 76 | //! [3] |
|
77 | 77 | |
|
78 | 78 | //! [4] |
|
79 | 79 | // Fill monthly and weekly series with data |
|
80 | 80 | foreach (QString plant, plants) { |
|
81 | 81 | QBarSet* monthlyCrop = new QBarSet(plant); |
|
82 | 82 | for (int month=0; month<months.count(); month++) { |
|
83 | 83 | QBarSet* weeklyCrop = new QBarSet(plant); |
|
84 | 84 | for (int week=0; week<weeks.count(); week++) { |
|
85 | 85 | *weeklyCrop << (qrand() % 20); |
|
86 | 86 | } |
|
87 | 87 | // Get the drilldown series from season series and add crop to it. |
|
88 | 88 | seasonSeries->drilldownSeries(month)->append(weeklyCrop); |
|
89 | 89 | *monthlyCrop << weeklyCrop->sum(); |
|
90 | 90 | } |
|
91 | 91 | seasonSeries->append(monthlyCrop); |
|
92 | 92 | } |
|
93 | 93 | //! [4] |
|
94 | 94 | |
|
95 | 95 | //! [5] |
|
96 | 96 | // Show season series in initial view |
|
97 | 97 | drilldownChart->changeSeries(seasonSeries); |
|
98 | 98 | drilldownChart->setTitle(seasonSeries->name()); |
|
99 | 99 | //! [5] |
|
100 | 100 | |
|
101 | 101 | //! [6] |
|
102 | 102 | drilldownChart->axisX()->setGridLineVisible(false); |
|
103 | 103 | drilldownChart->legend()->setVisible(true); |
|
104 | 104 | drilldownChart->legend()->setAlignment(Qt::AlignBottom); |
|
105 | 105 | //! [6] |
|
106 | 106 | |
|
107 | 107 | QChartView *chartView = new QChartView(drilldownChart); |
|
108 | 108 | window.setCentralWidget(chartView); |
|
109 | 109 | window.resize(400, 300); |
|
110 | 110 | window.show(); |
|
111 | 111 | |
|
112 | 112 | return a.exec(); |
|
113 | 113 | } |
|
114 | 114 |
@@ -1,35 +1,35 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 |
#include <Q |
|
|
21 | #include <QApplication> | |
|
22 | 22 | #include <QDeclarativeEngine> |
|
23 | 23 | #include "qmlapplicationviewer.h" |
|
24 | 24 | |
|
25 | 25 | Q_DECL_EXPORT int main(int argc, char *argv[]) |
|
26 | 26 | { |
|
27 | 27 | QScopedPointer<QApplication> app(createApplication(argc, argv)); |
|
28 | 28 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); |
|
29 | 29 | |
|
30 | 30 | viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); |
|
31 | 31 | viewer->setSource(QUrl("qrc:/qml/qmlchartaxis/main.qml")); |
|
32 | 32 | viewer->showExpanded(); |
|
33 | 33 | |
|
34 | 34 | return app->exec(); |
|
35 | 35 | } |
@@ -1,200 +1,200 | |||
|
1 | 1 | // checksum 0x78c version 0x60010 |
|
2 | 2 | /* |
|
3 | 3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
4 | 4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
5 | 5 | code such as screen orientation handling. Also QML paths and debugging are |
|
6 | 6 | handled here. |
|
7 | 7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
8 | 8 | may offer an updated version of it. |
|
9 | 9 | */ |
|
10 | 10 | |
|
11 | 11 | #include "qmlapplicationviewer.h" |
|
12 | 12 | |
|
13 | 13 | #include <QtCore/QDir> |
|
14 | 14 | #include <QtCore/QFileInfo> |
|
15 | 15 | #include <QtDeclarative/QDeclarativeComponent> |
|
16 | 16 | #include <QtDeclarative/QDeclarativeEngine> |
|
17 | 17 | #include <QtDeclarative/QDeclarativeContext> |
|
18 |
#include <Q |
|
|
18 | #include <QApplication> | |
|
19 | 19 | |
|
20 | 20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
21 | 21 | |
|
22 | 22 | #ifdef HARMATTAN_BOOSTER |
|
23 | 23 | #include <MDeclarativeCache> |
|
24 | 24 | #endif |
|
25 | 25 | |
|
26 | 26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
27 | 27 | |
|
28 | 28 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
29 | 29 | |
|
30 | 30 | #if !defined(NO_JSDEBUGGER) |
|
31 | 31 | #include <jsdebuggeragent.h> |
|
32 | 32 | #endif |
|
33 | 33 | #if !defined(NO_QMLOBSERVER) |
|
34 | 34 | #include <qdeclarativeviewobserver.h> |
|
35 | 35 | #endif |
|
36 | 36 | |
|
37 | 37 | // Enable debugging before any QDeclarativeEngine is created |
|
38 | 38 | struct QmlJsDebuggingEnabler |
|
39 | 39 | { |
|
40 | 40 | QmlJsDebuggingEnabler() |
|
41 | 41 | { |
|
42 | 42 | QDeclarativeDebugHelper::enableDebugging(); |
|
43 | 43 | } |
|
44 | 44 | }; |
|
45 | 45 | |
|
46 | 46 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
47 | 47 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
48 | 48 | |
|
49 | 49 | #endif // QMLJSDEBUGGER |
|
50 | 50 | |
|
51 | 51 | class QmlApplicationViewerPrivate |
|
52 | 52 | { |
|
53 | 53 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} |
|
54 | 54 | |
|
55 | 55 | QString mainQmlFile; |
|
56 | 56 | QDeclarativeView *view; |
|
57 | 57 | friend class QmlApplicationViewer; |
|
58 | 58 | QString adjustPath(const QString &path); |
|
59 | 59 | }; |
|
60 | 60 | |
|
61 | 61 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
62 | 62 | { |
|
63 | 63 | #ifdef Q_OS_UNIX |
|
64 | 64 | #ifdef Q_OS_MAC |
|
65 | 65 | if (!QDir::isAbsolutePath(path)) |
|
66 | 66 | return QCoreApplication::applicationDirPath() |
|
67 | 67 | + QLatin1String("/../Resources/") + path; |
|
68 | 68 | #else |
|
69 | 69 | QString pathInInstallDir; |
|
70 | 70 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); |
|
71 | 71 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); |
|
72 | 72 | |
|
73 | 73 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | 74 | return pathInInstallDir; |
|
75 | 75 | #endif |
|
76 | 76 | #endif |
|
77 | 77 | return path; |
|
78 | 78 | } |
|
79 | 79 | |
|
80 | 80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
81 | 81 | : QDeclarativeView(parent) |
|
82 | 82 | , d(new QmlApplicationViewerPrivate(this)) |
|
83 | 83 | { |
|
84 | 84 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
85 | 85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
86 | 86 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
87 | 87 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
88 | 88 | #if !defined(NO_JSDEBUGGER) |
|
89 | 89 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
90 | 90 | #endif |
|
91 | 91 | #if !defined(NO_QMLOBSERVER) |
|
92 | 92 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
93 | 93 | #endif |
|
94 | 94 | #endif |
|
95 | 95 | } |
|
96 | 96 | |
|
97 | 97 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) |
|
98 | 98 | : QDeclarativeView(parent) |
|
99 | 99 | , d(new QmlApplicationViewerPrivate(view)) |
|
100 | 100 | { |
|
101 | 101 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); |
|
102 | 102 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
103 | 103 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
104 | 104 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
105 | 105 | #if !defined(NO_JSDEBUGGER) |
|
106 | 106 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
107 | 107 | #endif |
|
108 | 108 | #if !defined(NO_QMLOBSERVER) |
|
109 | 109 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
110 | 110 | #endif |
|
111 | 111 | #endif |
|
112 | 112 | } |
|
113 | 113 | |
|
114 | 114 | QmlApplicationViewer::~QmlApplicationViewer() |
|
115 | 115 | { |
|
116 | 116 | delete d; |
|
117 | 117 | } |
|
118 | 118 | |
|
119 | 119 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
120 | 120 | { |
|
121 | 121 | #ifdef HARMATTAN_BOOSTER |
|
122 | 122 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); |
|
123 | 123 | #else |
|
124 | 124 | return new QmlApplicationViewer(); |
|
125 | 125 | #endif |
|
126 | 126 | } |
|
127 | 127 | |
|
128 | 128 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
129 | 129 | { |
|
130 | 130 | d->mainQmlFile = d->adjustPath(file); |
|
131 | 131 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
132 | 132 | } |
|
133 | 133 | |
|
134 | 134 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
135 | 135 | { |
|
136 | 136 | d->view->engine()->addImportPath(d->adjustPath(path)); |
|
137 | 137 | } |
|
138 | 138 | |
|
139 | 139 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
140 | 140 | { |
|
141 | 141 | #if defined(Q_OS_SYMBIAN) |
|
142 | 142 | // If the version of Qt on the device is < 4.7.2, that attribute won't work |
|
143 | 143 | if (orientation != ScreenOrientationAuto) { |
|
144 | 144 | const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); |
|
145 | 145 | if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { |
|
146 | 146 | qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); |
|
147 | 147 | return; |
|
148 | 148 | } |
|
149 | 149 | } |
|
150 | 150 | #endif // Q_OS_SYMBIAN |
|
151 | 151 | |
|
152 | 152 | Qt::WidgetAttribute attribute; |
|
153 | 153 | switch (orientation) { |
|
154 | 154 | #if QT_VERSION < 0x040702 |
|
155 | 155 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
156 | 156 | case ScreenOrientationLockPortrait: |
|
157 | 157 | attribute = static_cast<Qt::WidgetAttribute>(128); |
|
158 | 158 | break; |
|
159 | 159 | case ScreenOrientationLockLandscape: |
|
160 | 160 | attribute = static_cast<Qt::WidgetAttribute>(129); |
|
161 | 161 | break; |
|
162 | 162 | default: |
|
163 | 163 | case ScreenOrientationAuto: |
|
164 | 164 | attribute = static_cast<Qt::WidgetAttribute>(130); |
|
165 | 165 | break; |
|
166 | 166 | #else // QT_VERSION < 0x040702 |
|
167 | 167 | case ScreenOrientationLockPortrait: |
|
168 | 168 | attribute = Qt::WA_LockPortraitOrientation; |
|
169 | 169 | break; |
|
170 | 170 | case ScreenOrientationLockLandscape: |
|
171 | 171 | attribute = Qt::WA_LockLandscapeOrientation; |
|
172 | 172 | break; |
|
173 | 173 | default: |
|
174 | 174 | case ScreenOrientationAuto: |
|
175 | 175 | attribute = Qt::WA_AutoOrientation; |
|
176 | 176 | break; |
|
177 | 177 | #endif // QT_VERSION < 0x040702 |
|
178 | 178 | }; |
|
179 | 179 | setAttribute(attribute, true); |
|
180 | 180 | } |
|
181 | 181 | |
|
182 | 182 | void QmlApplicationViewer::showExpanded() |
|
183 | 183 | { |
|
184 | 184 | #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
185 | 185 | d->view->showFullScreen(); |
|
186 | 186 | #elif defined(Q_WS_MAEMO_5) |
|
187 | 187 | d->view->showMaximized(); |
|
188 | 188 | #else |
|
189 | 189 | d->view->show(); |
|
190 | 190 | #endif |
|
191 | 191 | } |
|
192 | 192 | |
|
193 | 193 | QApplication *createApplication(int &argc, char **argv) |
|
194 | 194 | { |
|
195 | 195 | #ifdef HARMATTAN_BOOSTER |
|
196 | 196 | return MDeclarativeCache::qApplication(argc, argv); |
|
197 | 197 | #else |
|
198 | 198 | return new QApplication(argc, argv); |
|
199 | 199 | #endif |
|
200 | 200 | } |
@@ -1,36 +1,36 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 |
#include <Q |
|
|
21 | #include <QApplication> | |
|
22 | 22 | #include <QDeclarativeEngine> |
|
23 | 23 | #include "qmlapplicationviewer.h" |
|
24 | 24 | |
|
25 | 25 | Q_DECL_EXPORT int main(int argc, char *argv[]) |
|
26 | 26 | { |
|
27 | 27 | QScopedPointer<QApplication> app(createApplication(argc, argv)); |
|
28 | 28 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); |
|
29 | 29 | |
|
30 | 30 | viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); |
|
31 | 31 | viewer->setSource(QUrl("qrc:/qml/qmlchartproperties/loader.qml")); |
|
32 | 32 | viewer->setRenderHint(QPainter::Antialiasing, true); |
|
33 | 33 | viewer->showExpanded(); |
|
34 | 34 | |
|
35 | 35 | return app->exec(); |
|
36 | 36 | } |
@@ -1,200 +1,200 | |||
|
1 | 1 | // checksum 0x78c version 0x60010 |
|
2 | 2 | /* |
|
3 | 3 | This file was generated by the Qt Quick Application wizard of Qt Creator. |
|
4 | 4 | QmlApplicationViewer is a convenience class containing mobile device specific |
|
5 | 5 | code such as screen orientation handling. Also QML paths and debugging are |
|
6 | 6 | handled here. |
|
7 | 7 | It is recommended not to modify this file, since newer versions of Qt Creator |
|
8 | 8 | may offer an updated version of it. |
|
9 | 9 | */ |
|
10 | 10 | |
|
11 | 11 | #include "qmlapplicationviewer.h" |
|
12 | 12 | |
|
13 | 13 | #include <QtCore/QDir> |
|
14 | 14 | #include <QtCore/QFileInfo> |
|
15 | 15 | #include <QtDeclarative/QDeclarativeComponent> |
|
16 | 16 | #include <QtDeclarative/QDeclarativeEngine> |
|
17 | 17 | #include <QtDeclarative/QDeclarativeContext> |
|
18 |
#include <Q |
|
|
18 | #include <QApplication> | |
|
19 | 19 | |
|
20 | 20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN |
|
21 | 21 | |
|
22 | 22 | #ifdef HARMATTAN_BOOSTER |
|
23 | 23 | #include <MDeclarativeCache> |
|
24 | 24 | #endif |
|
25 | 25 | |
|
26 | 26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
27 | 27 | |
|
28 | 28 | #include <qt_private/qdeclarativedebughelper_p.h> |
|
29 | 29 | |
|
30 | 30 | #if !defined(NO_JSDEBUGGER) |
|
31 | 31 | #include <jsdebuggeragent.h> |
|
32 | 32 | #endif |
|
33 | 33 | #if !defined(NO_QMLOBSERVER) |
|
34 | 34 | #include <qdeclarativeviewobserver.h> |
|
35 | 35 | #endif |
|
36 | 36 | |
|
37 | 37 | // Enable debugging before any QDeclarativeEngine is created |
|
38 | 38 | struct QmlJsDebuggingEnabler |
|
39 | 39 | { |
|
40 | 40 | QmlJsDebuggingEnabler() |
|
41 | 41 | { |
|
42 | 42 | QDeclarativeDebugHelper::enableDebugging(); |
|
43 | 43 | } |
|
44 | 44 | }; |
|
45 | 45 | |
|
46 | 46 | // Execute code in constructor before first QDeclarativeEngine is instantiated |
|
47 | 47 | static QmlJsDebuggingEnabler enableDebuggingHelper; |
|
48 | 48 | |
|
49 | 49 | #endif // QMLJSDEBUGGER |
|
50 | 50 | |
|
51 | 51 | class QmlApplicationViewerPrivate |
|
52 | 52 | { |
|
53 | 53 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} |
|
54 | 54 | |
|
55 | 55 | QString mainQmlFile; |
|
56 | 56 | QDeclarativeView *view; |
|
57 | 57 | friend class QmlApplicationViewer; |
|
58 | 58 | QString adjustPath(const QString &path); |
|
59 | 59 | }; |
|
60 | 60 | |
|
61 | 61 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) |
|
62 | 62 | { |
|
63 | 63 | #ifdef Q_OS_UNIX |
|
64 | 64 | #ifdef Q_OS_MAC |
|
65 | 65 | if (!QDir::isAbsolutePath(path)) |
|
66 | 66 | return QCoreApplication::applicationDirPath() |
|
67 | 67 | + QLatin1String("/../Resources/") + path; |
|
68 | 68 | #else |
|
69 | 69 | QString pathInInstallDir; |
|
70 | 70 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); |
|
71 | 71 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); |
|
72 | 72 | |
|
73 | 73 | if (QFileInfo(pathInInstallDir).exists()) |
|
74 | 74 | return pathInInstallDir; |
|
75 | 75 | #endif |
|
76 | 76 | #endif |
|
77 | 77 | return path; |
|
78 | 78 | } |
|
79 | 79 | |
|
80 | 80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) |
|
81 | 81 | : QDeclarativeView(parent) |
|
82 | 82 | , d(new QmlApplicationViewerPrivate(this)) |
|
83 | 83 | { |
|
84 | 84 | connect(engine(), SIGNAL(quit()), SLOT(close())); |
|
85 | 85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
86 | 86 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
87 | 87 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
88 | 88 | #if !defined(NO_JSDEBUGGER) |
|
89 | 89 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
90 | 90 | #endif |
|
91 | 91 | #if !defined(NO_QMLOBSERVER) |
|
92 | 92 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
93 | 93 | #endif |
|
94 | 94 | #endif |
|
95 | 95 | } |
|
96 | 96 | |
|
97 | 97 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) |
|
98 | 98 | : QDeclarativeView(parent) |
|
99 | 99 | , d(new QmlApplicationViewerPrivate(view)) |
|
100 | 100 | { |
|
101 | 101 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); |
|
102 | 102 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); |
|
103 | 103 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in |
|
104 | 104 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 |
|
105 | 105 | #if !defined(NO_JSDEBUGGER) |
|
106 | 106 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); |
|
107 | 107 | #endif |
|
108 | 108 | #if !defined(NO_QMLOBSERVER) |
|
109 | 109 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); |
|
110 | 110 | #endif |
|
111 | 111 | #endif |
|
112 | 112 | } |
|
113 | 113 | |
|
114 | 114 | QmlApplicationViewer::~QmlApplicationViewer() |
|
115 | 115 | { |
|
116 | 116 | delete d; |
|
117 | 117 | } |
|
118 | 118 | |
|
119 | 119 | QmlApplicationViewer *QmlApplicationViewer::create() |
|
120 | 120 | { |
|
121 | 121 | #ifdef HARMATTAN_BOOSTER |
|
122 | 122 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); |
|
123 | 123 | #else |
|
124 | 124 | return new QmlApplicationViewer(); |
|
125 | 125 | #endif |
|
126 | 126 | } |
|
127 | 127 | |
|
128 | 128 | void QmlApplicationViewer::setMainQmlFile(const QString &file) |
|
129 | 129 | { |
|
130 | 130 | d->mainQmlFile = d->adjustPath(file); |
|
131 | 131 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); |
|
132 | 132 | } |
|
133 | 133 | |
|
134 | 134 | void QmlApplicationViewer::addImportPath(const QString &path) |
|
135 | 135 | { |
|
136 | 136 | d->view->engine()->addImportPath(d->adjustPath(path)); |
|
137 | 137 | } |
|
138 | 138 | |
|
139 | 139 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) |
|
140 | 140 | { |
|
141 | 141 | #if defined(Q_OS_SYMBIAN) |
|
142 | 142 | // If the version of Qt on the device is < 4.7.2, that attribute won't work |
|
143 | 143 | if (orientation != ScreenOrientationAuto) { |
|
144 | 144 | const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); |
|
145 | 145 | if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { |
|
146 | 146 | qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); |
|
147 | 147 | return; |
|
148 | 148 | } |
|
149 | 149 | } |
|
150 | 150 | #endif // Q_OS_SYMBIAN |
|
151 | 151 | |
|
152 | 152 | Qt::WidgetAttribute attribute; |
|
153 | 153 | switch (orientation) { |
|
154 | 154 | #if QT_VERSION < 0x040702 |
|
155 | 155 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes |
|
156 | 156 | case ScreenOrientationLockPortrait: |
|
157 | 157 | attribute = static_cast<Qt::WidgetAttribute>(128); |
|
158 | 158 | break; |
|
159 | 159 | case ScreenOrientationLockLandscape: |
|
160 | 160 | attribute = static_cast<Qt::WidgetAttribute>(129); |
|
161 | 161 | break; |
|
162 | 162 | default: |
|
163 | 163 | case ScreenOrientationAuto: |
|
164 | 164 | attribute = static_cast<Qt::WidgetAttribute>(130); |
|
165 | 165 | break; |
|
166 | 166 | #else // QT_VERSION < 0x040702 |
|
167 | 167 | case ScreenOrientationLockPortrait: |
|
168 | 168 | attribute = Qt::WA_LockPortraitOrientation; |
|
169 | 169 | break; |
|
170 | 170 | case ScreenOrientationLockLandscape: |
|
171 | 171 | attribute = Qt::WA_LockLandscapeOrientation; |
|
172 | 172 | break; |
|
173 | 173 | default: |
|
174 | 174 | case ScreenOrientationAuto: |
|
175 | 175 | attribute = Qt::WA_AutoOrientation; |
|
176 | 176 | break; |
|
177 | 177 | #endif // QT_VERSION < 0x040702 |
|
178 | 178 | }; |
|
179 | 179 | setAttribute(attribute, true); |
|
180 | 180 | } |
|
181 | 181 | |
|
182 | 182 | void QmlApplicationViewer::showExpanded() |
|
183 | 183 | { |
|
184 | 184 | #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) |
|
185 | 185 | d->view->showFullScreen(); |
|
186 | 186 | #elif defined(Q_WS_MAEMO_5) |
|
187 | 187 | d->view->showMaximized(); |
|
188 | 188 | #else |
|
189 | 189 | d->view->show(); |
|
190 | 190 | #endif |
|
191 | 191 | } |
|
192 | 192 | |
|
193 | 193 | QApplication *createApplication(int &argc, char **argv) |
|
194 | 194 | { |
|
195 | 195 | #ifdef HARMATTAN_BOOSTER |
|
196 | 196 | return MDeclarativeCache::qApplication(argc, argv); |
|
197 | 197 | #else |
|
198 | 198 | return new QApplication(argc, argv); |
|
199 | 199 | #endif |
|
200 | 200 | } |
General Comments 0
You need to be logged in to leave comments.
Login now