catch file types by extension too
This commit is contained in:
parent
6d65ece95a
commit
d567b3414b
|
@ -42,12 +42,11 @@ QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlIntercept
|
|||
return path;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case QQmlAbstractUrlInterceptor::QmlFile:
|
||||
case QQmlAbstractUrlInterceptor::JavaScriptFile:
|
||||
if (type != QQmlAbstractUrlInterceptor::QmldirFile) {
|
||||
|
||||
//asked a file inside a package: let's rewrite the url!
|
||||
if (path.path().startsWith(m_package.path())) {
|
||||
qDebug() << "Found URL in package" << path;
|
||||
//qDebug() << "Found URL in package" << path;
|
||||
|
||||
//tries to isolate the relative path asked relative to the contentsPrefixPath: like ui/foo.qml
|
||||
QString relativePath;
|
||||
|
@ -83,10 +82,6 @@ QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlIntercept
|
|||
}
|
||||
qWarning() << "WARNING: Access denied for URL" << path;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return path;
|
||||
|
|
|
@ -44,7 +44,23 @@ public:
|
|||
default:
|
||||
break;
|
||||
}
|
||||
return "";
|
||||
|
||||
//failed by type, let's try by extension
|
||||
const QString extension = fileName.mid(fileName.lastIndexOf(".") + 1).toLower();
|
||||
|
||||
if (extension == "svg" || extension == "svgz" ||
|
||||
extension == "png" || extension == "gif" ||
|
||||
extension == "jpg" || extension == "jpeg") {
|
||||
return "images";
|
||||
//FIXME: are those necessary? are they *always* catched by type?
|
||||
} else if (extension == "js") {
|
||||
return "scripts";
|
||||
} else if (extension == "qml") {
|
||||
return "ui";
|
||||
//everything else, throw it in "data"
|
||||
} else {
|
||||
return "data";
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue
Block a user