summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorRoberto Raggi <roberto.raggi@nokia.com>2010-02-23 11:48:16 (GMT)
committerRoberto Raggi <roberto.raggi@nokia.com>2010-02-23 11:48:16 (GMT)
commit5eb3c2fc8f90509cb368ab56f14364d6e17844f1 (patch)
treeb496b6e8d48935a9745ff2c8ec4954ebf082f0b0 /src/declarative
parentd9a390c6d5f18f335fa0a4766180ffa62f28c363 (diff)
downloadQt-5eb3c2fc8f90509cb368ab56f14364d6e17844f1.zip
Qt-5eb3c2fc8f90509cb368ab56f14364d6e17844f1.tar.gz
Qt-5eb3c2fc8f90509cb368ab56f14364d6e17844f1.tar.bz2
Look for QML plugins in the paths specified in QML_PLUGIN_PATH env var.
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/qml/qmlengine.cpp30
-rw-r--r--src/declarative/qml/qmlengine_p.h3
-rw-r--r--src/declarative/qml/qmlextensioninterface.h2
-rw-r--r--src/declarative/qml/qmlextensionplugin.h2
4 files changed, 31 insertions, 6 deletions
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index 98e16aa..a7c3d08 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -158,6 +158,21 @@ QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e)
}
globalClass = new QmlGlobalScriptClass(&scriptEngine);
fileImportPath.append(QLibraryInfo::location(QLibraryInfo::DataPath)+QDir::separator()+QLatin1String("qml"));
+
+ // env import paths
+ QByteArray envImportPath = qgetenv("QML_IMPORT_PATH");
+ if (!envImportPath.isEmpty()) {
+#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
+ QLatin1Char pathSep(';');
+#else
+ QLatin1Char pathSep(':');
+#endif
+ foreach (const QString &path, QString::fromLatin1(envImportPath).split(pathSep, QString::SkipEmptyParts)) {
+ QString canonicalPath = QDir(path).canonicalPath();
+ if (!canonicalPath.isEmpty() && !environmentImportPath.contains(canonicalPath))
+ environmentImportPath.append(canonicalPath);
+ }
+ }
}
QUrl QmlScriptEngine::resolvedUrl(QScriptContext *context, const QUrl& url)
@@ -1334,9 +1349,16 @@ public:
url.replace(QLatin1Char('.'), QLatin1Char('/'));
bool found = false;
QString content;
- QString dir;
- QStringList paths = importPath;
- paths.prepend(QFileInfo(base.toLocalFile()).path());
+ QString dir;
+
+ // user import paths
+ QStringList paths;
+
+ // base..
+ paths += QFileInfo(base.toLocalFile()).path();
+ paths += importPath;
+ paths += QmlEnginePrivate::get(engine)->environmentImportPath;
+
foreach (const QString &p, paths) {
dir = p+QLatin1Char('/')+url;
QFileInfo fi(dir+QLatin1String("/qmldir"));
@@ -1575,7 +1597,7 @@ bool QmlEngine::importExtension(const QString &fileName, const QString &uri)
QPluginLoader loader(fileName);
if (QmlExtensionInterface *iface = qobject_cast<QmlExtensionInterface *>(loader.instance())) {
- iface->initialize(this, uri);
+ iface->initialize(this, uri.toUtf8().constData());
return true;
}
diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h
index 53a88b1..85c5fbe 100644
--- a/src/declarative/qml/qmlengine_p.h
+++ b/src/declarative/qml/qmlengine_p.h
@@ -264,6 +264,9 @@ public:
QmlImportsPrivate *d;
};
+
+ QStringList environmentImportPath;
+
QString resolvePlugin(const QDir &dir, const QString &baseName,
const QStringList &suffixes,
const QString &prefix = QString());
diff --git a/src/declarative/qml/qmlextensioninterface.h b/src/declarative/qml/qmlextensioninterface.h
index cbdd34c..b993e82 100644
--- a/src/declarative/qml/qmlextensioninterface.h
+++ b/src/declarative/qml/qmlextensioninterface.h
@@ -54,7 +54,7 @@ class QmlEngine;
struct Q_DECLARATIVE_EXPORT QmlExtensionInterface
{
- virtual void initialize(QmlEngine *engine, const QString &uri) = 0;
+ virtual void initialize(QmlEngine *engine, const char *uri) = 0;
};
Q_DECLARE_INTERFACE(QmlExtensionInterface, "com.trolltech.Qt.QmlExtensionInterface/1.0")
diff --git a/src/declarative/qml/qmlextensionplugin.h b/src/declarative/qml/qmlextensionplugin.h
index 82553e7..8cc64ad 100644
--- a/src/declarative/qml/qmlextensionplugin.h
+++ b/src/declarative/qml/qmlextensionplugin.h
@@ -62,7 +62,7 @@ public:
explicit QmlExtensionPlugin(QObject *parent = 0);
~QmlExtensionPlugin();
- virtual void initialize(QmlEngine *engine, const QString &uri) = 0;
+ virtual void initialize(QmlEngine *engine, const char *uri) = 0;
};
QT_END_NAMESPACE