[kcm/decoration] Port to KPluginLoader

Summary: KPluginTrader's future is uncertain. KPluginLoader is enough here

Test Plan: Open deco KCM. Themes are listed

Reviewers: #kwin, dfaure

Reviewed By: dfaure

Subscribers: dfaure, zzag, kwin

Tags: #kwin

Maniphest Tasks: T12173

Differential Revision: https://phabricator.kde.org/D25534
This commit is contained in:
Nicolas Fella 2020-09-30 15:31:05 +02:00
parent 0a3e18e5a6
commit abca052004

View file

@ -10,7 +10,7 @@
// KDE // KDE
#include <KPluginLoader> #include <KPluginLoader>
#include <KPluginFactory> #include <KPluginFactory>
#include <KPluginTrader> #include <KPluginMetaData>
// Qt // Qt
#include <QDebug> #include <QDebug>
@ -118,9 +118,9 @@ void DecorationsModel::init()
{ {
beginResetModel(); beginResetModel();
m_plugins.clear(); m_plugins.clear();
const auto plugins = KPluginTrader::self()->query(s_pluginName, s_pluginName); const auto plugins = KPluginLoader::findPlugins(s_pluginName);
for (const auto &info : plugins) { for (const auto &info : plugins) {
KPluginLoader loader(info.libraryPath()); KPluginLoader loader(info.fileName());
KPluginFactory *factory = loader.factory(); KPluginFactory *factory = loader.factory();
if (!factory) { if (!factory) {
continue; continue;
@ -150,7 +150,7 @@ void DecorationsModel::init()
const auto themesMap = themes.toMap(); const auto themesMap = themes.toMap();
for (auto it = themesMap.begin(); it != themesMap.end(); ++it) { for (auto it = themesMap.begin(); it != themesMap.end(); ++it) {
Data d; Data d;
d.pluginName = info.pluginName(); d.pluginName = info.pluginId();
d.themeName = it.value().toString(); d.themeName = it.value().toString();
d.visibleName = it.key(); d.visibleName = it.key();
QMetaObject::invokeMethod(themeFinder.data(), "hasConfiguration", QMetaObject::invokeMethod(themeFinder.data(), "hasConfiguration",
@ -165,8 +165,8 @@ void DecorationsModel::init()
data.configuration = isConfigureable(decoSettingsMap); data.configuration = isConfigureable(decoSettingsMap);
data.recommendedBorderSize = recommendedBorderSize(decoSettingsMap); data.recommendedBorderSize = recommendedBorderSize(decoSettingsMap);
} }
data.pluginName = info.pluginName(); data.pluginName = info.pluginId();
data.visibleName = info.name().isEmpty() ? info.pluginName() : info.name(); data.visibleName = info.name().isEmpty() ? info.pluginId() : info.name();
data.themeName = data.visibleName; data.themeName = data.visibleName;
m_plugins.emplace_back(std::move(data)); m_plugins.emplace_back(std::move(data));