[effects] Make scripted effects GHNS-able
Summary:
Currently, if one wants to install a scripted effect from the KDE Store,
the effect won't show up in the Desktop Effects KCM. The reason for that
is kpackagetool5 doesn't know where to install effects (they have to be
installed under ${DATA_DIR}/kwin/effects).
Another problem is that even if the scripted effect is installed in the
right directory (e.g. ~/.local/share/kwin/effects), it won't be listed in
the Desktop Effects KCM because it doesn't have a desktop file in
kservices5 dir. Please notice that the effect will be "visible" for KWin, i.e.
you can enable it by editing kwinrc.
This diff addresses those 2 problems by:
* Adding a PackageStructure plugin for effects (so they are installed
under kwin/effects/);
* Using KPackage::PackageLoader to get list of scripted effect in the
Desktop Effects KCM.
Test Plan:
* Installed an effect from the KDE Store, it appeared in the Desktop Effects
KCM;
* Removed it.
Reviewers: #kwin, mart, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: ngraham, davidedmundson, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D15372
2018-09-09 09:28:58 +00:00
|
|
|
/******************************************************************************
|
2019-09-29 14:03:25 +00:00
|
|
|
* Copyright 2018 Vlad Zahorodnii <vladzzag@gmail.com> *
|
[effects] Make scripted effects GHNS-able
Summary:
Currently, if one wants to install a scripted effect from the KDE Store,
the effect won't show up in the Desktop Effects KCM. The reason for that
is kpackagetool5 doesn't know where to install effects (they have to be
installed under ${DATA_DIR}/kwin/effects).
Another problem is that even if the scripted effect is installed in the
right directory (e.g. ~/.local/share/kwin/effects), it won't be listed in
the Desktop Effects KCM because it doesn't have a desktop file in
kservices5 dir. Please notice that the effect will be "visible" for KWin, i.e.
you can enable it by editing kwinrc.
This diff addresses those 2 problems by:
* Adding a PackageStructure plugin for effects (so they are installed
under kwin/effects/);
* Using KPackage::PackageLoader to get list of scripted effect in the
Desktop Effects KCM.
Test Plan:
* Installed an effect from the KDE Store, it appeared in the Desktop Effects
KCM;
* Removed it.
Reviewers: #kwin, mart, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: ngraham, davidedmundson, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D15372
2018-09-09 09:28:58 +00:00
|
|
|
* *
|
|
|
|
* This library is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU Library General Public *
|
|
|
|
* License as published by the Free Software Foundation; either *
|
|
|
|
* version 2 of the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This library is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
|
|
|
* Library General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Library General Public License *
|
|
|
|
* along with this library; see the file COPYING.LIB. If not, write to *
|
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
|
|
|
|
* Boston, MA 02110-1301, USA. *
|
|
|
|
*******************************************************************************/
|
|
|
|
|
|
|
|
#include "effect.h"
|
|
|
|
|
|
|
|
#include <KLocalizedString>
|
|
|
|
|
|
|
|
EffectPackageStructure::EffectPackageStructure(QObject *parent, const QVariantList &args)
|
|
|
|
: KPackage::PackageStructure(parent, args)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectPackageStructure::initPackage(KPackage::Package *package)
|
|
|
|
{
|
|
|
|
package->setDefaultPackageRoot(QStringLiteral("kwin/effects/"));
|
|
|
|
|
|
|
|
package->addDirectoryDefinition("code", QStringLiteral("code"), i18n("Executable Scripts"));
|
|
|
|
package->setMimeTypes("code", {QStringLiteral("text/plain")});
|
|
|
|
|
|
|
|
package->addFileDefinition("mainscript", QStringLiteral("code/main.js"), i18n("Main Script File"));
|
|
|
|
package->setRequired("mainscript", true);
|
|
|
|
|
|
|
|
package->addFileDefinition("config", QStringLiteral("config/main.xml"), i18n("Configuration Definition File"));
|
|
|
|
package->setMimeTypes("config", {QStringLiteral("text/xml")});
|
|
|
|
|
|
|
|
package->addFileDefinition("configui", QStringLiteral("ui/config.ui"), i18n("KCM User Interface File"));
|
|
|
|
package->setMimeTypes("configui", {QStringLiteral("text/xml")});
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectPackageStructure::pathChanged(KPackage::Package *package)
|
|
|
|
{
|
|
|
|
if (package->path().isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const KPluginMetaData md(package->metadata().metaDataFileName());
|
|
|
|
const QString mainScript = md.value("X-Plasma-MainScript");
|
|
|
|
if (mainScript.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
package->addFileDefinition("mainscript", mainScript, i18n("Main Script File"));
|
|
|
|
}
|
|
|
|
|
|
|
|
K_EXPORT_KPACKAGE_PACKAGE_WITH_JSON(EffectPackageStructure, "kwin-packagestructure-effect.json")
|
|
|
|
|
|
|
|
#include "effect.moc"
|