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
This commit is contained in:
Marco Martin 2017-03-15 13:01:53 +01:00
parent 063587db99
commit 898bee614d
9 changed files with 269 additions and 0 deletions

View file

@ -1,2 +1,4 @@
add_subdirectory(aurorae)
add_subdirectory(decoration)
add_subdirectory(scripts)
add_subdirectory(windowswitcher)

View file

@ -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)

View file

@ -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"

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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"

View file

@ -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

View file

@ -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