aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml')
-rw-r--r--src/qml/qml/qqmlengine.cpp8
-rw-r--r--src/qml/qml/qqmlimport.cpp5
-rw-r--r--src/qml/qml/qqmltypeloader.cpp5
3 files changed, 17 insertions, 1 deletions
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index 580aaf4899..f9b261b314 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -1610,7 +1610,13 @@ void QQmlEnginePrivate::dereferenceScarceResources()
/*!
Adds \a path as a directory where the engine searches for
installed modules in a URL-based directory structure.
- The \a path may be a local filesystem directory or a URL.
+
+ The \a path may be a local filesystem directory, a
+ \l {The Qt Resource System}{Qt Resource} path (\c {:/imports}), a
+ \l {The Qt Resource System}{Qt Resource} url (\c {qrc:/imports}) or a URL.
+
+ The \a path will be converted into canonical form before it
+ is added to the import path list.
The newly added \a path will be first in the importPathList().
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp
index 55c07ac35a..20da154673 100644
--- a/src/qml/qml/qqmlimport.cpp
+++ b/src/qml/qml/qqmlimport.cpp
@@ -1536,6 +1536,11 @@ void QQmlImportDatabase::addImportPath(const QString& path)
if (url.scheme() == QLatin1String("file")) {
cPath = QQmlFile::urlToLocalFileOrQrc(url);
+ } else if (path.startsWith(QLatin1Char(':'))) {
+ // qrc directory, e.g. :/foo
+ // need to convert to a qrc url, e.g. qrc:/foo
+ cPath = QStringLiteral("qrc") + path;
+ cPath.replace(Backslash, Slash);
} else if (url.isRelative() ||
(url.scheme().length() == 1 && QFile::exists(path)) ) { // windows path
QDir dir = QDir(path);
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index 1d7070675b..c66cd283da 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -1633,6 +1633,11 @@ QString QQmlTypeLoader::absoluteFilePath(const QString &path)
// qrc resource
QFileInfo fileInfo(path);
return fileInfo.isFile() ? fileInfo.absoluteFilePath() : QString();
+ } else if (path.count() > 3 && path.at(3) == QLatin1Char(':') &&
+ path.startsWith(QLatin1String("qrc"), Qt::CaseInsensitive)) {
+ // qrc resource url
+ QFileInfo fileInfo(QQmlFile::urlToLocalFileOrQrc(path));
+ return fileInfo.isFile() ? fileInfo.absoluteFilePath() : QString();
}
int lastSlash = path.lastIndexOf(QLatin1Char('/'));
QStringRef dirPath(&path, 0, lastSlash);