Port a bunch of classes away from Plasma::Package

Summary: Ported away some classes, removes many unneeded casts that happen when starting.

Test Plan: Tests still pass, plasma starts properly

Reviewers: #frameworks, #plasma, mart

Reviewed By: #plasma, mart

Subscribers: davidedmundson, mart, plasma-devel

Tags: #plasma, #frameworks

Differential Revision: https://phabricator.kde.org/D6041
This commit is contained in:
Aleix Pol 2017-05-31 02:15:16 +02:00
parent 8b92058d97
commit 563011436d
18 changed files with 131 additions and 157 deletions

View File

@ -39,7 +39,6 @@ PLASMA_UNIT_TESTS(
dialogstatetest
fallbackpackagetest
packagestructuretest
packageurlinterceptortest
pluginloadertest
framesvgtest
iconitemtest

View File

@ -1,36 +0,0 @@
/******************************************************************************
* Copyright 2013 Sebastian Kügler <sebas@kde.org> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public License *
* along with this library; see the file COPYING.LIB. If not, write to *
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301, USA. *
*******************************************************************************/
#include "packageurlinterceptortest.h"
#include <plasmaquick/packageurlinterceptor.h>
#include <qtest.h>
#include <QDebug>
QTEST_MAIN(PackageUrlInterceptorTest)
void PackageUrlInterceptorTest::loadAccessManager()
{
const Plasma::Package &pkg = Plasma::Package();
//TODO: tests on path resolution
}
#include "moc_packageurlinterceptortest.cpp"

View File

@ -1,35 +0,0 @@
/******************************************************************************
* Copyright 2013 Sebastian Kügler <sebas@kde.org> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public License *
* along with this library; see the file COPYING.LIB. If not, write to *
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301, USA. *
*******************************************************************************/
#ifndef PACKAGEURLINTERCEPTORTEST_H
#define PACKAGEURLINTERCEPTORTEST_H
#include <QObject>
class PackageUrlInterceptorTest : public QObject
{
Q_OBJECT
public:
PackageUrlInterceptorTest() {}
private Q_SLOTS:
void loadAccessManager();
};
#endif

View File

@ -84,6 +84,13 @@ Package::Package(const Package &other)
PackageStructureWrapper::s_packagesMap[d->internalPackage] = this;
}
Package::Package(const KPackage::Package &other)
: d(new Plasma::PackagePrivate())
{
d->internalPackage = new KPackage::Package(other);
PackageStructureWrapper::s_packagesMap[d->internalPackage] = this;
}
Package::~Package()
{
PackageStructureWrapper::s_packagesMap.remove(d->internalPackage);

View File

@ -94,6 +94,12 @@ public:
*/
PLASMA_DEPRECATED explicit Package(PackageStructure *structure = 0);
/**
* Copy constructore
* @since 4.6
*/
PLASMA_DEPRECATED Package(const KPackage::Package &other);
/**
* Copy constructore
* @since 4.6

View File

@ -534,16 +534,21 @@ KPluginInfo::List PluginLoader::listAppletInfo(const QString &category, const QS
return list;
}
KPluginInfo::List PluginLoader::listAppletInfoForMimeType(const QString &mimeType)
QList<KPluginMetaData> PluginLoader::listAppletMetaDataForMimeType(const QString &mimeType)
{
auto filter = [&mimeType](const KPluginMetaData &md) -> bool
{
return KPluginMetaData::readStringList(md.rawData(), QStringLiteral("X-Plasma-DropMimeTypes")).contains(mimeType);
};
return KPluginInfo::fromMetaData(KPackage::PackageLoader::self()->findPackages(QStringLiteral("Plasma/Applet"), QString(), filter).toVector());
return KPackage::PackageLoader::self()->findPackages(QStringLiteral("Plasma/Applet"), QString(), filter);
}
KPluginInfo::List PluginLoader::listAppletInfoForUrl(const QUrl &url)
KPluginInfo::List PluginLoader::listAppletInfoForMimeType(const QString &mimeType)
{
return KPluginInfo::fromMetaData(listAppletMetaDataForMimeType(mimeType).toVector());
}
QList<KPluginMetaData> PluginLoader::listAppletMetaDataForUrl(const QUrl &url)
{
QString parentApp;
QCoreApplication *app = QCoreApplication::instance();
@ -556,9 +561,9 @@ KPluginInfo::List PluginLoader::listAppletInfoForUrl(const QUrl &url)
const QString pa = md.value(QStringLiteral("X-KDE-ParentApp"));
return (pa.isEmpty() || pa == parentApp) && !KPluginMetaData::readStringList(md.rawData(), QStringLiteral("X-Plasma-DropUrlPatterns")).isEmpty();
};
QList<KPluginMetaData> allApplets = KPackage::PackageLoader::self()->findPackages(QStringLiteral("Plasma/Applet"), QString(), filter);
const QList<KPluginMetaData> allApplets = KPackage::PackageLoader::self()->findPackages(QStringLiteral("Plasma/Applet"), QString(), filter);
KPluginInfo::List filtered;
QList<KPluginMetaData> filtered;
foreach (const KPluginMetaData &md, allApplets) {
QStringList urlPatterns = KPluginMetaData::readStringList(md.rawData(), QStringLiteral("X-Plasma-DropUrlPatterns"));
foreach (const QString &glob, urlPatterns) {
@ -568,7 +573,7 @@ KPluginInfo::List PluginLoader::listAppletInfoForUrl(const QUrl &url)
#ifndef NDEBUG
// qCDebug(LOG_PLASMA) << md.name() << "matches" << glob << url;
#endif
filtered << KPluginInfo::fromMetaData(md);
filtered << md;
}
}
}
@ -576,6 +581,11 @@ KPluginInfo::List PluginLoader::listAppletInfoForUrl(const QUrl &url)
return filtered;
}
KPluginInfo::List PluginLoader::listAppletInfoForUrl(const QUrl &url)
{
return KPluginInfo::fromMetaData(listAppletMetaDataForUrl(url).toVector());
}
QStringList PluginLoader::listAppletCategories(const QString &parentApp, bool visibleOnly)
{
KConfigGroup group(KSharedConfig::openConfig(), "General");

View File

@ -202,15 +202,33 @@ public:
* Returns a list of all known applets associated with a certain mimetype.
*
* @return list of applets
*
* @deprecated use listAppletMetaDataForMimeType instead
**/
KPluginInfo::List listAppletInfoForMimeType(const QString &mimetype);
PLASMA_DEPRECATED KPluginInfo::List listAppletInfoForMimeType(const QString &mimetype);
/**
* Returns a list of all known applets associated with a certain mimetype.
*
* @return list of applets
**/
QList<KPluginMetaData> listAppletMetaDataForMimeType(const QString &mimetype);
/**
* Returns a list of all known applets associated with a certain URL.
*
* @return list of applets
*
* @deprecated use listAppletMetaDataForUrl instead
**/
PLASMA_DEPRECATED KPluginInfo::List listAppletInfoForUrl(const QUrl &url);
/**
* Returns a list of all known applets associated with a certain URL.
*
* @return list of applets
**/
KPluginInfo::List listAppletInfoForUrl(const QUrl &url);
QList<KPluginMetaData> listAppletMetaDataForUrl(const QUrl &url);
/**
* Returns a list of all the categories used by installed applets.

View File

@ -36,6 +36,7 @@
#include <kdeclarative/qmlobjectsharedengine.h>
#include <packageurlinterceptor.h>
#include <private/package_p.h>
namespace PlasmaQuick
{
@ -63,7 +64,7 @@ void AppletQuickItemPrivate::init()
qmlObject = new KDeclarative::QmlObjectSharedEngine(q);
if (!qmlObject->engine()->urlInterceptor()) {
PackageUrlInterceptor *interceptor = new PackageUrlInterceptor(qmlObject->engine(), Plasma::Package());
PackageUrlInterceptor *interceptor = new PackageUrlInterceptor(qmlObject->engine(), KPackage::Package());
qmlObject->engine()->setUrlInterceptor(interceptor);
}
}
@ -405,14 +406,14 @@ AppletQuickItem::AppletQuickItem(Plasma::Applet *applet, QQuickItem *parent)
d->init();
if (d->applet) {
d->appletPackage = d->applet->package();
d->appletPackage = d->applet->kPackage();
if (d->applet->containment()) {
if (d->applet->containment()->corona()) {
d->coronaPackage = d->applet->containment()->corona()->package();
d->coronaPackage = d->applet->containment()->corona()->kPackage();
}
d->containmentPackage = d->applet->containment()->package();
d->containmentPackage = d->applet->containment()->kPackage();
}
if (d->applet->pluginMetaData().isValid()) {
@ -494,7 +495,7 @@ void AppletQuickItem::init()
//are using an old version of the api in which every applet had one engine
//so initialize a private url interceptor
if (d->applet->kPackage().isValid() && !qobject_cast<KDeclarative::QmlObjectSharedEngine *>(d->qmlObject)) {
PackageUrlInterceptor *interceptor = new PackageUrlInterceptor(engine, d->applet->package());
PackageUrlInterceptor *interceptor = new PackageUrlInterceptor(engine, d->applet->kPackage());
interceptor->addAllowedPath(d->coronaPackage.path());
engine->setUrlInterceptor(interceptor);
}
@ -598,22 +599,22 @@ void AppletQuickItem::init()
Plasma::Package AppletQuickItem::appletPackage() const
{
return d->appletPackage;
return Plasma::Package(d->appletPackage);
}
void AppletQuickItem::setAppletPackage(const Plasma::Package &package)
{
d->appletPackage = package;
d->appletPackage = package.kPackage();
}
Plasma::Package AppletQuickItem::coronaPackage() const
{
return d->coronaPackage;
return Plasma::Package(d->coronaPackage);
}
void AppletQuickItem::setCoronaPackage(const Plasma::Package &package)
{
d->coronaPackage = package;
d->coronaPackage = package.kPackage();
}
int AppletQuickItem::switchWidth() const

View File

@ -102,11 +102,11 @@ public:
//Make the constructor lighter and delay the actual instantiation of the qml in the applet
virtual void init();
Plasma::Package appletPackage() const;
void setAppletPackage(const Plasma::Package &package);
PLASMA_DEPRECATED Plasma::Package appletPackage() const;
PLASMA_DEPRECATED void setAppletPackage(const Plasma::Package &package);
Plasma::Package coronaPackage() const;
void setCoronaPackage(const Plasma::Package &package);
PLASMA_DEPRECATED Plasma::Package coronaPackage() const;
PLASMA_DEPRECATED void setCoronaPackage(const Plasma::Package &package);
QQuickItem *compactRepresentationItem();
QQuickItem *fullRepresentationItem();

View File

@ -123,8 +123,9 @@ void ConfigViewPrivate::init()
return;
}
if (corona->kPackage().isValid()) {
PackageUrlInterceptor *interceptor = new PackageUrlInterceptor(q->engine(), corona->package());
const auto pkg = corona->kPackage();
if (pkg.isValid()) {
PackageUrlInterceptor *interceptor = new PackageUrlInterceptor(q->engine(), pkg);
interceptor->addAllowedPath(applet.data()->kPackage().path());
q->engine()->setUrlInterceptor(interceptor);
}

View File

@ -206,9 +206,9 @@ ContainmentView::ContainmentView(Plasma::Corona *corona, QWindow *parent)
this, &ContainmentView::screenGeometryChanged);
if (corona->kPackage().isValid()) {
KPluginInfo info = corona->package().metadata();
const auto info = corona->kPackage().metadata();
if (info.isValid()) {
setTranslationDomain("plasma_shell_" + info.pluginName());
setTranslationDomain("plasma_shell_" + info.pluginId());
} else {
qWarning() << "Invalid corona package metadata";
}

View File

@ -26,6 +26,8 @@
#include <QStandardPaths>
#include <Plasma/PluginLoader>
#include <Plasma/Package>
#include <KPackage/Package>
#include <kdeclarative/kdeclarative.h>
@ -34,25 +36,25 @@ namespace PlasmaQuick
class PackageUrlInterceptorPrivate {
public:
PackageUrlInterceptorPrivate(QQmlEngine *engine, const Plasma::Package &p)
PackageUrlInterceptorPrivate(QQmlEngine *engine, const KPackage::Package &p)
: package(p),
engine(engine)
{
}
Plasma::Package package;
KPackage::Package package;
QStringList allowedPaths;
QQmlEngine *engine;
//FIXME: those are going to be stuffed here and stay..
// they should probably be removed when the last applet of that type is removed
static QHash<QString, Plasma::Package> s_packages;
static QHash<QString, KPackage::Package> s_packages;
};
QHash<QString, Plasma::Package> PackageUrlInterceptorPrivate::s_packages = QHash<QString, Plasma::Package>();
QHash<QString, KPackage::Package> PackageUrlInterceptorPrivate::s_packages = QHash<QString, KPackage::Package>();
PackageUrlInterceptor::PackageUrlInterceptor(QQmlEngine *engine, const Plasma::Package &p)
PackageUrlInterceptor::PackageUrlInterceptor(QQmlEngine *engine, const KPackage::Package &p)
: QQmlAbstractUrlInterceptor(),
d(new PackageUrlInterceptorPrivate(engine, p))
{
@ -83,7 +85,7 @@ QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlIntercept
{
//qDebug() << "Intercepted URL:" << path << type;
QString pkgRoot;
Plasma::Package package;
KPackage::Package package;
if (d->package.isValid()) {
package = d->package;
} else {
@ -94,7 +96,7 @@ QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlIntercept
if (PackageUrlInterceptorPrivate::s_packages.contains(pkgName)) {
package = PackageUrlInterceptorPrivate::s_packages.value(pkgName);
} else {
package = Plasma::PluginLoader::self()->loadPackage(QStringLiteral("Plasma/Applet"));
package = Plasma::PluginLoader::self()->loadPackage(QStringLiteral("Plasma/Applet")).kPackage();
package.setPath(pkgName);
PackageUrlInterceptorPrivate::s_packages[pkgName] = package;
}

View File

@ -24,7 +24,7 @@
#include <plasmaquick/plasmaquick_export.h>
#include <Plasma/Package>
#include <KPackage/Package>
//
// W A R N I N G
@ -48,7 +48,7 @@ class PackageUrlInterceptorPrivate;
class PLASMAQUICK_EXPORT PackageUrlInterceptor: public QQmlAbstractUrlInterceptor
{
public:
PackageUrlInterceptor(QQmlEngine *engine, const Plasma::Package &p);
PackageUrlInterceptor(QQmlEngine *engine, const KPackage::Package &p);
virtual ~PackageUrlInterceptor();
void addAllowedPath(const QString &path);

View File

@ -21,8 +21,9 @@
#define APPLETQUICKITEM_P_H
#include <QQmlComponent>
#include <qquickitem.h>
#include <QQuickItem>
#include <QQmlEngine>
#include <KPackage/Package>
//
// W A R N I N G
@ -35,6 +36,7 @@
// We mean it.
//
namespace Plasma
{
class Applet;
@ -99,9 +101,9 @@ public:
Plasma::Applet *applet;
KDeclarative::QmlObject *qmlObject;
Plasma::Package appletPackage;
Plasma::Package coronaPackage;
Plasma::Package containmentPackage;
KPackage::Package appletPackage;
KPackage::Package coronaPackage;
KPackage::Package containmentPackage;
bool expanded : 1;
bool activationTogglesExpanded : 1;

View File

@ -188,14 +188,15 @@ View::View(Plasma::Corona *corona, QWindow *parent)
QObject::connect(screen(), &QScreen::geometryChanged,
this, &View::screenGeometryChanged);
if (corona->kPackage().isValid()) {
PackageUrlInterceptor *interceptor = new PackageUrlInterceptor(engine(), corona->package());
const auto pkg = corona->kPackage();
if (pkg.isValid()) {
PackageUrlInterceptor *interceptor = new PackageUrlInterceptor(engine(), pkg);
engine()->setUrlInterceptor(interceptor);
KDeclarative::KDeclarative kdeclarative;
kdeclarative.setDeclarativeEngine(engine());
//binds things like kconfig and icons
kdeclarative.setTranslationDomain("plasma_shell_" + corona->kPackage().metadata().pluginId());
kdeclarative.setTranslationDomain("plasma_shell_" + pkg.metadata().pluginId());
kdeclarative.setupBindings();
} else {
qWarning() << "Invalid home screen package";

View File

@ -494,19 +494,19 @@ void ContainmentInterface::processMimeData(QMimeData *mimeData, int x, int y, KI
} else {
QStringList formats = mimeData->formats();
QHash<QString, KPluginInfo> seenPlugins;
QHash<QString, KPluginMetaData> seenPlugins;
QHash<QString, QString> pluginFormats;
foreach (const QString &format, formats) {
KPluginInfo::List plugins = Plasma::PluginLoader::self()->listAppletInfoForMimeType(format);
const auto plugins = Plasma::PluginLoader::self()->listAppletMetaDataForMimeType(format);
foreach (const KPluginInfo &plugin, plugins) {
if (seenPlugins.contains(plugin.pluginName())) {
foreach (const auto &plugin, plugins) {
if (seenPlugins.contains(plugin.pluginId())) {
continue;
}
seenPlugins.insert(plugin.pluginName(), plugin);
pluginFormats.insert(plugin.pluginName(), format);
seenPlugins.insert(plugin.pluginId(), plugin);
pluginFormats.insert(plugin.pluginId(), format);
}
}
//qDebug() << "Mimetype ..." << formats << seenPlugins.keys() << pluginFormats.values();
@ -530,10 +530,10 @@ void ContainmentInterface::processMimeData(QMimeData *mimeData, int x, int y, KI
}
QList<QAction *> extraActions;
QHash<QAction *, QString> actionsToPlugins;
foreach (const KPluginInfo &info, seenPlugins) {
foreach (const auto &info, seenPlugins) {
QAction *action;
if (!info.icon().isEmpty()) {
action = new QAction(QIcon::fromTheme(info.icon()), info.name(), nullptr);
if (!info.iconName().isEmpty()) {
action = new QAction(QIcon::fromTheme(info.iconName()), info.name(), nullptr);
} else {
action = new QAction(info.name(), nullptr);
}
@ -541,14 +541,14 @@ void ContainmentInterface::processMimeData(QMimeData *mimeData, int x, int y, KI
if (choices) {
choices->addAction(action);
}
action->setData(info.pluginName());
action->setData(info.pluginId());
connect(action, &QAction::triggered, this, [this, x, y, mimeData, action]() {
const QString selectedPlugin = action->data().toString();
Plasma::Applet *applet = createApplet(selectedPlugin, QVariantList(), QRect(x, y, -1, -1));
setAppletArgs(applet, selectedPlugin, mimeData->data(selectedPlugin));
});
actionsToPlugins.insert(action, info.pluginName());
actionsToPlugins.insert(action, info.pluginId());
}
//if the menu was created by ourselves, delete it
@ -595,7 +595,7 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet
clearDataForMimeJob(job);
return;
}
KPluginInfo::List appletList = Plasma::PluginLoader::self()->listAppletInfoForUrl(tjob->url());
QList<KPluginMetaData> appletList = Plasma::PluginLoader::self()->listAppletMetaDataForUrl(tjob->url());
if (mimetype.isEmpty() && appletList.isEmpty()) {
clearDataForMimeJob(job);
qDebug() << "No applets found matching the url (" << tjob->url() << ") or the mimetype (" << mimetype << ")";
@ -624,17 +624,17 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet
qDebug() << "Creating menu for:" << mimetype << posi;
appletList << Plasma::PluginLoader::self()->listAppletInfoForMimeType(mimetype);
appletList << Plasma::PluginLoader::self()->listAppletMetaDataForMimeType(mimetype);
KPluginInfo::List wallpaperList;
QList<KPluginMetaData> wallpaperList;
if (m_containment->containmentType() != Plasma::Types::PanelContainment
&& m_containment->containmentType() != Plasma::Types::CustomPanelContainment) {
if (m_wallpaperInterface && m_wallpaperInterface->supportsMimetype(mimetype)) {
wallpaperList << m_wallpaperInterface->package().metadata();
wallpaperList << m_wallpaperInterface->kPackage().metadata();
} else {
wallpaperList = WallpaperInterface::listWallpaperInfoForMimetype(mimetype);
wallpaperList = WallpaperInterface::listWallpaperMetadataForMimetype(mimetype);
}
}
@ -701,11 +701,10 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet
action->setSeparator(true);
dropActions << action;
}
foreach (const KPluginInfo &info, appletList) {
qDebug() << info.name();
foreach (const auto &info, appletList) {
QAction *action;
if (!info.icon().isEmpty()) {
action = new QAction(QIcon::fromTheme(info.icon()), info.name(), nullptr);
if (!info.iconName().isEmpty()) {
action = new QAction(QIcon::fromTheme(info.iconName()), info.name(), nullptr);
} else {
action = new QAction(info.name(), nullptr);
}
@ -714,8 +713,7 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet
choices->addAction(action);
}
dropActions << action;
action->setData(info.pluginName());
qDebug() << info.pluginName();
action->setData(info.pluginId());
const QUrl url = tjob->url();
connect(action, &QAction::triggered, this, [this, action, posi, mimetype, url]() {
Plasma::Applet *applet = createApplet(action->data().toString(), QVariantList(), QRect(posi, QSize(-1,-1)));
@ -746,15 +744,15 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet
dropActions << action;
}
QMap<QString, KPluginInfo> sorted;
foreach (const KPluginInfo &info, appletList) {
QMap<QString, KPluginMetaData> sorted;
foreach (const auto &info, appletList) {
sorted.insert(info.name(), info);
}
foreach (const KPluginInfo &info, wallpaperList) {
foreach (const KPluginMetaData &info, wallpaperList) {
QAction *action;
if (!info.icon().isEmpty()) {
action = new QAction(QIcon::fromTheme(info.icon()), info.name(), nullptr);
if (!info.iconName().isEmpty()) {
action = new QAction(QIcon::fromTheme(info.iconName()), info.name(), nullptr);
} else {
action = new QAction(info.name(), nullptr);
}
@ -763,7 +761,7 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet
choices->addAction(action);
}
dropActions << action;
actionsToWallpapers.insert(action, info.pluginName());
actionsToWallpapers.insert(action, info.pluginId());
const QUrl url = tjob->url();
connect(action, &QAction::triggered, this, [this, action, url]() {
//set wallpapery stuff

View File

@ -68,7 +68,7 @@ WallpaperInterface::~WallpaperInterface()
}
}
KPluginInfo::List WallpaperInterface::listWallpaperInfoForMimetype(const QString &mimetype, const QString &formFactor)
QList<KPluginMetaData> WallpaperInterface::listWallpaperMetadataForMimetype(const QString &mimetype, const QString &formFactor)
{
auto filter = [&mimetype, &formFactor](const KPluginMetaData &md) -> bool
{
@ -77,10 +77,10 @@ KPluginInfo::List WallpaperInterface::listWallpaperInfoForMimetype(const QString
}
return KPluginMetaData::readStringList(md.rawData(), QStringLiteral("X-Plasma-DropMimeTypes")).contains(mimetype);
};
return KPluginInfo::fromMetaData(KPackage::PackageLoader::self()->findPackages(QStringLiteral("Plasma/Wallpaper"), QString(), filter).toVector());
return KPackage::PackageLoader::self()->findPackages(QStringLiteral("Plasma/Wallpaper"), QString(), filter);
}
Plasma::Package WallpaperInterface::package() const
KPackage::Package WallpaperInterface::kPackage() const
{
return m_pkg;
}
@ -133,7 +133,7 @@ void WallpaperInterface::syncWallpaperPackage()
}
m_actions->clear();
m_pkg = Plasma::PluginLoader::self()->loadPackage(QStringLiteral("Plasma/Wallpaper"));
m_pkg = Plasma::PluginLoader::self()->loadPackage(QStringLiteral("Plasma/Wallpaper")).kPackage();
m_pkg.setPath(m_wallpaperPlugin);
if (!m_pkg.isValid()) {
qWarning() << "Error loading the wallpaper, no valid package loaded";
@ -151,11 +151,11 @@ void WallpaperInterface::syncWallpaperPackage()
m_qmlObject->rootContext()->setContextProperty(QStringLiteral("wallpaper"), this);
m_qmlObject->setSource(QUrl::fromLocalFile(m_pkg.filePath("mainscript")));
const QString rootPath = m_pkg.metadata().property(QStringLiteral("X-Plasma-RootPath")).toString();
const QString rootPath = m_pkg.metadata().value(QStringLiteral("X-Plasma-RootPath"));
if (!rootPath.isEmpty()) {
m_qmlObject->setTranslationDomain(QLatin1String("plasma_wallpaper_") + rootPath);
} else {
m_qmlObject->setTranslationDomain(QLatin1String("plasma_wallpaper_") + m_pkg.metadata().pluginName());
m_qmlObject->setTranslationDomain(QLatin1String("plasma_wallpaper_") + m_pkg.metadata().pluginId());
}
//initialize with our size to avoid as much resize events as possible
@ -199,7 +199,7 @@ QList<QAction *> WallpaperInterface::contextualActions() const
bool WallpaperInterface::supportsMimetype(const QString &mimetype) const
{
return KPluginMetaData::readStringList(m_pkg.kPackage().metadata().rawData(), "X-Plasma-DropMimeTypes").contains(mimetype);
return KPluginMetaData::readStringList(m_pkg.metadata().rawData(), "X-Plasma-DropMimeTypes").contains(mimetype);
}
void WallpaperInterface::setUrl(const QUrl &url)

View File

@ -23,7 +23,7 @@
#include <QQuickItem>
#include <QQmlEngine>
#include <Plasma/Package>
#include <KPackage/Package>
class KConfigLoader;
class KActionCollection;
@ -56,15 +56,15 @@ public:
~WallpaperInterface();
/**
* Returns a list of all known wallpapers that can accept the given mimetype
* @param mimetype the mimetype to search for
* @param formFactor the format of the wallpaper being search for (e.g. desktop)
* @return list of wallpapers
*/
static KPluginInfo::List listWallpaperInfoForMimetype(const QString &mimetype,
* Returns a list of all known wallpapers that can accept the given mimetype
* @param mimetype the mimetype to search for
* @param formFactor the format of the wallpaper being search for (e.g. desktop)
* @return list of wallpapers
*/
static QList<KPluginMetaData> listWallpaperMetadataForMimetype(const QString &mimetype,
const QString &formFactor = QString());
Plasma::Package package() const;
KPackage::Package kPackage() const;
QString pluginName() const;
@ -100,7 +100,7 @@ private:
QString m_wallpaperPlugin;
ContainmentInterface *m_containmentInterface;
KDeclarative::QmlObject *m_qmlObject;
Plasma::Package m_pkg;
KPackage::Package m_pkg;
KDeclarative::ConfigPropertyMap *m_configuration;
KConfigLoader *m_configLoader;
KActionCollection *m_actions;