static QQmlNetworkAccessManagerFactory creator in urlinterceptor
Adding this one static to PackageUrlInterceptor allows us to hide it otherwise from the API. Files can also move into private subdir, and the factory header isn't installed anymore.
This commit is contained in:
parent
c42974f52e
commit
48d9bcb9f5
@ -4,10 +4,10 @@ set(plasmaquick_LIB_SRC
|
||||
plasmaquickview.cpp
|
||||
configmodel.cpp
|
||||
configview.cpp
|
||||
private/configcategory_p.cpp
|
||||
packageaccessmanager.cpp
|
||||
packageaccessmanagerfactory.cpp
|
||||
packageurlinterceptor.cpp
|
||||
private/configcategory_p.cpp
|
||||
private/packageaccessmanager.cpp
|
||||
private/packageaccessmanagerfactory.cpp
|
||||
#private/containmentconfigview_p.cpp
|
||||
#private/currentcontainmentactionsmodel_p.cpp
|
||||
)
|
||||
@ -41,7 +41,6 @@ set(plasmaquick_LIB_INCLUDES
|
||||
plasmaquickview.h
|
||||
configview.h
|
||||
configmodel.h
|
||||
packageaccessmanagerfactory.h # temporary, remove once folded into urlinterceptor
|
||||
packageurlinterceptor.h
|
||||
)
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "packageurlinterceptor.h"
|
||||
#include "private/packageaccessmanagerfactory.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QQmlEngine>
|
||||
@ -90,7 +91,7 @@ QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlIntercept
|
||||
qDebug() << "Trying" << platform;
|
||||
|
||||
//search for a platformqml/ path sibling of this import path
|
||||
QString platformPath = import+"/../platformqml/"+platform+path.path().mid(import.length());
|
||||
QString platformPath = import+QStringLiteral("/../platformqml/")+platform+path.path().mid(import.length());
|
||||
QFile f(platformPath);
|
||||
|
||||
qDebug() << "Found a platform specific file:" << QUrl::fromLocalFile(platformPath)<<f.exists();
|
||||
@ -108,5 +109,9 @@ QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlIntercept
|
||||
return path;
|
||||
}
|
||||
|
||||
QQmlNetworkAccessManagerFactory* PackageUrlInterceptor::createPackageAccessManagerFactory(const Plasma::Package& package)
|
||||
{
|
||||
return new PackageAccessManagerFactory(package);
|
||||
}
|
||||
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#define PACKAGEURLINTERCEPTOR_H
|
||||
|
||||
#include <QQmlAbstractUrlInterceptor>
|
||||
#include <QQmlNetworkAccessManagerFactory>
|
||||
|
||||
#include <plasmaquick/plasmaquick_export.h>
|
||||
|
||||
@ -37,6 +38,8 @@ public:
|
||||
|
||||
virtual QUrl intercept(const QUrl &path, QQmlAbstractUrlInterceptor::DataType type);
|
||||
|
||||
static QQmlNetworkAccessManagerFactory* createPackageAccessManagerFactory(const Plasma::Package &package);
|
||||
|
||||
static inline QByteArray prefixForType(QQmlAbstractUrlInterceptor::DataType type, const QString &fileName)
|
||||
{
|
||||
switch (type) {
|
||||
|
@ -1,66 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Research In Motion.
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the QtQml module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
//Private API for 5.1 (at least)
|
||||
#ifndef QQMLABSTRACTURLINTERCEPTOR_H
|
||||
#define QQMLABSTRACTURLINTERCEPTOR_H
|
||||
|
||||
#include <QtCore/qurl.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QQmlAbstractUrlInterceptor
|
||||
{
|
||||
Q_FLAGS(InterceptionPoint)
|
||||
public:
|
||||
enum DataType { //Matches QQmlDataBlob::Type
|
||||
QmlFile = 0,
|
||||
JavaScriptFile = 1,
|
||||
QmldirFile = 2,
|
||||
UrlString = 0x1000
|
||||
};
|
||||
|
||||
QQmlAbstractUrlInterceptor() {}
|
||||
virtual ~QQmlAbstractUrlInterceptor() {}
|
||||
virtual QUrl intercept(const QUrl &path, DataType type) = 0;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
#endif
|
@ -47,7 +47,7 @@
|
||||
#include "containmentinterface.h"
|
||||
#include <kdeclarative/configpropertymap.h>
|
||||
#include <kdeclarative/qmlobject.h>
|
||||
#include <packageaccessmanagerfactory.h>
|
||||
|
||||
#include <packageurlinterceptor.h>
|
||||
|
||||
Q_DECLARE_METATYPE(AppletInterface*)
|
||||
@ -110,7 +110,8 @@ void AppletInterface::init()
|
||||
QQmlNetworkAccessManagerFactory *factory = engine->networkAccessManagerFactory();
|
||||
engine->setNetworkAccessManagerFactory(0);
|
||||
delete factory;
|
||||
engine->setNetworkAccessManagerFactory(new PackageAccessManagerFactory(m_appletScriptEngine->package()));
|
||||
//engine->setNetworkAccessManagerFactory(new PackageAccessManagerFactory(m_appletScriptEngine->package()));
|
||||
engine->setNetworkAccessManagerFactory(PackageUrlInterceptor::createPackageAccessManagerFactory(m_appletScriptEngine->package()));
|
||||
|
||||
//Hook generic url resolution to the applet package as well
|
||||
//TODO: same thing will have to be done for every qqmlengine: PackageUrlInterceptor is material for plasmaquick?
|
||||
|
@ -46,7 +46,6 @@
|
||||
#include "plasmoid/containmentinterface.h"
|
||||
|
||||
#include <kdeclarative/qmlobject.h>
|
||||
#include <packageaccessmanagerfactory.h>
|
||||
#include <kdeclarative/configpropertymap.h>
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user