File 0005-add-packagestructure-for-KWin-Decoration.patch of Package kwin5

From 5afad869d09bd197b2205af879470e65a3eefda0 Mon Sep 17 00:00:00 2001
From: Marco Martin <notmart@gmail.com>
Date: Wed, 15 Mar 2017 13:01:53 +0100
Subject: [PATCH 5/5] add packagestructure for KWin/Decoration

Summary:
use a KPackage/PackageStructure for aurorae themes as well

Patch by Demitrius Belai

Reviewers: #plasma, graesslin

Reviewed By: #plasma, graesslin

Subscribers: graesslin, plasma-devel, kwin, #kwin

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D4974
---
 packageplugins/CMakeLists.txt                      |  2 +
 packageplugins/aurorae/CMakeLists.txt              | 17 +++++
 packageplugins/aurorae/aurorae.cpp                 | 85 ++++++++++++++++++++++
 packageplugins/aurorae/aurorae.h                   | 33 +++++++++
 .../aurorae/kwin-packagestructure-aurorae.desktop  | 10 +++
 packageplugins/decoration/CMakeLists.txt           | 17 +++++
 packageplugins/decoration/decoration.cpp           | 62 ++++++++++++++++
 packageplugins/decoration/decoration.h             | 33 +++++++++
 .../kwin-packagestructure-decoration.desktop       | 10 +++
 9 files changed, 269 insertions(+)
 create mode 100644 packageplugins/aurorae/CMakeLists.txt
 create mode 100644 packageplugins/aurorae/aurorae.cpp
 create mode 100644 packageplugins/aurorae/aurorae.h
 create mode 100644 packageplugins/aurorae/kwin-packagestructure-aurorae.desktop
 create mode 100644 packageplugins/decoration/CMakeLists.txt
 create mode 100644 packageplugins/decoration/decoration.cpp
 create mode 100644 packageplugins/decoration/decoration.h
 create mode 100644 packageplugins/decoration/kwin-packagestructure-decoration.desktop

diff --git a/packageplugins/CMakeLists.txt b/packageplugins/CMakeLists.txt
index 8c784b353..92d6d1b4b 100644
--- a/packageplugins/CMakeLists.txt
+++ b/packageplugins/CMakeLists.txt
@@ -1,2 +1,4 @@
+add_subdirectory(aurorae)
+add_subdirectory(decoration)
 add_subdirectory(scripts)
 add_subdirectory(windowswitcher)
