From 80fc5bf17e5f049a395d6a5612843c69c5b0fde1 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Mon, 22 Feb 2010 12:21:06 +0100 Subject: Introduced QmlEngine::importExtension. importExtension can be used to import QmlExtensionInterface(s) into a QmlEngine. --- src/declarative/qml/qmlengine.cpp | 21 ++++++++++++++++++++- src/declarative/qml/qmlengine.h | 1 + 2 files changed, 21 insertions(+), 1 deletion(-) 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 #include @@ -82,6 +82,7 @@ #include #include #include +#include #include #include #include @@ -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(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; -- cgit v0.12