diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2010-08-19 06:35:40 (GMT) |
---|---|---|
committer | Jason McDonald <jason.mcdonald@nokia.com> | 2010-09-03 03:09:00 (GMT) |
commit | 7bb6f5414558ed24839a533a6b22104fd700f7d4 (patch) | |
tree | e90d5eb11c9f975c0694824f69a5eb542e612fda /demos/qtdemo | |
parent | 5ff12e18588d94a8403b2220318c97d892c72265 (diff) | |
download | Qt-7bb6f5414558ed24839a533a6b22104fd700f7d4.zip Qt-7bb6f5414558ed24839a533a6b22104fd700f7d4.tar.gz Qt-7bb6f5414558ed24839a533a6b22104fd700f7d4.tar.bz2 |
Without Declarative, still build and run QtDemo
If declarative is configured out then QtDemo will now still build, with
all declarative demos disabled.
Task-number: QTBUG-12983
(cherry picked from commit 015b726aa46e774155bc13359dcd68d15df73bbd)
Diffstat (limited to 'demos/qtdemo')
-rw-r--r-- | demos/qtdemo/mainwindow.h | 1 | ||||
-rw-r--r-- | demos/qtdemo/menumanager.cpp | 32 | ||||
-rw-r--r-- | demos/qtdemo/menumanager.h | 7 | ||||
-rw-r--r-- | demos/qtdemo/qtdemo.pro | 6 |
4 files changed, 33 insertions, 13 deletions
diff --git a/demos/qtdemo/mainwindow.h b/demos/qtdemo/mainwindow.h index e613268..b8cfda6 100644 --- a/demos/qtdemo/mainwindow.h +++ b/demos/qtdemo/mainwindow.h @@ -43,7 +43,6 @@ #define MAIN_WINDOW_H #include <QtGui> -#include <QtDeclarative> #include <QPixmap> class DemoTextItem; diff --git a/demos/qtdemo/menumanager.cpp b/demos/qtdemo/menumanager.cpp index 5b851b4..f98c2fc 100644 --- a/demos/qtdemo/menumanager.cpp +++ b/demos/qtdemo/menumanager.cpp @@ -356,6 +356,7 @@ void MenuManager::launchExample(const QString &name) void MenuManager::launchQmlExample(const QString &name) { +#ifndef QT_NO_DECLARATIVE if(!qmlRoot){ exampleError(QProcess::UnknownError); return; @@ -382,6 +383,11 @@ void MenuManager::launchQmlExample(const QString &name) qmlRoot->setProperty("qmlFile", QVariant(""));//unload component qmlRoot->setProperty("show", QVariant(true)); qmlRoot->setProperty("qmlFile", QUrl::fromLocalFile(file.fileName())); +#else + QMessageBox::critical(0, tr("Failed to launch the example"), + tr("This application was built without the QtDeclarative module, and therefore declarative examples have been disabled."), + QMessageBox::Cancel); +#endif } void MenuManager::exampleFinished() @@ -427,21 +433,26 @@ void MenuManager::init(MainWindow *window) level2MenuNode = level2MenuNode.nextSibling(); } + qmlRoot = 0; +#ifndef QT_NO_DECLARATIVE // Create QML Loader declarativeEngine = new QDeclarativeEngine(this); QDeclarativeComponent component(declarativeEngine, QUrl("qrc:qml/qmlShell.qml"), this); - qmlRoot = 0; - if(component.isReady()) - qmlRoot = qobject_cast<QDeclarativeItem*>(component.create()); - else + QDeclarativeItem* qmlRootItem = 0; + if(component.isReady()){ + qmlRoot = component.create(); + qmlRootItem = qobject_cast<QDeclarativeItem*>(qmlRoot); + }else{ qDebug() << component.status() << component.errorString(); - if(qmlRoot){ - qmlRoot->setHeight(this->window->scene->sceneRect().height()); - qmlRoot->setWidth(this->window->scene->sceneRect().width()); - qmlRoot->setZValue(101);//Above other items - qmlRoot->setCursor(Qt::ArrowCursor); - window->scene->addItem(qmlRoot); + } + + if(qmlRootItem){ + qmlRootItem->setHeight(this->window->scene->sceneRect().height()); + qmlRootItem->setWidth(this->window->scene->sceneRect().width()); + qmlRootItem->setZValue(101);//Above other items + qmlRootItem->setCursor(Qt::ArrowCursor); + window->scene->addItem(qmlRootItem); //Note that QML adds key handling to the app. window->viewport()->setFocusPolicy(Qt::NoFocus);//Correct keyboard focus handling @@ -451,6 +462,7 @@ void MenuManager::init(MainWindow *window) }else{ qDebug() << "Error initializing QML subsystem, Declarative examples will not work"; } +#endif } void MenuManager::readInfoAboutExample(const QDomElement &example) diff --git a/demos/qtdemo/menumanager.h b/demos/qtdemo/menumanager.h index 5e14204..e4303c8 100644 --- a/demos/qtdemo/menumanager.h +++ b/demos/qtdemo/menumanager.h @@ -45,6 +45,9 @@ #include <QtGui> #include <QtXml> #include <QtHelp/QHelpEngineCore> +#ifndef QT_NO_DECLARATIVE +#include <QtDeclarative> +#endif #include "score.h" #include "textbutton.h" @@ -83,8 +86,10 @@ public: Score *score; int currentMenuCode; + QObject *qmlRoot; +#ifndef QT_NO_DECLARATIVE QDeclarativeEngine* declarativeEngine; - QDeclarativeItem *qmlRoot; +#endif private slots: void exampleFinished(); diff --git a/demos/qtdemo/qtdemo.pro b/demos/qtdemo/qtdemo.pro index 61ea376..836178b 100644 --- a/demos/qtdemo/qtdemo.pro +++ b/demos/qtdemo/qtdemo.pro @@ -6,13 +6,17 @@ DESTDIR = $$DEMO_DESTDIR/bin INSTALLS += target sources -QT += xml network declarative +QT += xml network contains(QT_CONFIG, opengl) { DEFINES += QT_OPENGL_SUPPORT QT += opengl } +contains(QT_CONFIG, declarative) { + QT += declarative +} + build_all:!build_pass { CONFIG -= build_all CONFIG += release |