use the interceptor on views too

relax its rules a bit and alter it to make it work with shell packages too
This commit is contained in:
Marco Martin 2014-05-23 20:02:35 +02:00
parent 249c1e1c93
commit d4b4a9558f
2 changed files with 16 additions and 2 deletions

View File

@ -103,10 +103,19 @@ QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlIntercept
const QString &filename = components.join("/");
//qDebug() << "Returning" << QUrl::fromLocalFile(m_package.filePath(prefixForType(type, filename), filename));
return QUrl::fromLocalFile(m_package.filePath(prefixForType(type, filename), filename));
QUrl ret = QUrl::fromLocalFile(m_package.filePath(prefixForType(type, filename), filename));
if (ret.path().isEmpty()) {
return path;
}
return ret;
//forbid to load random absolute paths
} else {
if (m_package.allowExternalPaths()) {
return path;
}
foreach (const QString &allowed, m_allowedPaths) {
//It's a private import
if (path.path().contains("org/kde/plasma/private")) {

View File

@ -24,8 +24,10 @@
#include <QQmlContext>
#include <QTimer>
#include <QScreen>
#include <QQmlEngine>
#include "plasma/pluginloader.h"
#include <packageurlinterceptor.h>
namespace PlasmaQuick
{
@ -164,7 +166,10 @@ View::View(Plasma::Corona *corona, QWindow *parent)
QObject::connect(screen(), &QScreen::geometryChanged,
this, &View::screenGeometryChanged);
if (!corona->package().isValid()) {
if (corona->package().isValid()) {
PackageUrlInterceptor *interceptor = new PackageUrlInterceptor(engine(), corona->package());
engine()->setUrlInterceptor(interceptor);
} else {
qWarning() << "Invalid home screen package";
}