diff options
author | Tapani Mikola <tapani.mikola@nokia.com> | 2009-11-26 07:30:55 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-11-30 06:34:29 (GMT) |
commit | bd2ba54d85415047a581b7b441309572a756dcc5 (patch) | |
tree | 28442cc914bd9ac77b42382094fc8a36341a6b89 /src/declarative | |
parent | c8cb256644c143f9d85eed0a8d295ffd05a2017d (diff) | |
download | Qt-bd2ba54d85415047a581b7b441309572a756dcc5.zip Qt-bd2ba54d85415047a581b7b441309572a756dcc5.tar.gz Qt-bd2ba54d85415047a581b7b441309572a756dcc5.tar.bz2 |
Qt.quit() added to qml.
Diffstat (limited to 'src/declarative')
-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 |
5 files changed, 22 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(); |