diff options
author | Roberto Raggi <roberto.raggi@nokia.com> | 2010-02-22 11:21:06 (GMT) |
---|---|---|
committer | Roberto Raggi <roberto.raggi@nokia.com> | 2010-02-22 11:21:06 (GMT) |
commit | 80fc5bf17e5f049a395d6a5612843c69c5b0fde1 (patch) | |
tree | e678ae163e415c5d1a0ef19b30dfbf53a26c3b38 /src/declarative/qml | |
parent | 3731e214baeb44434f12f773b1c68e772f25323e (diff) | |
download | Qt-80fc5bf17e5f049a395d6a5612843c69c5b0fde1.zip Qt-80fc5bf17e5f049a395d6a5612843c69c5b0fde1.tar.gz Qt-80fc5bf17e5f049a395d6a5612843c69c5b0fde1.tar.bz2 |
Introduced QmlEngine::importExtension.
importExtension can be used to import QmlExtensionInterface(s) into a QmlEngine.
Diffstat (limited to 'src/declarative/qml')
-rw-r--r-- | src/declarative/qml/qmlengine.cpp | 21 | ||||
-rw-r--r-- | src/declarative/qml/qmlengine.h | 1 |
2 files changed, 21 insertions, 1 deletions
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 7a60f9c..1f5caa5 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -67,7 +67,7 @@ #include "qmlnetworkaccessmanagerfactory.h" #include "qmlimageprovider.h" #include "qmldirparser_p.h" - +#include "qmlextensioninterface.h" #include <qfxperf_p_p.h> #include <QtCore/qmetaobject.h> @@ -82,6 +82,7 @@ #include <QDebug> #include <QMetaObject> #include <QStack> +#include <QPluginLoader> #include <QtCore/qlibraryinfo.h> #include <QtCore/qthreadstorage.h> #include <QtCore/qthread.h> @@ -1530,6 +1531,24 @@ void QmlEngine::addImportPath(const QString& path) } /*! + Imports the given \a extension into this QmlEngine. Returns + true if the extension was successfully imported. + + \sa QmlExtensionInterface +*/ +bool QmlEngine::importExtension(const QString &fileName) +{ + QPluginLoader loader(fileName); + + if (QmlExtensionInterface *iface = qobject_cast<QmlExtensionInterface *>(loader.instance())) { + iface->initialize(this); + return true; + } + + return false; +} + +/*! \property QmlEngine::offlineStoragePath \brief the directory for storing offline user data diff --git a/src/declarative/qml/qmlengine.h b/src/declarative/qml/qmlengine.h index 64d0b9d..13a67b0 100644 --- a/src/declarative/qml/qmlengine.h +++ b/src/declarative/qml/qmlengine.h @@ -78,6 +78,7 @@ public: void clearComponentCache(); void addImportPath(const QString& dir); + bool importExtension(const QString &fileName); void setNetworkAccessManagerFactory(QmlNetworkAccessManagerFactory *); QmlNetworkAccessManagerFactory *networkAccessManagerFactory() const; |