From 816c8c6e440e105c897dfa292dbe4aa7c1a61320 2012-09-18 09:16:15 From: Jani Honkonen Date: 2012-09-18 09:16:15 Subject: [PATCH] qmlcustomlegend: fix qt5 build --- diff --git a/demos/qmlcustomlegend/main.cpp b/demos/qmlcustomlegend/main.cpp index f93f1a9..6353e56 100755 --- a/demos/qmlcustomlegend/main.cpp +++ b/demos/qmlcustomlegend/main.cpp @@ -18,8 +18,12 @@ ** ****************************************************************************/ -#include -#include +#include +#ifdef QT5_QUICK_1 + #include +#else + #include +#endif #include "qmlapplicationviewer.h" Q_DECL_EXPORT int main(int argc, char *argv[]) @@ -27,7 +31,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) QScopedPointer app(createApplication(argc, argv)); QScopedPointer viewer(QmlApplicationViewer::create()); - viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); + //viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); viewer->setSource(QUrl("qrc:/qml/qmlcustomlegend/loader.qml")); viewer->setRenderHint(QPainter::Antialiasing, true); viewer->showExpanded(); diff --git a/demos/qmlcustomlegend/qmlapplicationviewer/qmlapplicationviewer.cpp b/demos/qmlcustomlegend/qmlapplicationviewer/qmlapplicationviewer.cpp index 91ab71e..08d207c 100755 --- a/demos/qmlcustomlegend/qmlapplicationviewer/qmlapplicationviewer.cpp +++ b/demos/qmlcustomlegend/qmlapplicationviewer/qmlapplicationviewer.cpp @@ -12,10 +12,16 @@ #include #include -#include -#include -#include -#include +#ifdef QT5_QUICK_1 + #include + #include + #include +#else + #include + #include + #include +#endif +#include #include // MEEGO_EDITION_HARMATTAN @@ -136,48 +142,48 @@ void QmlApplicationViewer::addImportPath(const QString &path) d->view->engine()->addImportPath(d->adjustPath(path)); } -void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) -{ -#if defined(Q_OS_SYMBIAN) - // If the version of Qt on the device is < 4.7.2, that attribute won't work - if (orientation != ScreenOrientationAuto) { - const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); - if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { - qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); - return; - } - } -#endif // Q_OS_SYMBIAN - - Qt::WidgetAttribute attribute; - switch (orientation) { -#if QT_VERSION < 0x040702 - // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes - case ScreenOrientationLockPortrait: - attribute = static_cast(128); - break; - case ScreenOrientationLockLandscape: - attribute = static_cast(129); - break; - default: - case ScreenOrientationAuto: - attribute = static_cast(130); - break; -#else // QT_VERSION < 0x040702 - case ScreenOrientationLockPortrait: - attribute = Qt::WA_LockPortraitOrientation; - break; - case ScreenOrientationLockLandscape: - attribute = Qt::WA_LockLandscapeOrientation; - break; - default: - case ScreenOrientationAuto: - attribute = Qt::WA_AutoOrientation; - break; -#endif // QT_VERSION < 0x040702 - }; - setAttribute(attribute, true); -} +//void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) +//{ +//#if defined(Q_OS_SYMBIAN) +// // If the version of Qt on the device is < 4.7.2, that attribute won't work +// if (orientation != ScreenOrientationAuto) { +// const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); +// if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { +// qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); +// return; +// } +// } +//#endif // Q_OS_SYMBIAN + +// Qt::WidgetAttribute attribute; +// switch (orientation) { +//#if QT_VERSION < 0x040702 +// // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes +// case ScreenOrientationLockPortrait: +// attribute = static_cast(128); +// break; +// case ScreenOrientationLockLandscape: +// attribute = static_cast(129); +// break; +// default: +// case ScreenOrientationAuto: +// attribute = static_cast(130); +// break; +//#else // QT_VERSION < 0x040702 +// case ScreenOrientationLockPortrait: +// attribute = Qt::WA_LockPortraitOrientation; +// break; +// case ScreenOrientationLockLandscape: +// attribute = Qt::WA_LockLandscapeOrientation; +// break; +// default: +// case ScreenOrientationAuto: +// attribute = Qt::WA_AutoOrientation; +// break; +//#endif // QT_VERSION < 0x040702 +// }; +// setAttribute(attribute, true); +//} void QmlApplicationViewer::showExpanded() { diff --git a/demos/qmlcustomlegend/qmlapplicationviewer/qmlapplicationviewer.h b/demos/qmlcustomlegend/qmlapplicationviewer/qmlapplicationviewer.h index c7940f7..22c35a1 100755 --- a/demos/qmlcustomlegend/qmlapplicationviewer/qmlapplicationviewer.h +++ b/demos/qmlcustomlegend/qmlapplicationviewer/qmlapplicationviewer.h @@ -11,7 +11,11 @@ #ifndef QMLAPPLICATIONVIEWER_H #define QMLAPPLICATIONVIEWER_H -#include +#ifdef QT5_QUICK_1 + #include +#else + #include +#endif class QmlApplicationViewer : public QDeclarativeView { @@ -33,7 +37,7 @@ public: void addImportPath(const QString &path); // Note that this will only have an effect on Symbian and Fremantle. - void setOrientation(ScreenOrientation orientation); + // void setOrientation(ScreenOrientation orientation); void showExpanded(); diff --git a/demos/qmlcustomlegend/qmlapplicationviewer/qmlapplicationviewer.pri b/demos/qmlcustomlegend/qmlapplicationviewer/qmlapplicationviewer.pri index 8450019..8e891c0 100755 --- a/demos/qmlcustomlegend/qmlapplicationviewer/qmlapplicationviewer.pri +++ b/demos/qmlcustomlegend/qmlapplicationviewer/qmlapplicationviewer.pri @@ -1,4 +1,8 @@ -QT += declarative +greaterThan(QT_MAJOR_VERSION, 4) { + QT += quick1 +} else { + QT += declarative +} SOURCES += $$PWD/qmlapplicationviewer.cpp HEADERS += $$PWD/qmlapplicationviewer.h