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