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
wilder-5.14
Marco Martin 8 years ago
parent 030897484c
commit aeecbcd9f8
  1. 36
      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;

Loading…
Cancel
Save