kwin/plugins/kpackage/decoration/decoration.cpp
2020-08-07 19:57:56 +00:00

49 lines
1.5 KiB
C++

/*
SPDX-FileCopyrightText: 2017 Demitrius Belai <demitriusbelai@gmail.com>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "decoration.h"
#include <KLocalizedString>
void DecorationPackage::initPackage(KPackage::Package *package)
{
package->setDefaultPackageRoot(QStringLiteral("kwin/decorations/"));
package->addDirectoryDefinition("config", QStringLiteral("config"), i18n("Configuration Definitions"));
QStringList mimetypes;
mimetypes << QStringLiteral("text/xml");
package->setMimeTypes("config", mimetypes);
package->addDirectoryDefinition("ui", QStringLiteral("ui"), i18n("User Interface"));
package->addDirectoryDefinition("code", QStringLiteral("code"), i18n("Executable Scripts"));
package->addFileDefinition("mainscript", QStringLiteral("code/main.qml"), i18n("Main Script File"));
package->setRequired("mainscript", true);
mimetypes.clear();
mimetypes << QStringLiteral("text/plain");
package->setMimeTypes("decoration", mimetypes);
}
void DecorationPackage::pathChanged(KPackage::Package *package)
{
if (package->path().isEmpty()) {
return;
}
KPluginMetaData md(package->metadata().metaDataFileName());
QString mainScript = md.value("X-Plasma-MainScript");
if (!mainScript.isEmpty()) {
package->addFileDefinition("mainscript", mainScript, i18n("Main Script File"));
}
}
K_EXPORT_KPACKAGE_PACKAGE_WITH_JSON(DecorationPackage, "kwin-packagestructure-decoration.json")
#include "decoration.moc"