summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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/qmlShell.qml58
-rw-r--r--demos/qtdemo/qtdemo.pro6
5 files changed, 58 insertions, 46 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/qmlShell.qml b/demos/qtdemo/qmlShell.qml
index b5fdf39..b8a019e 100644
--- a/demos/qtdemo/qmlShell.qml
+++ b/demos/qtdemo/qmlShell.qml
@@ -100,6 +100,30 @@ Item {
}
}
+ Rectangle{ id: closeButton
+ width: 24
+ height: 24
+ z: 11
+ border.color: "#aaaaaaaa"
+ gradient: Gradient{
+ GradientStop{ position: 0.0; color: "#34FFFFFF" }
+ GradientStop{ position: 1.0; color: "#7AFFFFFF" }
+ }
+ anchors.left: frame.right
+ anchors.bottom: frame.top
+ anchors.margins: -(2*width/3)
+ Text{
+ text: 'X'
+ font.bold: true
+ color: "white"
+ font.pixelSize: 12
+ anchors.centerIn: parent
+ }
+ MouseArea{
+ anchors.fill: parent
+ onClicked: main.show = false;
+ }
+ }
Text{
id: errorTxt
@@ -116,32 +140,6 @@ Item {
onLinkActivated: Qt.openUrlExternally(link);
}
}
- Rectangle{
- id: helpLabel
- property bool timedOut: false
- z: 9
- //Positioned in the top left corner
- x: 8
- y: 8
- color: "white"
- border.color: "black"
- border.width: 1
- width: helpText.width + 16
- height: helpText.height + 8
- Text{
- id: helpText
- color: "black"
- anchors.centerIn: parent
- text: "Click outside the example to exit it."
- }
- opacity: 0
- Behavior on opacity{ NumberAnimation{duration:500} }
- Timer{
- id: helpTimer
- interval: 5000
- onTriggered: {helpLabel.timedOut=true}
- }
- }
Rectangle{ id: blackout //Maybe use a colorize effect instead?
z: 8
anchors.fill: parent
@@ -154,7 +152,6 @@ Item {
hoverEnabled: main.show //To steal focus from the buttons
acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
anchors.fill: parent
- onClicked: main.show=false;
}
states: [
@@ -166,10 +163,6 @@ Item {
opacity: 1
}
PropertyChanges {
- target: helpLabel
- opacity: helpLabel.timedOut?0:1
- }
- PropertyChanges {
target: blackout
opacity: 0.5
}
@@ -178,8 +171,7 @@ Item {
transitions: [//Should not be too long, because the component has already started running
Transition { from: ''; to: "show"; reversible: true
ParallelAnimation{
- ScriptAction{ script: {helpLabel.timedOut = false; helpTimer.restart();} }
- NumberAnimation{ exclude: helpLabel; properties: "opacity"; easing.type: Easing.InQuad; duration: 500}
+ NumberAnimation{ properties: "opacity"; easing.type: Easing.InQuad; duration: 500}
PropertyAction { target: loader; property: "focus"; value: true}//Might be needed to ensure the focus stays with us
}
}
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