aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Martin <[email protected]>2017-01-19 18:13:01 +0100
committerMarco Martin <[email protected]>2017-01-20 15:34:56 +0100
commit405518c41da9df963823eed9c7688b4353f29fe6 (patch)
treeba497b2f7a0ac4e17104ffd151cc5fef5cca2c0a
parent3ba1d9c405575a2005ac52578e95e9ee0100f31c (diff)
use proper packagestructures
Summary: as the plasmapkg2 utility is dead, scripts and tabboxes couldn't be installed anymore, as plasmapkg2 was launched with an hardcoded package type (and had a bunch of custom code for it) and no packagestructure for the relevant package types existed. the port of scripts and tabboxes to kpackage in kwin is quite incomplete and somewhat strange (given the fact that was started by looking manually for the file as it couldn't link to libplasma) this makes things a bit better as now scripts and tabboxes have an actual package structure, making it installable by kpackagetool5. in the future, the port should be completed and replace all the manual lookup of files with package::filePath as it should work now given that valid structures exist BUG:374766 Test Plan: tabbox plugins and kwin scripts can be installed from knewstuff again and can be successfully loaded Reviewers: #plasma, graesslin, subdiff Reviewed By: #plasma, graesslin Subscribers: graesslin, plasma-devel, kwin, #kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D4202
-rw-r--r--CMakeLists.txt1
-rw-r--r--kcmkwin/kwintabbox/main.cpp16
-rw-r--r--packageplugins/CMakeLists.txt2
-rw-r--r--packageplugins/scripts/CMakeLists.txt16
-rw-r--r--packageplugins/scripts/kwin-packagestructure-scripts.desktop10
-rw-r--r--packageplugins/scripts/scripts.cpp62
-rw-r--r--packageplugins/scripts/scripts.h33
-rw-r--r--packageplugins/windowswitcher/CMakeLists.txt16
-rw-r--r--packageplugins/windowswitcher/kwin-packagestructure-windowswitcher.desktop10
-rw-r--r--packageplugins/windowswitcher/windowswitcher.cpp62
-rw-r--r--packageplugins/windowswitcher/windowswitcher.h33
11 files changed, 253 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 04ab141..f595d64 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -634,6 +634,7 @@ ecm_install_icons(
add_subdirectory(qml)
add_subdirectory(autotests)
add_subdirectory(tests)
+add_subdirectory(packageplugins)
if (KF5DocTools_FOUND)
add_subdirectory(doc)
diff --git a/kcmkwin/kwintabbox/main.cpp b/kcmkwin/kwintabbox/main.cpp
index 5e42cf7..efd52c8 100644
--- a/kcmkwin/kwintabbox/main.cpp
+++ b/kcmkwin/kwintabbox/main.cpp
@@ -197,8 +197,7 @@ void KWinTabBoxConfig::initLayoutLists()
QString coverswitch = BuiltInEffects::effectData(BuiltInEffect::CoverSwitch).displayName;
QString flipswitch = BuiltInEffects::effectData(BuiltInEffect::FlipSwitch).displayName;
- KServiceTypeTrader* trader = KServiceTypeTrader::self();
- KService::List offers = trader->query("KWin/WindowSwitcher");
+ QList<KPluginMetaData> offers = KPackage::PackageLoader::self()->listPackages("KWin/WindowSwitcher");
QStringList layoutNames, layoutPlugins, layoutPaths;
const auto lnfPackages = availableLnFPackages();
@@ -209,15 +208,16 @@ void KWinTabBoxConfig::initLayoutLists()
layoutPaths << package.filePath("windowswitcher", QStringLiteral("WindowSwitcher.qml"));
}
- foreach (KService::Ptr service, offers) {
- const QString pluginName = service->property("X-KDE-PluginInfo-Name").toString();
- if (service->property("X-Plasma-API").toString() != "declarativeappletscript") {
+ for (const auto &offer : offers) {
+ const QString pluginName = offer.pluginId();
+ if (offer.value("X-Plasma-API") != "declarativeappletscript") {
continue;
}
- if (service->property("X-KWin-Exclude-Listing").toBool()) {
+ //we don't have a proper servicetype
+ if (offer.value("X-KWin-Exclude-Listing") == QStringLiteral("true")) {
continue;
}
- const QString scriptName = service->property("X-Plasma-MainScript").toString();
+ const QString scriptName = offer.value("X-Plasma-MainScript");
const QString scriptFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
QLatin1String("kwin/tabbox/") + pluginName + QLatin1String("/contents/")
+ scriptName);
@@ -225,7 +225,7 @@ void KWinTabBoxConfig::initLayoutLists()
continue;
}
- layoutNames << service->name();
+ layoutNames << offer.name();
layoutPlugins << pluginName;
layoutPaths << scriptFile;
}
diff --git a/packageplugins/CMakeLists.txt b/packageplugins/CMakeLists.txt
new file mode 100644
index 0000000..8c784b3
--- /dev/null
+++ b/packageplugins/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_subdirectory(scripts)
+add_subdirectory(windowswitcher)
diff --git a/packageplugins/scripts/CMakeLists.txt b/packageplugins/scripts/CMakeLists.txt
new file mode 100644
index 0000000..f0a5636
--- /dev/null
+++ b/packageplugins/scripts/CMakeLists.txt
@@ -0,0 +1,16 @@
+add_definitions(-DTRANSLATION_DOMAIN=\"kwin_package_scripts\")
+
+set(scripts_SRCS
+ scripts.cpp
+)
+
+add_library(kwin_packagestructure_scripts MODULE ${scripts_SRCS})
+
+target_link_libraries(kwin_packagestructure_scripts
+ KF5::I18n
+ KF5::Package
+)
+
+kcoreaddons_desktop_to_json(kwin_packagestructure_scripts kwin-packagestructure-scripts.desktop)
+
+install(TARGETS kwin_packagestructure_scripts DESTINATION ${KDE_INSTALL_PLUGINDIR}/kpackage/packagestructure)
diff --git a/packageplugins/scripts/kwin-packagestructure-scripts.desktop b/packageplugins/scripts/kwin-packagestructure-scripts.desktop
new file mode 100644
index 0000000..81a9401
--- /dev/null
+++ b/packageplugins/scripts/kwin-packagestructure-scripts.desktop
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Name=KWin Script
+Type=Service
+X-KDE-ServiceTypes=KPackage/PackageStructure
+X-KDE-Library=kwin_packagestructure_scripts
+
+X-KDE-PluginInfo-Author=Marco Martin
+X-KDE-PluginInfo-Name=KWin/Script
+X-KDE-PluginInfo-Version=1
diff --git a/packageplugins/scripts/scripts.cpp b/packageplugins/scripts/scripts.cpp
new file mode 100644
index 0000000..4a41514
--- /dev/null
+++ b/packageplugins/scripts/scripts.cpp
@@ -0,0 +1,62 @@
+/******************************************************************************
+* Copyright 2017 by Marco Martin <[email protected]> *
+* *
+* 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 "scripts.h"
+
+#include <KLocalizedString>
+
+void ScriptsPackage::initPackage(KPackage::Package *package)
+{
+ package->setDefaultPackageRoot(QStringLiteral("kwin/scripts/"));
+
+ 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.js"), i18n("Main Script File"));
+ package->setRequired("mainscript", true);
+
+ mimetypes.clear();
+ mimetypes << QStringLiteral("text/plain");
+ package->setMimeTypes("scripts", mimetypes);
+}
+
+void ScriptsPackage::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(ScriptsPackage, "kwin-packagestructure-scripts.json")
+
+#include "scripts.moc"
+
diff --git a/packageplugins/scripts/scripts.h b/packageplugins/scripts/scripts.h
new file mode 100644
index 0000000..b5b7035
--- /dev/null
+++ b/packageplugins/scripts/scripts.h
@@ -0,0 +1,33 @@
+/******************************************************************************
+* Copyright 2017 by Marco Martin <[email protected]> *
+* *
+* 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 SCRIPTSPACKAGE_H
+#define SCRIPTSPACKAGE_H
+
+#include <KPackage/PackageStructure>
+
+class ScriptsPackage : public KPackage::PackageStructure
+{
+public:
+ ScriptsPackage(QObject*, const QVariantList &) {}
+ void initPackage(KPackage::Package *package) Q_DECL_OVERRIDE;
+ void pathChanged(KPackage::Package *package) Q_DECL_OVERRIDE;
+};
+
+#endif
diff --git a/packageplugins/windowswitcher/CMakeLists.txt b/packageplugins/windowswitcher/CMakeLists.txt
new file mode 100644
index 0000000..d0496d4
--- /dev/null
+++ b/packageplugins/windowswitcher/CMakeLists.txt
@@ -0,0 +1,16 @@
+add_definitions(-DTRANSLATION_DOMAIN=\"kwin_package_windowswitcher\")
+
+set(windowswitcher_SRCS
+ windowswitcher.cpp
+)
+
+add_library(kwin_packagestructure_windowswitcher MODULE ${windowswitcher_SRCS})
+
+target_link_libraries(kwin_packagestructure_windowswitcher
+ KF5::I18n
+ KF5::Package
+)
+
+kcoreaddons_desktop_to_json(kwin_packagestructure_windowswitcher kwin-packagestructure-windowswitcher.desktop)
+
+install(TARGETS kwin_packagestructure_windowswitcher DESTINATION ${KDE_INSTALL_PLUGINDIR}/kpackage/packagestructure)
diff --git a/packageplugins/windowswitcher/kwin-packagestructure-windowswitcher.desktop b/packageplugins/windowswitcher/kwin-packagestructure-windowswitcher.desktop
new file mode 100644
index 0000000..0d89d87
--- /dev/null
+++ b/packageplugins/windowswitcher/kwin-packagestructure-windowswitcher.desktop
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Name=KWin Window Switcher
+Type=Service
+X-KDE-ServiceTypes=KPackage/PackageStructure
+X-KDE-Library=kwin_packagestructure_windowswitcher
+
+X-KDE-PluginInfo-Author=Marco Martin
+X-KDE-PluginInfo-Name=KWin/WindowSwitcher
+X-KDE-PluginInfo-Version=1
diff --git a/packageplugins/windowswitcher/windowswitcher.cpp b/packageplugins/windowswitcher/windowswitcher.cpp
new file mode 100644
index 0000000..a32d953
--- /dev/null
+++ b/packageplugins/windowswitcher/windowswitcher.cpp
@@ -0,0 +1,62 @@
+/******************************************************************************
+* Copyright 2017 by Marco Martin <[email protected]> *
+* *
+* 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 "windowswitcher.h"
+
+#include <KLocalizedString>
+
+void SwitcherPackage::initPackage(KPackage::Package *package)
+{
+ package->setDefaultPackageRoot(QStringLiteral("kwin/tabbox/"));
+
+ 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 windowswitcher"));
+
+ package->addFileDefinition("mainscript", QStringLiteral("ui/main.qml"), i18n("Main Script File"));
+ package->setRequired("mainscript", true);
+
+ mimetypes.clear();
+ mimetypes << QStringLiteral("text/plain");
+ package->setMimeTypes("windowswitcher", mimetypes);
+}
+
+void SwitcherPackage::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(SwitcherPackage, "kwin-packagestructure-windowswitcher.json")
+
+#include "windowswitcher.moc"
+
diff --git a/packageplugins/windowswitcher/windowswitcher.h b/packageplugins/windowswitcher/windowswitcher.h
new file mode 100644
index 0000000..74bbdcc
--- /dev/null
+++ b/packageplugins/windowswitcher/windowswitcher.h
@@ -0,0 +1,33 @@
+/******************************************************************************
+* Copyright 2017 by Marco Martin <[email protected]> *
+* *
+* 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 SWITCHERPACKAGE_H
+#define SWITCHERPACKAGE_H
+
+#include <KPackage/PackageStructure>
+
+class SwitcherPackage : public KPackage::PackageStructure
+{
+public:
+ SwitcherPackage(QObject*, const QVariantList &) {}
+ void initPackage(KPackage::Package *package) Q_DECL_OVERRIDE;
+ void pathChanged(KPackage::Package *package) Q_DECL_OVERRIDE;
+};
+
+#endif