aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmltypeloader.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>2013-04-04 16:17:35 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-05 12:28:25 +0200
commit6eed3409c4ecf69d3c43cdcbeeca829624b9fe25 (patch)
treee342ac85f4bd6267a1618f2f6fff44fe381ee03c /src/qml/qml/qqmltypeloader.cpp
parente5d9cb4f3534e2d2fe6d28867b71c87ccb1438db (diff)
Android: Support implicit import paths for assets:/ urls
The assets: scheme is not handled by QNetworkAccessManager, so it needs to be special cased along side the qrc: scheme. We make QML recognize it as a synchronously loaded, local file, and we make the type loader get the correct path and check existence of the directory correctly. This makes it possible to implicitly import the containing directory of QML files that are bundled in the assets directory. Task-number: QTBUG-30510 Change-Id: I048292757e509066a4af342081ec8428e2bd8af3 Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
Diffstat (limited to 'src/qml/qml/qqmltypeloader.cpp')
-rw-r--r--src/qml/qml/qqmltypeloader.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index e800eb815d..bbce8e625e 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -1659,6 +1659,15 @@ QString QQmlTypeLoader::absoluteFilePath(const QString &path)
QFileInfo fileInfo(QQmlFile::urlToLocalFileOrQrc(path));
return fileInfo.isFile() ? fileInfo.absoluteFilePath() : QString();
}
+#if defined(Q_OS_ANDROID)
+ else if (path.count() > 7 && path.at(6) == QLatin1Char(':') && path.at(7) == QLatin1Char('/') &&
+ path.startsWith(QLatin1String("assets"), Qt::CaseInsensitive)) {
+ // assets resource url
+ QFileInfo fileInfo(QQmlFile::urlToLocalFileOrQrc(path));
+ return fileInfo.isFile() ? fileInfo.absoluteFilePath() : QString();
+ }
+#endif
+
int lastSlash = path.lastIndexOf(QLatin1Char('/'));
QStringRef dirPath(&path, 0, lastSlash);
@@ -1717,7 +1726,13 @@ bool QQmlTypeLoader::directoryExists(const QString &path)
{
if (path.isEmpty())
return false;
- if (path.at(0) == QLatin1Char(':')) {
+
+ bool isResource = path.at(0) == QLatin1Char(':');
+#if defined(Q_OS_ANDROID)
+ isResource = isResource || path.startsWith(QLatin1String("assets:/"));
+#endif
+
+ if (isResource) {
// qrc resource
QFileInfo fileInfo(path);
return fileInfo.exists() && fileInfo.isDir();