diff --git a/src/plugins/kpackage/effect/effect.cpp b/src/plugins/kpackage/effect/effect.cpp index ff5064f55e..7b6c8c5a62 100644 --- a/src/plugins/kpackage/effect/effect.cpp +++ b/src/plugins/kpackage/effect/effect.cpp @@ -18,8 +18,8 @@ public: package->addDirectoryDefinition("code", QStringLiteral("code")); package->setMimeTypes("code", QStringList{QStringLiteral("text/plain")}); - package->addFileDefinition("mainscript", QStringLiteral("code/main.js")); - package->setRequired("mainscript", true); + package->addDirectoryDefinition("ui", QStringLiteral("ui")); + package->setMimeTypes("ui", QStringList{QStringLiteral("text/plain")}); package->addFileDefinition("config", QStringLiteral("config/main.xml")); package->setMimeTypes("config", QStringList{QStringLiteral("text/xml")}); @@ -27,6 +27,22 @@ public: package->addFileDefinition("configui", QStringLiteral("ui/config.ui")); package->setMimeTypes("configui", QStringList{QStringLiteral("text/xml")}); } + + void pathChanged(KPackage::Package *package) override + { + if (!package->metadata().isValid()) { + return; + } + + const QString api = package->metadata().value(QStringLiteral("X-Plasma-API")); + if (api == QStringLiteral("javascript")) { + package->addFileDefinition("mainscript", QStringLiteral("code/main.js")); + package->setRequired("mainscript", true); + } else if (api == QStringLiteral("declarativescript")) { + package->addFileDefinition("mainscript", QStringLiteral("ui/main.qml")); + package->setRequired("mainscript", true); + } + } }; K_PLUGIN_CLASS_WITH_JSON(EffectPackageStructure, "effect.json")