From b1e76ed8c4612fe861bd26ce7daec6112250875d Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Fri, 7 Oct 2016 13:27:19 +0100 Subject: [PATCH] Use KPackage in kcmscripts Test Plan: Tested all but show OSD appeared Reviewers: #plasma, graesslin Reviewed By: #plasma, graesslin Subscribers: graesslin, plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D2977 --- kcmkwin/kwinscripts/CMakeLists.txt | 1 + kcmkwin/kwinscripts/module.cpp | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/kcmkwin/kwinscripts/CMakeLists.txt b/kcmkwin/kwinscripts/CMakeLists.txt index ad19db60c7..c6cd344cea 100644 --- a/kcmkwin/kwinscripts/CMakeLists.txt +++ b/kcmkwin/kwinscripts/CMakeLists.txt @@ -18,6 +18,7 @@ target_link_libraries(kcm_kwin_scripts KF5::KCMUtils KF5::KIOCore KF5::I18n + KF5::Package KF5::Plasma KF5::NewStuff ) diff --git a/kcmkwin/kwinscripts/module.cpp b/kcmkwin/kwinscripts/module.cpp index 7ecf963673..6b0519f58a 100644 --- a/kcmkwin/kwinscripts/module.cpp +++ b/kcmkwin/kwinscripts/module.cpp @@ -33,8 +33,10 @@ #include #include #include -#include +#include +#include #include + #include #include "version.h" @@ -95,8 +97,18 @@ void Module::importScript() void Module::updateListViewContents() { - KService::List offers = KServiceTypeTrader::self()->query("KWin/Script", "not (exist [X-KWin-Exclude-Listing]) or [X-KWin-Exclude-Listing] == false"); - QList scriptinfos = KPluginInfo::fromServices(offers); + auto filter = [](const KPluginMetaData &md) { + if (md.value(QStringLiteral("X-KWin-Exclude-Listing")) == QLatin1String("true") ) { + return false; + } + return true; + }; + + const QString scriptFolder = QStringLiteral("kwin/scripts/"); + const auto scripts = KPackage::PackageLoader::self()->findPackages(QStringLiteral("KWin/Script"), scriptFolder, filter); + + QList scriptinfos = KPluginInfo::fromMetaData(scripts.toVector()); + ui->scriptSelector->addPlugins(scriptinfos, KPluginSelector::ReadConfigFile, QString(), QString(), m_kwinConfig); }