Changeset View
Changeset View
Standalone View
Standalone View
packageplugins/decoration/decoration.cpp
- This file was added.
1 | /****************************************************************************** | ||||
---|---|---|---|---|---|
2 | * Copyright 2017 by Demitrius Belai <demitriusbelai@gmail.com> * | ||||
3 | * * | ||||
4 | * This library is free software; you can redistribute it and/or * | ||||
5 | * modify it under the terms of the GNU Library General Public * | ||||
6 | * License as published by the Free Software Foundation; either * | ||||
7 | * version 2 of the License, or (at your option) any later version. * | ||||
8 | * * | ||||
9 | * This library is distributed in the hope that it will be useful, * | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * | ||||
12 | * Library General Public License for more details. * | ||||
13 | * * | ||||
14 | * You should have received a copy of the GNU Library General Public License * | ||||
15 | * along with this library; see the file COPYING.LIB. If not, write to * | ||||
16 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * | ||||
17 | * Boston, MA 02110-1301, USA. * | ||||
18 | *******************************************************************************/ | ||||
19 | | ||||
20 | #include "decoration.h" | ||||
21 | | ||||
22 | #include <KLocalizedString> | ||||
23 | | ||||
24 | void DecorationPackage::initPackage(KPackage::Package *package) | ||||
25 | { | ||||
26 | package->setDefaultPackageRoot(QStringLiteral("kwin/decorations/")); | ||||
27 | | ||||
28 | package->addDirectoryDefinition("config", QStringLiteral("config"), i18n("Configuration Definitions")); | ||||
29 | QStringList mimetypes; | ||||
30 | mimetypes << QStringLiteral("text/xml"); | ||||
31 | package->setMimeTypes("config", mimetypes); | ||||
32 | | ||||
33 | package->addDirectoryDefinition("ui", QStringLiteral("ui"), i18n("User Interface")); | ||||
34 | | ||||
35 | package->addDirectoryDefinition("code", QStringLiteral("code"), i18n("Executable Scripts")); | ||||
36 | | ||||
37 | package->addFileDefinition("mainscript", QStringLiteral("code/main.qml"), i18n("Main Script File")); | ||||
38 | package->setRequired("mainscript", true); | ||||
39 | | ||||
40 | mimetypes.clear(); | ||||
41 | mimetypes << QStringLiteral("text/plain"); | ||||
42 | package->setMimeTypes("decoration", mimetypes); | ||||
43 | } | ||||
44 | | ||||
45 | void DecorationPackage::pathChanged(KPackage::Package *package) | ||||
46 | { | ||||
47 | if (package->path().isEmpty()) { | ||||
48 | return; | ||||
49 | } | ||||
50 | | ||||
51 | KPluginMetaData md(package->metadata().metaDataFileName()); | ||||
52 | QString mainScript = md.value("X-Plasma-MainScript"); | ||||
53 | | ||||
54 | if (!mainScript.isEmpty()) { | ||||
55 | package->addFileDefinition("mainscript", mainScript, i18n("Main Script File")); | ||||
56 | } | ||||
57 | } | ||||
58 | | ||||
59 | K_EXPORT_KPACKAGE_PACKAGE_WITH_JSON(DecorationPackage, "kwin-packagestructure-decoration.json") | ||||
60 | | ||||
61 | #include "decoration.moc" | ||||
62 | |