From db63beeb4d421e98d851f4f837ad978e0f04d9aa Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Fri, 20 Aug 2010 15:18:43 +1000 Subject: Allow QML Quit buttons to work inside QtDemo. Also changes the line documenting the quit signal on QDeclarativeEngine. --- demos/qtdemo/menumanager.cpp | 8 ++++++++ demos/qtdemo/menumanager.h | 2 ++ demos/qtdemo/qmlShell.qml | 2 -- src/declarative/qml/qdeclarativeengine.cpp | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/demos/qtdemo/menumanager.cpp b/demos/qtdemo/menumanager.cpp index f98c2fc..4ae9ca1 100644 --- a/demos/qtdemo/menumanager.cpp +++ b/demos/qtdemo/menumanager.cpp @@ -390,6 +390,12 @@ void MenuManager::launchQmlExample(const QString &name) #endif } +void MenuManager::quitQML() +{ + if(qmlRoot) + qmlRoot->setProperty("show", QVariant(false)); +} + void MenuManager::exampleFinished() { } @@ -437,6 +443,8 @@ void MenuManager::init(MainWindow *window) #ifndef QT_NO_DECLARATIVE // Create QML Loader declarativeEngine = new QDeclarativeEngine(this); + connect(declarativeEngine, SIGNAL(quit()), + this, SLOT(quitQML())); QDeclarativeComponent component(declarativeEngine, QUrl("qrc:qml/qmlShell.qml"), this); QDeclarativeItem* qmlRootItem = 0; diff --git a/demos/qtdemo/menumanager.h b/demos/qtdemo/menumanager.h index e4303c8..93fb998 100644 --- a/demos/qtdemo/menumanager.h +++ b/demos/qtdemo/menumanager.h @@ -95,6 +95,8 @@ private slots: void exampleFinished(); void exampleError(QProcess::ProcessError error); + void quitQML(); + private: // singleton pattern: MenuManager(); diff --git a/demos/qtdemo/qmlShell.qml b/demos/qtdemo/qmlShell.qml index b8a019e..24c12ae 100644 --- a/demos/qtdemo/qmlShell.qml +++ b/demos/qtdemo/qmlShell.qml @@ -68,8 +68,6 @@ Item { loader.item.width = 640; if(loader.item.height > 480) loader.item.height = 480; - if(loader.item.inAnotherDemo != undefined) - loader.item.inAnotherDemo = true; }} } diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index bc7468f..cedf9d5 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -551,7 +551,7 @@ QDeclarativeEngine::~QDeclarativeEngine() } /*! \fn void QDeclarativeEngine::quit() - This signal is emitted when the QDeclarativeEngine quits. + This signal is emitted when the QML loaded by the engine would like to quit. */ /*! \fn void QDeclarativeEngine::warnings(const QList &warnings) -- cgit v0.12