From a1340a98154cc5f0517a1c107153d33ae82ce495 Mon Sep 17 00:00:00 2001 From: Alexander Lohnau Date: Sat, 25 Dec 2021 12:21:41 +0100 Subject: [PATCH] Rework determining of scripted effect config Currently the plugin needs to set a property in oder to be considered configurable. In kpackage we have the concept of optional and required files, based on the existence of those optional files we can define different behavior. For example in Plasma the applets can optionally have a config ui. Because here we don not use The KPackage:Package class, it is simpler to check the existence of the files on disk. --- src/effects/frozenapp/package/metadata.desktop | 1 - src/effects/login/package/metadata.desktop | 1 - src/effects/scale/package/metadata.desktop | 1 - src/effects/translucency/package/metadata.desktop | 1 - src/kcmkwin/common/effectsmodel.cpp | 13 +++++-------- src/scripts/videowall/metadata.desktop | 1 - 6 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/effects/frozenapp/package/metadata.desktop b/src/effects/frozenapp/package/metadata.desktop index 8dd8c1a057..b7f7949f9c 100644 --- a/src/effects/frozenapp/package/metadata.desktop +++ b/src/effects/frozenapp/package/metadata.desktop @@ -99,5 +99,4 @@ X-Plasma-API=javascript X-Plasma-MainScript=code/main.js X-KDE-PluginKeyword=kwin4_effect_frozenapp X-KDE-Library=kcm_kwin4_genericscripted -X-KDE-ParentComponents=kwin4_effect_frozen X-KWin-Config-TranslationDomain=kwin_effects diff --git a/src/effects/login/package/metadata.desktop b/src/effects/login/package/metadata.desktop index 37df15fb49..430de96fb6 100644 --- a/src/effects/login/package/metadata.desktop +++ b/src/effects/login/package/metadata.desktop @@ -169,5 +169,4 @@ X-Plasma-API=javascript X-Plasma-MainScript=code/main.js X-KDE-PluginKeyword=kwin4_effect_login X-KDE-Library=kcm_kwin4_genericscripted -X-KDE-ParentComponents=kwin4_effect_login X-KWin-Config-TranslationDomain=kwin_effects diff --git a/src/effects/scale/package/metadata.desktop b/src/effects/scale/package/metadata.desktop index 50493dabe5..11beb4a77d 100644 --- a/src/effects/scale/package/metadata.desktop +++ b/src/effects/scale/package/metadata.desktop @@ -88,6 +88,5 @@ X-Plasma-API=javascript X-Plasma-MainScript=code/main.js X-KDE-PluginKeyword=kwin4_effect_scale X-KDE-Library=kcm_kwin4_genericscripted -X-KDE-ParentComponents=kwin4_effect_scale X-KWin-Config-TranslationDomain=kwin_effects X-KWin-Exclusive-Category=toplevel-open-close-animation diff --git a/src/effects/translucency/package/metadata.desktop b/src/effects/translucency/package/metadata.desktop index f154d29a2e..5a431e31dc 100644 --- a/src/effects/translucency/package/metadata.desktop +++ b/src/effects/translucency/package/metadata.desktop @@ -167,5 +167,4 @@ X-Plasma-API=javascript X-Plasma-MainScript=code/main.js X-KDE-PluginKeyword=kwin4_effect_translucency X-KDE-Library=kcm_kwin4_genericscripted -X-KDE-ParentComponents=kwin4_effect_translucency X-KWin-Config-TranslationDomain=kwin_effects diff --git a/src/kcmkwin/common/effectsmodel.cpp b/src/kcmkwin/common/effectsmodel.cpp index 4cf88cb4c3..e596695477 100644 --- a/src/kcmkwin/common/effectsmodel.cpp +++ b/src/kcmkwin/common/effectsmodel.cpp @@ -316,14 +316,11 @@ void EffectsModel::loadJavascriptEffects(const KConfigGroup &kwinConfig) const QString pluginKeyword = plugin.value(QStringLiteral("X-KDE-PluginKeyword")); if (!pluginKeyword.isEmpty()) { - // scripted effects have their pluginName() as the keyword - const QStringList parentComponents = plugin.value(QStringLiteral("X-KDE-ParentComponents"), QStringList{}); - - if (parentComponents.isEmpty()) { - effect.configurable = false; - } else { - effect.configurable = parentComponents.first() == pluginKeyword; - } + QDir package(QFileInfo(plugin.fileName()).dir()); + package.cd(QStringLiteral("contents")); + const QString xmlFile = package.filePath(QStringLiteral("config/main.xml")); + const QString uiFile =package.filePath(QStringLiteral("ui/config.ui")); + effect.configurable = QFileInfo::exists(xmlFile) && QFileInfo::exists(uiFile); } else { effect.configurable = false; } diff --git a/src/scripts/videowall/metadata.desktop b/src/scripts/videowall/metadata.desktop index f3c8caeed3..64b510eba5 100644 --- a/src/scripts/videowall/metadata.desktop +++ b/src/scripts/videowall/metadata.desktop @@ -112,6 +112,5 @@ X-KDE-ServiceTypes=KWin/Script,KCModule X-KDE-Library=kwin/effects/configs/kcm_kwin4_genericscripted X-KDE-PluginKeyword=videowall -X-KDE-ParentComponents=videowall Type=Service