summaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2010-08-19 06:35:40 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2010-08-19 06:35:40 (GMT)
commit015b726aa46e774155bc13359dcd68d15df73bbd (patch)
treeab9ecf289258fe58e64ddc4b5999c86ab7dbfbbf /demos
parentceb068261e326f38b4049becd75c7160a6b84f87 (diff)
downloadQt-015b726aa46e774155bc13359dcd68d15df73bbd.zip
Qt-015b726aa46e774155bc13359dcd68d15df73bbd.tar.gz
Qt-015b726aa46e774155bc13359dcd68d15df73bbd.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
Diffstat (limited to 'demos')
-rw-r--r--demos/qtdemo/mainwindow.h1
-rw-r--r--demos/qtdemo/menumanager.cpp32
-rw-r--r--demos/qtdemo/menumanager.h7
-rw-r--r--demos/qtdemo/qtdemo.pro6
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