##// END OF EJS Templates
Qt5: declarative fix part3...
Marek Rosa -
r2054:96f04f377ffa
parent child
Show More
@@ -1,49 +1,49
1 1 !include(config.pri) {
2 2 error('Missing config.pri')
3 3 }
4 4
5 5 TEMPLATE = subdirs
6 SUBDIRS = src plugins demos
7 #examples tests
6 SUBDIRS = src plugins demos examples
7 # tests
8 8
9 9 development_build: message('Development build')
10 10
11 11 CONFIG += ordered
12 12 QMAKE_CXXFLAGS += -g -Wall
13 13 unix:QMAKE_DISTCLEAN += -r build bin include lib doc/html
14 14 win32:QMAKE_DISTCLEAN += /Q /s build bin include lib doc\\html
15 15
16 16 # install feature file
17 17 feature.path = $$[QT_INSTALL_DATA]/mkspecs/features
18 18 feature.files = $$PWD/features/qtcommercialchart.prf
19 19 INSTALLS += feature
20 20
21 21 docs.target = docs
22 22 win32:{
23 23 docs.commands = qdoc3 $$CHART_BUILD_DOC_DIR\\qcharts.qdocconf
24 24 }else{
25 25 docs.commands = qdoc3 $$CHART_BUILD_DOC_DIR/qcharts.qdocconf
26 26 }
27 27 docs.depends = FORCE
28 28 QMAKE_EXTRA_TARGETS += docs
29 29
30 30 unix:coverage:{
31 31 QMAKE_DISTCLEAN += -r ./coverage
32 32 QMAKE_CLEAN += build/*.gcda build/*.gcno
33 33 QMAKE_EXTRA_TARGETS += buildcoverage runcoverage gencoverage
34 34
35 35 buildcoverage.target = build_coverage
36 36 buildcoverage.depends = all
37 37 buildcoverage.commands = mkdir -p ./coverage; \
38 38 make -C src prepare_coverage;
39 39
40 40 runcoverage.target = run_coverage
41 41 runcoverage.depends = buildcoverage
42 42 runcoverage.commands = for f in `ls ./bin/tst_*` ; do echo "processing \$\$f test..."; \$\$f >> unit.log; done ; exit 0;
43 43
44 44 gencoverage.target = gen_coverage
45 45 gencoverage.depends = runcoverage
46 46 gencoverage.commands = make -C src gen_coverage; \
47 47 genhtml -o ./coverage ./coverage/coverage.info --prefix $$PWD
48 48 }
49 49
@@ -1,36 +1,40
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include <QApplication>
22 #include <QDeclarativeEngine>
22 #ifdef QT5_QUICK_1
23 #include <QtQuick1/QDeclarativeEngine>
24 #else
25 #include <QtDeclarative/QDeclarativeEngine>
26 #endif
23 27 #include "qmlapplicationviewer.h"
24 28
25 29 Q_DECL_EXPORT int main(int argc, char *argv[])
26 30 {
27 31 QScopedPointer<QApplication> app(createApplication(argc, argv));
28 32 QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create());
29 33
30 viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
34 // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
31 35 viewer->setSource(QUrl("qrc:/qml/qmlpiechart/main.qml"));
32 36 viewer->setRenderHint(QPainter::Antialiasing, true);
33 37 viewer->showExpanded();
34 38
35 39 return app->exec();
36 40 }
@@ -1,200 +1,207
1 1 // checksum 0x78c version 0x60010
2 2 /*
3 3 This file was generated by the Qt Quick Application wizard of Qt Creator.
4 4 QmlApplicationViewer is a convenience class containing mobile device specific
5 5 code such as screen orientation handling. Also QML paths and debugging are
6 6 handled here.
7 7 It is recommended not to modify this file, since newer versions of Qt Creator
8 8 may offer an updated version of it.
9 9 */
10 10
11 11 #include "qmlapplicationviewer.h"
12 12
13 13 #include <QtCore/QDir>
14 14 #include <QtCore/QFileInfo>
15 #include <QtDeclarative/QDeclarativeComponent>
16 #include <QtDeclarative/QDeclarativeEngine>
17 #include <QtDeclarative/QDeclarativeContext>
15 #ifdef QT5_QUICK_1
16 #include <QtQuick1/QDeclarativeComponent>
17 #include <QtQuick1/QDeclarativeEngine>
18 #include <QtQuick1/QDeclarativeContext>
19 #else
20 #include <QtDeclarative/QDeclarativeComponent>
21 #include <QtDeclarative/QDeclarativeEngine>
22 #include <QtDeclarative/QDeclarativeContext>
23 #endif
24
18 25 #include <QApplication>
19 26
20 27 #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN
21 28
22 29 #ifdef HARMATTAN_BOOSTER
23 30 #include <MDeclarativeCache>
24 31 #endif
25 32
26 33 #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800
27 34
28 35 #include <qt_private/qdeclarativedebughelper_p.h>
29 36
30 37 #if !defined(NO_JSDEBUGGER)
31 38 #include <jsdebuggeragent.h>
32 39 #endif
33 40 #if !defined(NO_QMLOBSERVER)
34 41 #include <qdeclarativeviewobserver.h>
35 42 #endif
36 43
37 44 // Enable debugging before any QDeclarativeEngine is created
38 45 struct QmlJsDebuggingEnabler
39 46 {
40 47 QmlJsDebuggingEnabler()
41 48 {
42 49 QDeclarativeDebugHelper::enableDebugging();
43 50 }
44 51 };
45 52
46 53 // Execute code in constructor before first QDeclarativeEngine is instantiated
47 54 static QmlJsDebuggingEnabler enableDebuggingHelper;
48 55
49 56 #endif // QMLJSDEBUGGER
50 57
51 58 class QmlApplicationViewerPrivate
52 59 {
53 60 QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {}
54 61
55 62 QString mainQmlFile;
56 63 QDeclarativeView *view;
57 64 friend class QmlApplicationViewer;
58 65 QString adjustPath(const QString &path);
59 66 };
60 67
61 68 QString QmlApplicationViewerPrivate::adjustPath(const QString &path)
62 69 {
63 70 #ifdef Q_OS_UNIX
64 71 #ifdef Q_OS_MAC
65 72 if (!QDir::isAbsolutePath(path))
66 73 return QCoreApplication::applicationDirPath()
67 74 + QLatin1String("/../Resources/") + path;
68 75 #else
69 76 QString pathInInstallDir;
70 77 const QString applicationDirPath = QCoreApplication::applicationDirPath();
71 78 pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path);
72 79
73 80 if (QFileInfo(pathInInstallDir).exists())
74 81 return pathInInstallDir;
75 82 #endif
76 83 #endif
77 84 return path;
78 85 }
79 86
80 87 QmlApplicationViewer::QmlApplicationViewer(QWidget *parent)
81 88 : QDeclarativeView(parent)
82 89 , d(new QmlApplicationViewerPrivate(this))
83 90 {
84 91 connect(engine(), SIGNAL(quit()), SLOT(close()));
85 92 setResizeMode(QDeclarativeView::SizeRootObjectToView);
86 93 // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in
87 94 #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800
88 95 #if !defined(NO_JSDEBUGGER)
89 96 new QmlJSDebugger::JSDebuggerAgent(d->view->engine());
90 97 #endif
91 98 #if !defined(NO_QMLOBSERVER)
92 99 new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view);
93 100 #endif
94 101 #endif
95 102 }
96 103
97 104 QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent)
98 105 : QDeclarativeView(parent)
99 106 , d(new QmlApplicationViewerPrivate(view))
100 107 {
101 108 connect(view->engine(), SIGNAL(quit()), view, SLOT(close()));
102 109 view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
103 110 // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in
104 111 #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800
105 112 #if !defined(NO_JSDEBUGGER)
106 113 new QmlJSDebugger::JSDebuggerAgent(d->view->engine());
107 114 #endif
108 115 #if !defined(NO_QMLOBSERVER)
109 116 new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view);
110 117 #endif
111 118 #endif
112 119 }
113 120
114 121 QmlApplicationViewer::~QmlApplicationViewer()
115 122 {
116 123 delete d;
117 124 }
118 125
119 126 QmlApplicationViewer *QmlApplicationViewer::create()
120 127 {
121 128 #ifdef HARMATTAN_BOOSTER
122 129 return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0);
123 130 #else
124 131 return new QmlApplicationViewer();
125 132 #endif
126 133 }
127 134
128 135 void QmlApplicationViewer::setMainQmlFile(const QString &file)
129 136 {
130 137 d->mainQmlFile = d->adjustPath(file);
131 138 d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile));
132 139 }
133 140
134 141 void QmlApplicationViewer::addImportPath(const QString &path)
135 142 {
136 143 d->view->engine()->addImportPath(d->adjustPath(path));
137 144 }
138 145
139 void QmlApplicationViewer::setOrientation(ScreenOrientation orientation)
140 {
141 #if defined(Q_OS_SYMBIAN)
142 // If the version of Qt on the device is < 4.7.2, that attribute won't work
143 if (orientation != ScreenOrientationAuto) {
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) {
146 qWarning("Screen orientation locking only supported with Qt 4.7.2 and above");
147 return;
148 }
149 }
150 #endif // Q_OS_SYMBIAN
151
152 Qt::WidgetAttribute attribute;
153 switch (orientation) {
154 #if QT_VERSION < 0x040702
155 // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
156 case ScreenOrientationLockPortrait:
157 attribute = static_cast<Qt::WidgetAttribute>(128);
158 break;
159 case ScreenOrientationLockLandscape:
160 attribute = static_cast<Qt::WidgetAttribute>(129);
161 break;
162 default:
163 case ScreenOrientationAuto:
164 attribute = static_cast<Qt::WidgetAttribute>(130);
165 break;
166 #else // QT_VERSION < 0x040702
167 case ScreenOrientationLockPortrait:
168 attribute = Qt::WA_LockPortraitOrientation;
169 break;
170 case ScreenOrientationLockLandscape:
171 attribute = Qt::WA_LockLandscapeOrientation;
172 break;
173 default:
174 case ScreenOrientationAuto:
175 attribute = Qt::WA_AutoOrientation;
176 break;
177 #endif // QT_VERSION < 0x040702
178 };
179 setAttribute(attribute, true);
180 }
146 //void QmlApplicationViewer::setOrientation(ScreenOrientation orientation)
147 //{
148 //#if defined(Q_OS_SYMBIAN)
149 // // If the version of Qt on the device is < 4.7.2, that attribute won't work
150 // if (orientation != ScreenOrientationAuto) {
151 // const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.'));
152 // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) {
153 // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above");
154 // return;
155 // }
156 // }
157 //#endif // Q_OS_SYMBIAN
158
159 // Qt::WidgetAttribute attribute;
160 // switch (orientation) {
161 //#if QT_VERSION < 0x040702
162 // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
163 // case ScreenOrientationLockPortrait:
164 // attribute = static_cast<Qt::WidgetAttribute>(128);
165 // break;
166 // case ScreenOrientationLockLandscape:
167 // attribute = static_cast<Qt::WidgetAttribute>(129);
168 // break;
169 // default:
170 // case ScreenOrientationAuto:
171 // attribute = static_cast<Qt::WidgetAttribute>(130);
172 // break;
173 //#else // QT_VERSION < 0x040702
174 // case ScreenOrientationLockPortrait:
175 // attribute = Qt::WA_LockPortraitOrientation;
176 // break;
177 // case ScreenOrientationLockLandscape:
178 // attribute = Qt::WA_LockLandscapeOrientation;
179 // break;
180 // default:
181 // case ScreenOrientationAuto:
182 // attribute = Qt::WA_AutoOrientation;
183 // break;
184 //#endif // QT_VERSION < 0x040702
185 // };
186 // setAttribute(attribute, true);
187 //}
181 188
182 189 void QmlApplicationViewer::showExpanded()
183 190 {
184 191 #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR)
185 192 d->view->showFullScreen();
186 193 #elif defined(Q_WS_MAEMO_5)
187 194 d->view->showMaximized();
188 195 #else
189 196 d->view->show();
190 197 #endif
191 198 }
192 199
193 200 QApplication *createApplication(int &argc, char **argv)
194 201 {
195 202 #ifdef HARMATTAN_BOOSTER
196 203 return MDeclarativeCache::qApplication(argc, argv);
197 204 #else
198 205 return new QApplication(argc, argv);
199 206 #endif
200 207 }
@@ -1,47 +1,51
1 1 // checksum 0x82ed version 0x60010
2 2 /*
3 3 This file was generated by the Qt Quick Application wizard of Qt Creator.
4 4 QmlApplicationViewer is a convenience class containing mobile device specific
5 5 code such as screen orientation handling. Also QML paths and debugging are
6 6 handled here.
7 7 It is recommended not to modify this file, since newer versions of Qt Creator
8 8 may offer an updated version of it.
9 9 */
10 10
11 11 #ifndef QMLAPPLICATIONVIEWER_H
12 12 #define QMLAPPLICATIONVIEWER_H
13 13
14 #include <QtDeclarative/QDeclarativeView>
14 #ifdef QT5_QUICK_1
15 #include <QtQuick1/QDeclarativeView>
16 #else
17 #include <QtDeclarative/QDeclarativeView>
18 #endif
15 19
16 20 class QmlApplicationViewer : public QDeclarativeView
17 21 {
18 22 Q_OBJECT
19 23
20 24 public:
21 25 enum ScreenOrientation {
22 26 ScreenOrientationLockPortrait,
23 27 ScreenOrientationLockLandscape,
24 28 ScreenOrientationAuto
25 29 };
26 30
27 31 explicit QmlApplicationViewer(QWidget *parent = 0);
28 32 virtual ~QmlApplicationViewer();
29 33
30 34 static QmlApplicationViewer *create();
31 35
32 36 void setMainQmlFile(const QString &file);
33 37 void addImportPath(const QString &path);
34 38
35 39 // Note that this will only have an effect on Symbian and Fremantle.
36 void setOrientation(ScreenOrientation orientation);
40 // void setOrientation(ScreenOrientation orientation);
37 41
38 42 void showExpanded();
39 43
40 44 private:
41 45 explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent);
42 46 class QmlApplicationViewerPrivate *d;
43 47 };
44 48
45 49 QApplication *createApplication(int &argc, char **argv);
46 50
47 51 #endif // QMLAPPLICATIONVIEWER_H
@@ -1,46 +1,48
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #ifndef CHART_H
22 22 #define CHART_H
23 23
24 24 #include <QChart>
25 25
26 class QGestureEvent;
27
26 28 QTCOMMERCIALCHART_USE_NAMESPACE
27 29
28 30 //![1]
29 31 class Chart : public QChart
30 32 //![1]
31 33 {
32 34 public:
33 35 explicit Chart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
34 36 ~Chart();
35 37
36 38 protected:
37 39 bool sceneEvent(QEvent *event);
38 40
39 41 private:
40 42 bool gestureEvent(QGestureEvent* event);
41 43
42 44 private:
43 45
44 46 };
45 47
46 48 #endif // CHART_H
@@ -1,46 +1,48
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #ifndef CHART_H
22 22 #define CHART_H
23 23
24 24 #include <QChart>
25 25
26 class QGestureEvent;
27
26 28 QTCOMMERCIALCHART_USE_NAMESPACE
27 29
28 30 //![1]
29 31 class Chart : public QChart
30 32 //![1]
31 33 {
32 34 public:
33 35 explicit Chart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
34 36 ~Chart();
35 37
36 38 protected:
37 39 bool sceneEvent(QEvent *event);
38 40
39 41 private:
40 42 bool gestureEvent(QGestureEvent* event);
41 43
42 44 private:
43 45
44 46 };
45 47
46 48 #endif // CHART_H
General Comments 0
You need to be logged in to leave comments. Login now