diff options
-rw-r--r-- | src/declarative/qml/qmlengine.cpp | 14 | ||||
-rw-r--r-- | src/declarative/qml/qmlengine.h | 3 | ||||
-rw-r--r-- | src/declarative/qml/qmlengine_p.h | 3 | ||||
-rw-r--r-- | src/declarative/util/qmlview.cpp | 1 | ||||
-rw-r--r-- | src/declarative/util/qmlview.h | 1 | ||||
-rw-r--r-- | tools/qmlviewer/qmlviewer.cpp | 1 |
6 files changed, 23 insertions, 0 deletions
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index c0692eb..864d07e 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -147,6 +147,7 @@ QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e) qtObject.setProperty(QLatin1String("md5"),scriptEngine.newFunction(md5, 1)); qtObject.setProperty(QLatin1String("btoa"),scriptEngine.newFunction(btoa, 1)); qtObject.setProperty(QLatin1String("atob"),scriptEngine.newFunction(atob, 1)); + qtObject.setProperty(QLatin1String("quit"), scriptEngine.newFunction(QmlEnginePrivate::quit, 0)); //firebug/webkit compat QScriptValue consoleObject = scriptEngine.newObject(); @@ -868,6 +869,19 @@ QScriptValue QmlEnginePrivate::consoleLog(QScriptContext *ctxt, QScriptEngine *e return e->newVariant(QVariant(true)); } +void QmlEnginePrivate::sendQuit () +{ + Q_Q(QmlEngine); + emit q->quit (); +} + +QScriptValue QmlEnginePrivate::quit(QScriptContext *ctxt, QScriptEngine *e) +{ + QmlEnginePrivate *qe = get (e); + qe->sendQuit (); + return QScriptValue(); +} + QScriptValue QmlEnginePrivate::closestAngle(QScriptContext *ctxt, QScriptEngine *e) { if(ctxt->argumentCount() < 2) diff --git a/src/declarative/qml/qmlengine.h b/src/declarative/qml/qmlengine.h index 0b18e94..7cbbcac 100644 --- a/src/declarative/qml/qmlengine.h +++ b/src/declarative/qml/qmlengine.h @@ -89,6 +89,9 @@ public: static QmlContext *contextForObject(const QObject *); static void setContextForObject(QObject *, QmlContext *); +Q_SIGNALS: + void quit (); + private: Q_DECLARE_PRIVATE(QmlEngine) }; diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h index 191be83..9e0c1fc 100644 --- a/src/declarative/qml/qmlengine_p.h +++ b/src/declarative/qml/qmlengine_p.h @@ -254,6 +254,8 @@ public: QScriptValue scriptValueFromVariant(const QVariant &); QVariant scriptValueToVariant(const QScriptValue &); + void sendQuit (); + static QScriptValue qmlScriptObject(QObject*, QmlEngine*); static QScriptValue createComponent(QScriptContext*, QScriptEngine*); @@ -276,6 +278,7 @@ public: static QScriptValue btoa(QScriptContext*, QScriptEngine*); static QScriptValue atob(QScriptContext*, QScriptEngine*); static QScriptValue consoleLog(QScriptContext*, QScriptEngine*); + static QScriptValue quit(QScriptContext*, QScriptEngine*); static QScriptEngine *getScriptEngine(QmlEngine *e) { return &e->d_func()->scriptEngine; } static QmlEngine *getEngine(QScriptEngine *e) { return static_cast<QmlScriptEngine*>(e)->p->q_func(); } diff --git a/src/declarative/util/qmlview.cpp b/src/declarative/util/qmlview.cpp index 62bcc07..afeead2 100644 --- a/src/declarative/util/qmlview.cpp +++ b/src/declarative/util/qmlview.cpp @@ -291,6 +291,7 @@ void QmlView::execute() } else { d->component = new QmlComponent(&d->engine, d->qml.toUtf8(), d->source, this); } + connect (&d->engine, SIGNAL (quit ()), this, SIGNAL (quit ())); if (!d->component->isLoading()) { continueExecute(); diff --git a/src/declarative/util/qmlview.h b/src/declarative/util/qmlview.h index 83c4f97..f4f58fd 100644 --- a/src/declarative/util/qmlview.h +++ b/src/declarative/util/qmlview.h @@ -90,6 +90,7 @@ Q_SIGNALS: void initialSize(QSize size); void sceneResized(QSize size); void errors(const QList<QmlError> &error); + void quit (); private Q_SLOTS: void continueExecute(); diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index ea0936b..6130ade 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -340,6 +340,7 @@ QmlViewer::QmlViewer(QWidget *parent, Qt::WindowFlags flags) QObject::connect(canvas, SIGNAL(sceneResized(QSize)), this, SLOT(sceneResized(QSize))); QObject::connect(canvas, SIGNAL(initialSize(QSize)), this, SLOT(adjustSizeSlot())); QObject::connect(canvas, SIGNAL(errors(QList<QmlError>)), this, SLOT(executeErrors())); + QObject::connect(canvas, SIGNAL(quit()), QCoreApplication::instance (), SLOT(quit())); if (!(flags & Qt::FramelessWindowHint)) createMenu(menuBar(),0); |