From fce17c2847fa48410adae098b1df3db76fa4ef67 Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Thu, 26 Aug 2010 15:08:41 +1000 Subject: Fix application exiting in embedded qml examples Task-number: QTBUG-13178 Reviewed-by: Martin Jones --- demos/embedded/qmlcalculator/qmlcalculator.cpp | 4 +++- demos/embedded/qmlclocks/qmlclocks.cpp | 2 ++ demos/embedded/qmldialcontrol/qmldialcontrol.cpp | 2 ++ demos/embedded/qmleasing/deployment.pri | 2 +- demos/embedded/qmleasing/qmleasing.cpp | 2 ++ demos/embedded/qmlflickr/qmlflickr.cpp | 4 +++- demos/embedded/qmlphotoviewer/qmlphotoviewer.cpp | 2 ++ demos/embedded/qmltwitter/qmltwitter.cpp | 3 ++- .../animation/easing/content/QuitButton.qml | 12 ++++++++++++ .../declarative/animation/easing/content/quit.png | Bin 0 -> 583 bytes examples/declarative/animation/easing/easing.qml | 19 ++++++++++++++++--- examples/declarative/toys/clocks/clocks.qml | 5 +++++ .../declarative/toys/clocks/content/QuitButton.qml | 12 ++++++++++++ examples/declarative/toys/clocks/content/quit.png | Bin 0 -> 583 bytes .../ui-components/dialcontrol/content/QuitButton.qml | 12 ++++++++++++ .../ui-components/dialcontrol/content/quit.png | Bin 0 -> 583 bytes .../ui-components/dialcontrol/dialcontrol.qml | 5 +++++ src/declarative/qml/qdeclarativeengine.cpp | 3 +++ 18 files changed, 82 insertions(+), 7 deletions(-) create mode 100644 examples/declarative/animation/easing/content/QuitButton.qml create mode 100644 examples/declarative/animation/easing/content/quit.png create mode 100644 examples/declarative/toys/clocks/content/QuitButton.qml create mode 100644 examples/declarative/toys/clocks/content/quit.png create mode 100644 examples/declarative/ui-components/dialcontrol/content/QuitButton.qml create mode 100644 examples/declarative/ui-components/dialcontrol/content/quit.png diff --git a/demos/embedded/qmlcalculator/qmlcalculator.cpp b/demos/embedded/qmlcalculator/qmlcalculator.cpp index 3030e81..6c41e61 100644 --- a/demos/embedded/qmlcalculator/qmlcalculator.cpp +++ b/demos/embedded/qmlcalculator/qmlcalculator.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #if defined(Q_OS_SYMBIAN) #include @@ -58,7 +59,8 @@ int main(int argc, char *argv[]) QDeclarativeView view; view.setSource(QUrl(mainQmlApp)); view.setResizeMode(QDeclarativeView::SizeRootObjectToView); - + QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit())); + #if defined(QT_KEYPAD_NAVIGATION) QApplication::setNavigationMode(Qt::NavigationModeCursorAuto); #endif // QT_KEYPAD_NAVIGATION diff --git a/demos/embedded/qmlclocks/qmlclocks.cpp b/demos/embedded/qmlclocks/qmlclocks.cpp index d94cbdd..a09801b 100644 --- a/demos/embedded/qmlclocks/qmlclocks.cpp +++ b/demos/embedded/qmlclocks/qmlclocks.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #if defined(Q_OS_SYMBIAN) #include @@ -58,6 +59,7 @@ int main(int argc, char *argv[]) QDeclarativeView view; view.setSource(QUrl(mainQmlApp)); view.setResizeMode(QDeclarativeView::SizeRootObjectToView); + QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit())); #if defined(QT_KEYPAD_NAVIGATION) QApplication::setNavigationMode(Qt::NavigationModeCursorAuto); diff --git a/demos/embedded/qmldialcontrol/qmldialcontrol.cpp b/demos/embedded/qmldialcontrol/qmldialcontrol.cpp index 311cee0..56b21d7 100644 --- a/demos/embedded/qmldialcontrol/qmldialcontrol.cpp +++ b/demos/embedded/qmldialcontrol/qmldialcontrol.cpp @@ -42,6 +42,7 @@ #include #include #include +#include int main(int argc, char *argv[]) { @@ -51,6 +52,7 @@ int main(int argc, char *argv[]) QDeclarativeView view; view.setSource(QUrl(mainQmlApp)); view.setResizeMode(QDeclarativeView::SizeRootObjectToView); + QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit())); #if defined(QT_KEYPAD_NAVIGATION) QApplication::setNavigationMode(Qt::NavigationModeCursorAuto); diff --git a/demos/embedded/qmleasing/deployment.pri b/demos/embedded/qmleasing/deployment.pri index 984f5c8..d3621cb 100644 --- a/demos/embedded/qmleasing/deployment.pri +++ b/demos/embedded/qmleasing/deployment.pri @@ -4,5 +4,5 @@ symbian { qmleasing_uid3 = A000E3FE qmleasing_files.path = $$APP_PRIVATE_DIR_BASE/$$qmleasing_uid3 } -qmleasing_files.sources = $$qmleasing_src/easing.qml +qmleasing_files.sources = $$qmleasing_src/easing.qml $$qmleasing_src/content DEPLOYMENT += qmleasing_files diff --git a/demos/embedded/qmleasing/qmleasing.cpp b/demos/embedded/qmleasing/qmleasing.cpp index d326468..713fe67 100644 --- a/demos/embedded/qmleasing/qmleasing.cpp +++ b/demos/embedded/qmleasing/qmleasing.cpp @@ -42,6 +42,7 @@ #include #include #include +#include int main(int argc, char *argv[]) { @@ -51,6 +52,7 @@ int main(int argc, char *argv[]) QDeclarativeView view; view.setSource(QUrl(mainQmlApp)); view.setResizeMode(QDeclarativeView::SizeRootObjectToView); + QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit())); #if defined(QT_KEYPAD_NAVIGATION) QApplication::setNavigationMode(Qt::NavigationModeCursorAuto); diff --git a/demos/embedded/qmlflickr/qmlflickr.cpp b/demos/embedded/qmlflickr/qmlflickr.cpp index 7068f88..c05806c 100644 --- a/demos/embedded/qmlflickr/qmlflickr.cpp +++ b/demos/embedded/qmlflickr/qmlflickr.cpp @@ -48,6 +48,7 @@ #include #include #include +#include // Factory to create QNetworkAccessManagers that use the saved network configuration; otherwise // the system default. @@ -95,7 +96,8 @@ int main(int argc, char *argv[]) view.engine()->setNetworkAccessManagerFactory(&networkAccessManagerFactory); view.setSource(QUrl(mainQmlApp)); view.setResizeMode(QDeclarativeView::SizeRootObjectToView); - + QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit())); + #if defined(Q_OS_SYMBIAN) view.showFullScreen(); #else // Q_OS_SYMBIAN diff --git a/demos/embedded/qmlphotoviewer/qmlphotoviewer.cpp b/demos/embedded/qmlphotoviewer/qmlphotoviewer.cpp index 2b9db5e..d9cf67c 100644 --- a/demos/embedded/qmlphotoviewer/qmlphotoviewer.cpp +++ b/demos/embedded/qmlphotoviewer/qmlphotoviewer.cpp @@ -96,6 +96,8 @@ int main(int argc, char *argv[]) view.setSource(QUrl(mainQmlApp)); view.setResizeMode(QDeclarativeView::SizeRootObjectToView); + QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit())); + #if defined(Q_OS_SYMBIAN) view.showFullScreen(); #else // Q_OS_SYMBIAN diff --git a/demos/embedded/qmltwitter/qmltwitter.cpp b/demos/embedded/qmltwitter/qmltwitter.cpp index c53098a4..30c4601 100644 --- a/demos/embedded/qmltwitter/qmltwitter.cpp +++ b/demos/embedded/qmltwitter/qmltwitter.cpp @@ -95,7 +95,8 @@ int main(int argc, char *argv[]) view.engine()->setNetworkAccessManagerFactory(&networkAccessManagerFactory); view.setSource(QUrl(mainQmlApp)); view.setResizeMode(QDeclarativeView::SizeRootObjectToView); - + QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit())); + #if defined(Q_OS_SYMBIAN) view.showFullScreen(); #else // Q_OS_SYMBIAN diff --git a/examples/declarative/animation/easing/content/QuitButton.qml b/examples/declarative/animation/easing/content/QuitButton.qml new file mode 100644 index 0000000..70747a8 --- /dev/null +++ b/examples/declarative/animation/easing/content/QuitButton.qml @@ -0,0 +1,12 @@ +import Qt 4.7 +Image { + source: "quit.png" + scale: quitMouse.pressed ? 0.8 : 1.0 + smooth: quitMouse.pressed + MouseArea { + id: quitMouse + anchors.fill: parent + anchors.margins: -10 + onClicked: Qt.quit() + } +} \ No newline at end of file diff --git a/examples/declarative/animation/easing/content/quit.png b/examples/declarative/animation/easing/content/quit.png new file mode 100644 index 0000000..b822057 Binary files /dev/null and b/examples/declarative/animation/easing/content/quit.png differ diff --git a/examples/declarative/animation/easing/easing.qml b/examples/declarative/animation/easing/easing.qml index 9cdbad1..b53cb98 100644 --- a/examples/declarative/animation/easing/easing.qml +++ b/examples/declarative/animation/easing/easing.qml @@ -39,6 +39,7 @@ ****************************************************************************/ import Qt 4.7 +import "content" Rectangle { id: window @@ -134,11 +135,23 @@ Rectangle { } Flickable { - anchors.fill: parent; contentHeight: layout.height - + anchors.fill: parent + contentHeight: layout.height + Rectangle { + id: titlePane + color: "#444444" + height: 35 + anchors { top: parent.top; left: parent.left; right: parent.right } + QuitButton { + id: quitButton + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + anchors.rightMargin: 10 + } + } Column { id: layout - anchors.left: parent.left; anchors.right: parent.right + anchors { top: titlePane.bottom; topMargin: 10; left: parent.left; right: parent.right } Repeater { model: easingTypes; delegate: delegate } } } diff --git a/examples/declarative/toys/clocks/clocks.qml b/examples/declarative/toys/clocks/clocks.qml index 124e391..82a1dbf 100644 --- a/examples/declarative/toys/clocks/clocks.qml +++ b/examples/declarative/toys/clocks/clocks.qml @@ -51,4 +51,9 @@ Rectangle { Clock { city: "Mumbai"; shift: 5.5 } Clock { city: "Tokyo"; shift: 9 } } + QuitButton { + anchors.right: parent.right + anchors.top: parent.top + anchors.margins: 10 + } } diff --git a/examples/declarative/toys/clocks/content/QuitButton.qml b/examples/declarative/toys/clocks/content/QuitButton.qml new file mode 100644 index 0000000..70747a8 --- /dev/null +++ b/examples/declarative/toys/clocks/content/QuitButton.qml @@ -0,0 +1,12 @@ +import Qt 4.7 +Image { + source: "quit.png" + scale: quitMouse.pressed ? 0.8 : 1.0 + smooth: quitMouse.pressed + MouseArea { + id: quitMouse + anchors.fill: parent + anchors.margins: -10 + onClicked: Qt.quit() + } +} \ No newline at end of file diff --git a/examples/declarative/toys/clocks/content/quit.png b/examples/declarative/toys/clocks/content/quit.png new file mode 100644 index 0000000..b822057 Binary files /dev/null and b/examples/declarative/toys/clocks/content/quit.png differ diff --git a/examples/declarative/ui-components/dialcontrol/content/QuitButton.qml b/examples/declarative/ui-components/dialcontrol/content/QuitButton.qml new file mode 100644 index 0000000..70747a8 --- /dev/null +++ b/examples/declarative/ui-components/dialcontrol/content/QuitButton.qml @@ -0,0 +1,12 @@ +import Qt 4.7 +Image { + source: "quit.png" + scale: quitMouse.pressed ? 0.8 : 1.0 + smooth: quitMouse.pressed + MouseArea { + id: quitMouse + anchors.fill: parent + anchors.margins: -10 + onClicked: Qt.quit() + } +} \ No newline at end of file diff --git a/examples/declarative/ui-components/dialcontrol/content/quit.png b/examples/declarative/ui-components/dialcontrol/content/quit.png new file mode 100644 index 0000000..b822057 Binary files /dev/null and b/examples/declarative/ui-components/dialcontrol/content/quit.png differ diff --git a/examples/declarative/ui-components/dialcontrol/dialcontrol.qml b/examples/declarative/ui-components/dialcontrol/dialcontrol.qml index 46cc3e6..a7da5c6 100644 --- a/examples/declarative/ui-components/dialcontrol/dialcontrol.qml +++ b/examples/declarative/ui-components/dialcontrol/dialcontrol.qml @@ -88,5 +88,10 @@ Rectangle { } } } + QuitButton { + anchors.right: parent.right + anchors.top: parent.top + anchors.margins: 10 + } } //! [0] diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index c5a5c18..0fe1ea3 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -1716,6 +1716,9 @@ void QDeclarativeEnginePrivate::sendQuit() { Q_Q(QDeclarativeEngine); emit q->quit(); + if (q->receivers(SIGNAL(quit())) == 0) { + qWarning("Signal QDeclarativeEngine::quit() emitted, but no receivers connected to handle it."); + } } static void dumpwarning(const QDeclarativeError &error) -- cgit v0.12