diff --git a/packageplugins/aurorae/CMakeLists.txt b/packageplugins/aurorae/CMakeLists.txt
new file mode 100644
index 000000000..6b1ef2b22
--- /dev/null
+++ b/packageplugins/aurorae/CMakeLists.txt
@@ -0,0 +1,17 @@
+add_definitions(-DTRANSLATION_DOMAIN=\"kwin_package_aurorae\")
+
+set(aurorae_SRCS
+    aurorae.cpp
+)
+
+add_library(kwin_packagestructure_aurorae MODULE ${aurorae_SRCS})
+
+target_link_libraries(kwin_packagestructure_aurorae
+   KF5::I18n
+   KF5::Package
+)
+
+kcoreaddons_desktop_to_json(kwin_packagestructure_aurorae kwin-packagestructure-aurorae.desktop)
+
+install(TARGETS kwin_packagestructure_aurorae DESTINATION ${KDE_INSTALL_PLUGINDIR}/kpackage/packagestructure)
+
diff --git a/packageplugins/aurorae/aurorae.cpp b/packageplugins/aurorae/aurorae.cpp
new file mode 100644
index 000000000..8628f79b5
--- /dev/null
+++ b/packageplugins/aurorae/aurorae.cpp
@@ -0,0 +1,85 @@
+/******************************************************************************
+*   Copyright 2017 by Demitrius Belai <demitriusbelai@gmail.com>              *
+*                                                                             *
+*   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 "aurorae.h"
+
+#include <KLocalizedString>
+
+void AuroraePackage::initPackage(KPackage::Package *package)
+{
+    package->setContentsPrefixPaths(QStringList());
+    package->setDefaultPackageRoot(QStringLiteral("aurorae/themes/"));
+
+    package->addFileDefinition("decoration", QStringLiteral("decoration.svgz"),
+                            i18n("Window Decoration"));
+    package->setRequired("decoration", true);
+
+    package->addFileDefinition("close", QStringLiteral("close.svgz"),
+                            i18n("Close Button"));
+
+    package->addFileDefinition("minimize", QStringLiteral("minimize.svgz"),
+                            i18n("Minimize Button"));
+
+    package->addFileDefinition("maximize", QStringLiteral("maximize.svgz"),
+                            i18n("Maximize Button"));
+
+    package->addFileDefinition("restore", QStringLiteral("restore.svgz"),
+                            i18n("Restore Button"));
+
+    package->addFileDefinition("alldesktops", QStringLiteral("alldesktops.svgz"),
+                            i18n("Sticky Button"));
+
+    package->addFileDefinition("keepabove", QStringLiteral("keepabove.svgz"),
+                            i18n("Keepabove Button"));
+
+    package->addFileDefinition("keepbelow", QStringLiteral("keepbelow.svgz"),
+                            i18n("Keepbelow Button"));
+
+    package->addFileDefinition("shade", QStringLiteral("shade.svgz"),
+                            i18n("Shade Button"));
+
+    package->addFileDefinition("help", QStringLiteral("help.svgz"),
+                            i18n("Help Button"));
+
+    package->addFileDefinition("configrc", QStringLiteral("configrc"),
+                            i18n("Configuration file"));
+
+    QStringList mimetypes;
+    mimetypes << QStringLiteral("image/svg+xml-compressed");
+    package->setDefaultMimeTypes(mimetypes);
+}
+
+void AuroraePackage::pathChanged(KPackage::Package *package)
+{
+    if (package->path().isEmpty()) {
+        return;
+    }
+
+    KPluginMetaData md(package->metadata().metaDataFileName());
+
+    if (!md.pluginId().isEmpty()) {
+        QString configrc = md.pluginId() + "rc";
+        package->addFileDefinition("configrc", configrc, i18n("Configuration file"));
+    }
+}
+
+K_EXPORT_KPACKAGE_PACKAGE_WITH_JSON(AuroraePackage, "kwin-packagestructure-aurorae.json")
+
+#include "aurorae.moc"
+
diff --git a/packageplugins/aurorae/aurorae.h b/packageplugins/aurorae/aurorae.h
new file mode 100644
index 000000000..c3005aac8
--- /dev/null
+++ b/packageplugins/aurorae/aurorae.h
@@ -0,0 +1,33 @@
+/******************************************************************************
+*   Copyright 2017 by Demitrius Belai <demitriusbelai@gmail.com>              *
+*                                                                             *
+*   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.                                               *
+*******************************************************************************/
+
+#ifndef AURORAEPACKAGE_H
+#define AURORAEPACKAGE_H
+
+#include <KPackage/PackageStructure>
+
+class AuroraePackage : public KPackage::PackageStructure
+{
+public:
+    AuroraePackage(QObject*, const QVariantList &) {}
+    void initPackage(KPackage::Package *package) Q_DECL_OVERRIDE;
+    void pathChanged(KPackage::Package *package) Q_DECL_OVERRIDE;
+};
+
+#endif
diff --git a/packageplugins/aurorae/kwin-packagestructure-aurorae.desktop b/packageplugins/aurorae/kwin-packagestructure-aurorae.desktop
new file mode 100644
index 000000000..3f1065ec1
--- /dev/null
+++ b/packageplugins/aurorae/kwin-packagestructure-aurorae.desktop
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Name=KWin Aurorae
+Type=Service
+X-KDE-ServiceTypes=KPackage/PackageStructure
+X-KDE-Library=kwin_packagestructure_aurorae
+
+X-KDE-PluginInfo-Author=Demitrius Belai
+X-KDE-PluginInfo-Email=demitriusbelai@gmail.com
+X-KDE-PluginInfo-Name=KWin/Aurorae
+X-KDE-PluginInfo-Version=1
diff --git a/packageplugins/decoration/CMakeLists.txt b/packageplugins/decoration/CMakeLists.txt
new file mode 100644
index 000000000..bfb606553
--- /dev/null
+++ b/packageplugins/decoration/CMakeLists.txt
@@ -0,0 +1,17 @@
+add_definitions(-DTRANSLATION_DOMAIN=\"kwin_package_decoration\")
+
+set(decoration_SRCS
+    decoration.cpp
+)
+
+add_library(kwin_packagestructure_decoration MODULE ${decoration_SRCS})
+
+target_link_libraries(kwin_packagestructure_decoration
+   KF5::I18n
+   KF5::Package
+)
+
+kcoreaddons_desktop_to_json(kwin_packagestructure_decoration kwin-packagestructure-decoration.desktop)
+
+install(TARGETS kwin_packagestructure_decoration DESTINATION ${KDE_INSTALL_PLUGINDIR}/kpackage/packagestructure)
+
diff --git a/packageplugins/decoration/decoration.cpp b/packageplugins/decoration/decoration.cpp
new file mode 100644
index 000000000..a8dc37d66
--- /dev/null
+++ b/packageplugins/decoration/decoration.cpp
@@ -0,0 +1,62 @@
+/******************************************************************************
+*   Copyright 2017 by Demitrius Belai <demitriusbelai@gmail.com>              *
+*                                                                             *
+*   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 "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"
+
diff --git a/packageplugins/decoration/decoration.h b/packageplugins/decoration/decoration.h
new file mode 100644
index 000000000..cf3897efa
--- /dev/null
+++ b/packageplugins/decoration/decoration.h
@@ -0,0 +1,33 @@
+/******************************************************************************
+*   Copyright 2017 by Demitrius Belai <demitriusbelai@gmail.com>              *
+*                                                                             *
+*   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.                                               *
+*******************************************************************************/
+
+#ifndef DECORATIONPACKAGE_H
+#define DECORATIONPACKAGE_H
+
+#include <KPackage/PackageStructure>
+
+class DecorationPackage : public KPackage::PackageStructure
+{
+public:
+    DecorationPackage(QObject*, const QVariantList &) {}
+    void initPackage(KPackage::Package *package) Q_DECL_OVERRIDE;
+    void pathChanged(KPackage::Package *package) Q_DECL_OVERRIDE;
+};
+
+#endif
diff --git a/packageplugins/decoration/kwin-packagestructure-decoration.desktop b/packageplugins/decoration/kwin-packagestructure-decoration.desktop
new file mode 100644
index 000000000..2e362d489
--- /dev/null
+++ b/packageplugins/decoration/kwin-packagestructure-decoration.desktop
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Name=KWin Decoration
+Type=Service
+X-KDE-ServiceTypes=KPackage/PackageStructure
+X-KDE-Library=kwin_packagestructure_decoration
+
+X-KDE-PluginInfo-Author=Demitrius Belai
+X-KDE-PluginInfo-Email=demitriusbelai@gmail.com
+X-KDE-PluginInfo-Name=KWin/Decoration
+X-KDE-PluginInfo-Version=1
-- 
2.13.2

openSUSE Build Service is sponsored by