From 468acd0cbed9036f1951e8ab1610880253aa3f3e Mon Sep 17 00:00:00 2001 From: Alexander Lohnau Date: Thu, 18 Nov 2021 06:54:35 +0100 Subject: [PATCH] Fix determining of scripted effect config from KPluginSelector In the KPluginSelector we don't have the possibility to set the args for each KCM. Because of that we use the metadata of the KPluginFactory as a fallback to read the plugin keyword, which specifies the KCM we want to display. This requires kcmutils 54b196a9bad88732debe0b49111af4755268f09f, which landed in the last release. BUG: 445667 --- src/scripting/genericscriptedconfig.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/scripting/genericscriptedconfig.cpp b/src/scripting/genericscriptedconfig.cpp index 0be341631b..9b23154577 100644 --- a/src/scripting/genericscriptedconfig.cpp +++ b/src/scripting/genericscriptedconfig.cpp @@ -30,9 +30,18 @@ QObject *GenericScriptedConfigFactory::create(const char *iface, QWidget *parent Q_UNUSED(iface) Q_UNUSED(parent) Q_UNUSED(keyword) - Q_ASSERT(!args.isEmpty()); - const QString pluginId = args.first().toString(); + // the plugin id is in the args when created by desktop effects kcm or EffectsModel in general + QString pluginId = args.isEmpty() ? QString() : args.first().toString(); + + // If we do not get the id of the effect we want to load from the args, we have to check our metadata. + // This can be the case if the factory gets loaded from a KPluginSelector + // the plugin id is in plugin factory metadata when created by scripts kcm + // (because it uses kpluginselector, which doesn't pass the plugin id as the first arg), + // can be dropped once the scripts kcm is ported to qtquick (because then we could pass the plugin id via the args) + if (pluginId.isEmpty()) { + pluginId = metaData().pluginId(); + } if (pluginId.startsWith(QLatin1String("kwin4_effect_"))) { return new ScriptedEffectConfig(pluginId, parentWidget, args); } else {