From 015b726aa46e774155bc13359dcd68d15df73bbd Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 19 Aug 2010 16:35:40 +1000 Subject: 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 --- demos/qtdemo/mainwindow.h | 1 - demos/qtdemo/menumanager.cpp | 32 ++++++++++++++++++++++---------- demos/qtdemo/menumanager.h | 7 ++++++- 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 -#include #include 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(component.create()); - else + QDeclarativeItem* qmlRootItem = 0; + if(component.isReady()){ + qmlRoot = component.create(); + qmlRootItem = qobject_cast(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 #include #include +#ifndef QT_NO_DECLARATIVE +#include +#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 -- cgit v0.12