From aeecbcd9f8394527b379eb17b29e1cba51f90e4e Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Mon, 11 Dec 2017 18:49:29 +0100 Subject: [PATCH] port wallpaper config fialog to Package::fileUrl Summary: in the wallpaper config dialog there was custom code duplicating listing of kpackage, just wrong (if the same wallpaper was installed in more than one place, the config file qml was taken from the one with least priority) Test Plan: wallpaper dialog works again with qresource based packages also they load the proper config ui qml file when more than one instance of plasmashell is installed Reviewers: #plasma, davidedmundson Reviewed By: #plasma, davidedmundson Subscribers: davidedmundson, broulik, plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D9237 --- shell/containmentconfigview.cpp | 36 +++++---------------------------- 1 file changed, 5 insertions(+), 31 deletions(-) diff --git a/shell/containmentconfigview.cpp b/shell/containmentconfigview.cpp index 134f15e46..246dbabb3 100644 --- a/shell/containmentconfigview.cpp +++ b/shell/containmentconfigview.cpp @@ -121,39 +121,13 @@ PlasmaQuick::ConfigModel *ContainmentConfigView::wallpaperConfigModel() { if (!m_wallpaperConfigModel) { m_wallpaperConfigModel = new PlasmaQuick::ConfigModel(this); - QStringList dirs(QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, PLASMA_RELATIVE_DATA_INSTALL_DIR "/wallpapers", QStandardPaths::LocateDirectory)); - KPackage::Package pkg = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("KPackage/Generic")); - QStringList platform = KDeclarative::KDeclarative::runtimePlatform(); - if (!platform.isEmpty()) { - QMutableStringListIterator it(platform); - while (it.hasNext()) { - it.next(); - it.setValue("platformcontents/" + it.value()); - } - - platform.append(QStringLiteral("contents")); - pkg.setContentsPrefixPaths(platform); - } - pkg.addFileDefinition("mainscript", QStringLiteral("ui/main.qml"), i18n("Main Script File")); - foreach (const QString &dirPath, dirs) { - QDir dir(dirPath); - pkg.setDefaultPackageRoot(dirPath); - QStringList packages; - - foreach (const QString &sdir, dir.entryList(QDir::AllDirs | QDir::Readable)) { - const QString metadata = dirPath + '/' + sdir; - if (QFile::exists(metadata + "/metadata.json") || QFile::exists(metadata + "/metadata.desktop")) { - packages << sdir; - } - } - foreach (const QString &package, packages) { - pkg.setPath(package); - if (!pkg.isValid()) { - continue; - } - m_wallpaperConfigModel->appendCategory(pkg.metadata().iconName(), pkg.metadata().name(), pkg.filePath("ui", QStringLiteral("config.qml")), package); + for (const KPluginMetaData &m : KPackage::PackageLoader::self()->listPackages("Plasma/Wallpaper")) { + KPackage::Package pkg = KPackage::PackageLoader::self()->loadPackage("Plasma/Wallpaper", m.pluginId()); + if (!pkg.isValid()) { + continue; } + m_wallpaperConfigModel->appendCategory(pkg.metadata().iconName(), pkg.metadata().name(), pkg.fileUrl("ui", QStringLiteral("config.qml")).toString(), m.pluginId()); } } return m_wallpaperConfigModel;