Define Plasma PackageStructure as regular KPackage PackageStructure plugins

This way we can use kpackagetool5 against them (see RR 128590).

REVIEW: 128596
This commit is contained in:
Aleix Pol 2016-08-04 19:23:59 +02:00
parent 3ec4f26e79
commit 67d882037c
22 changed files with 530 additions and 392 deletions

View File

@ -1,3 +1,5 @@
add_subdirectory(packagestructure)
# This option should be removed, or moved down as far as possible.
# That means porting the existing frameworks to the CMake automoc
# feature. Porting is mostly removing explicit moc includes, and
@ -66,7 +68,6 @@ set(Plasma_LIB_SRCS
#packages
package.cpp
packagestructure.cpp
private/packages.cpp
#graphics
framesvg.cpp

View File

@ -20,7 +20,6 @@
#include "containmentactions.h"
#include "containment.h"
#include "private/packages_p.h"
#include "private/containmentactions_p.h"
#include "private/containment_p.h"

View File

@ -40,7 +40,6 @@
#include "pluginloader.h"
#include "private/package_p.h"
#include "private/packagestructure_p.h"
#include "private/packages_p.h"
namespace Plasma
{

View File

@ -0,0 +1,12 @@
function(install_package_structure name)
add_library(${name}_packagestructure MODULE ${name}package.cpp packages.cpp)
target_link_libraries(${name}_packagestructure PRIVATE KF5::Package KF5::Plasma KF5::Declarative KF5::I18n)
install(TARGETS ${name}_packagestructure DESTINATION ${KDE_INSTALL_PLUGINDIR}/kpackage/packagestructure)
endfunction()
install_package_structure(plasmageneric)
install_package_structure(plasmoid)
install_package_structure(dataengine)
install_package_structure(plasmatheme)
install_package_structure(containmentactions)

View File

@ -0,0 +1,14 @@
{
"KPlugin": {
"Authors": [
{
"Email": "aseigo@kde.org",
"Name": "Aaron Seigo"
}
],
"Id": "Plasma/ContainmentActions",
"Name": "Containment Actions",
"ServiceTypes": [ "KPackage/PackageStructure" ],
"Version": "1"
}
}

View File

@ -0,0 +1,43 @@
/******************************************************************************
* Copyright 2007-2009 by Aaron Seigo <aseigo@kde.org> *
* *
* 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 "plasma.h"
#include <kpackage/package.h>
#include <kpackage/packagestructure.h>
#include "packages_p.h"
#include "config-plasma.h"
class ContainmentActionsPackage : public Plasma::ChangeableMainScriptPackage
{
Q_OBJECT
public:
ContainmentActionsPackage(QObject *parent = 0, const QVariantList &args = QVariantList()) : ChangeableMainScriptPackage(parent, args) {}
void initPackage(KPackage::Package *package) Q_DECL_OVERRIDE
{
ChangeableMainScriptPackage::initPackage(package);
package->setDefaultPackageRoot(QStringLiteral(PLASMA_RELATIVE_DATA_INSTALL_DIR "/containmentactions/"));
}
};
K_EXPORT_KPACKAGE_PACKAGE_WITH_JSON(ContainmentActionsPackage, "containmentactions-packagestructure.json")
#include "containmentactionspackage.moc"

View File

@ -0,0 +1,14 @@
{
"KPlugin": {
"Authors": [
{
"Email": "aseigo@kde.org",
"Name": "Aaron Seigo"
}
],
"Id": "Plasma/DataEngine",
"Name": "Data Engine",
"ServiceTypes": [ "KPackage/PackageStructure" ],
"Version": "1"
}
}

View File

@ -0,0 +1,56 @@
/******************************************************************************
* Copyright 2007-2009 by Aaron Seigo <aseigo@kde.org> *
* *
* 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 "plasma.h"
#include <KLocalizedString>
#include <kpackage/package.h>
#include <kpackage/packagestructure.h>
#include "packages_p.h"
#include "config-plasma.h"
class DataEnginePackage : public Plasma::ChangeableMainScriptPackage
{
Q_OBJECT
public:
DataEnginePackage(QObject *parent = 0, const QVariantList &args = QVariantList()) : ChangeableMainScriptPackage(parent, args) {}
void initPackage(KPackage::Package *package) Q_DECL_OVERRIDE
{
ChangeableMainScriptPackage::initPackage(package);
package->setDefaultPackageRoot(QStringLiteral(PLASMA_RELATIVE_DATA_INSTALL_DIR "/dataengines/"));
package->addDirectoryDefinition("data", QStringLiteral("data"), i18n("Data Files"));
package->addDirectoryDefinition("scripts", QStringLiteral("code"), i18n("Executable Scripts"));
QStringList mimetypes;
mimetypes << QStringLiteral("text/plain");
package->setMimeTypes("scripts", mimetypes);
package->addDirectoryDefinition("services", QStringLiteral("services/"), i18n("Service Descriptions"));
package->setMimeTypes("services", mimetypes);
package->addDirectoryDefinition("translations", QStringLiteral("locale"), i18n("Translations"));
}
};
K_EXPORT_KPACKAGE_PACKAGE_WITH_JSON(DataEnginePackage, "dataengine-packagestructure.json")
#include "dataenginepackage.moc"

View File

@ -0,0 +1,111 @@
/******************************************************************************
* Copyright 2007-2009 by Aaron Seigo <aseigo@kde.org> *
* *
* 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 <math.h>
#include <float.h> // FLT_MAX
#include <QCoreApplication>
#include <QFileInfo>
#include <QDebug>
#include <kconfiggroup.h>
#include <kdesktopfile.h>
#include <klocalizedstring.h>
#include <kdeclarative/kdeclarative.h>
#include "packages_p.h"
#include "config-plasma.h"
#include <kpackage/package.h>
namespace Plasma
{
void ChangeableMainScriptPackage::initPackage(KPackage::Package *package)
{
package->addFileDefinition("mainscript", QStringLiteral("ui/main.qml"), i18n("Main Script File"));
package->addFileDefinition("test", QStringLiteral("tests/test.qml"), i18n("Tests"));
package->setRequired("mainscript", true);
}
QString ChangeableMainScriptPackage::mainScriptConfigKey() const
{
return QStringLiteral("X-Plasma-MainScript");
}
void ChangeableMainScriptPackage::pathChanged(KPackage::Package *package)
{
if (package->path().isEmpty()) {
return;
}
KDesktopFile config(package->path() + "/metadata.desktop");
KConfigGroup cg = config.desktopGroup();
QString mainScript = cg.readEntry(mainScriptConfigKey(), QString());
if (!mainScript.isEmpty()) {
package->addFileDefinition("mainscript", mainScript, i18n("Main Script File"));
}
}
void GenericPackage::initPackage(KPackage::Package *package)
{
ChangeableMainScriptPackage::initPackage(package);
QStringList platform = KDeclarative::KDeclarative::runtimePlatform();
if (!platform.isEmpty()) {
QMutableStringListIterator it(platform);
while (it.hasNext()) {
it.next();
it.setValue("platformcontents/" + it.value());
}
platform.append(QStringLiteral("contents"));
package->setContentsPrefixPaths(platform);
}
package->setDefaultPackageRoot(QStringLiteral(PLASMA_RELATIVE_DATA_INSTALL_DIR "/packages/"));
package->addDirectoryDefinition("images", QStringLiteral("images"), i18n("Images"));
package->addDirectoryDefinition("theme", QStringLiteral("theme"), i18n("Themed Images"));
QStringList mimetypes;
mimetypes << QStringLiteral("image/svg+xml") << QStringLiteral("image/png") << QStringLiteral("image/jpeg");
package->setMimeTypes("images", mimetypes);
package->setMimeTypes("theme", mimetypes);
package->addDirectoryDefinition("config", QStringLiteral("config"), i18n("Configuration Definitions"));
mimetypes.clear();
mimetypes << QStringLiteral("text/xml");
package->setMimeTypes("config", mimetypes);
package->addDirectoryDefinition("ui", QStringLiteral("ui"), i18n("User Interface"));
package->addDirectoryDefinition("data", QStringLiteral("data"), i18n("Data Files"));
package->addDirectoryDefinition("scripts", QStringLiteral("code"), i18n("Executable Scripts"));
mimetypes.clear();
mimetypes << QStringLiteral("text/plain");
package->setMimeTypes("scripts", mimetypes);
package->addFileDefinition("screenshot", QStringLiteral("screenshot.png"), i18n("Screenshot"));
package->addDirectoryDefinition("translations", QStringLiteral("locale"), i18n("Translations"));
}
} // namespace Plasma

View File

@ -32,6 +32,8 @@ class ChangeableMainScriptPackage : public KPackage::PackageStructure
{
Q_OBJECT
public:
ChangeableMainScriptPackage(QObject *parent = 0, const QVariantList &args = QVariantList()) : KPackage::PackageStructure(parent, args) {}
void initPackage(KPackage::Package *package) Q_DECL_OVERRIDE;
void pathChanged(KPackage::Package *package) Q_DECL_OVERRIDE;
@ -43,35 +45,7 @@ class GenericPackage : public ChangeableMainScriptPackage
{
Q_OBJECT
public:
void initPackage(KPackage::Package *package) Q_DECL_OVERRIDE;
};
class PlasmoidPackage : public GenericPackage
{
Q_OBJECT
public:
void initPackage(KPackage::Package *package) Q_DECL_OVERRIDE;
void pathChanged(KPackage::Package *package) Q_DECL_OVERRIDE;
};
class DataEnginePackage : public ChangeableMainScriptPackage
{
Q_OBJECT
public:
void initPackage(KPackage::Package *package) Q_DECL_OVERRIDE;
};
class ThemePackage : public KPackage::PackageStructure
{
Q_OBJECT
public:
void initPackage(KPackage::Package *package) Q_DECL_OVERRIDE;
};
class ContainmentActionsPackage : public ChangeableMainScriptPackage
{
Q_OBJECT
public:
GenericPackage(QObject *parent = 0, const QVariantList &args = QVariantList()) : ChangeableMainScriptPackage(parent, args) {}
void initPackage(KPackage::Package *package) Q_DECL_OVERRIDE;
};

View File

@ -0,0 +1,14 @@
{
"KPlugin": {
"Authors": [
{
"Email": "aseigo@kde.org",
"Name": "Aaron Seigo"
}
],
"Id": "Plasma/Generic",
"Name": "Generic",
"ServiceTypes": [ "KPackage/PackageStructure" ],
"Version": "1"
}
}

View File

@ -0,0 +1,29 @@
/******************************************************************************
* Copyright 2007-2009 by Aaron Seigo <aseigo@kde.org> *
* *
* 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 "plasma.h"
#include <KLocalizedString>
#include <kpackage/package.h>
#include <kpackage/packagestructure.h>
#include "packages_p.h"
K_EXPORT_KPACKAGE_PACKAGE_WITH_JSON(Plasma::GenericPackage, "plasmageneric-packagestructure.json")
#include "plasmagenericpackage.moc"

View File

@ -0,0 +1,14 @@
{
"KPlugin": {
"Authors": [
{
"Email": "aseigo@kde.org",
"Name": "Aaron Seigo"
}
],
"Id": "Plasma/Theme",
"Name": "Plasma Theme",
"ServiceTypes": [ "KPackage/PackageStructure" ],
"Version": "1"
}
}

View File

@ -0,0 +1,136 @@
/******************************************************************************
* Copyright 2007-2009 by Aaron Seigo <aseigo@kde.org> *
* *
* 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 "plasma.h"
#include <KLocalizedString>
#include <kpackage/package.h>
#include <kpackage/packagestructure.h>
class ThemePackage : public KPackage::PackageStructure
{
Q_OBJECT
public:
ThemePackage(QObject *parent = 0, const QVariantList &args = QVariantList()) : KPackage::PackageStructure(parent, args) {}
void initPackage(KPackage::Package *package) Q_DECL_OVERRIDE
{
// by default the packages have "contents/" as contentsPrefixPaths
// but for the themes we don't want that, so unset it.
package->setContentsPrefixPaths(QStringList());
package->addDirectoryDefinition("dialogs", QStringLiteral("dialogs/"), i18n("Images for dialogs"));
package->addFileDefinition("dialogs/background", QStringLiteral("dialogs/background.svg"),
i18n("Generic dialog background"));
package->addFileDefinition("dialogs/background", QStringLiteral("dialogs/background.svgz"),
i18n("Generic dialog background"));
package->addFileDefinition("dialogs/shutdowndialog", QStringLiteral("dialogs/shutdowndialog.svg"),
i18n("Theme for the logout dialog"));
package->addFileDefinition("dialogs/shutdowndialog", QStringLiteral("dialogs/shutdowndialog.svgz"),
i18n("Theme for the logout dialog"));
package->addDirectoryDefinition("wallpapers", QStringLiteral("wallpapers/"), i18n("Wallpaper packages"));
package->addDirectoryDefinition("widgets", QStringLiteral("widgets/"), i18n("Images for widgets"));
package->addFileDefinition("widgets/background", QStringLiteral("widgets/background.svg"),
i18n("Background image for widgets"));
package->addFileDefinition("widgets/background", QStringLiteral("widgets/background.svgz"),
i18n("Background image for widgets"));
package->addFileDefinition("widgets/clock", QStringLiteral("widgets/clock.svg"),
i18n("Analog clock face"));
package->addFileDefinition("widgets/clock", QStringLiteral("widgets/clock.svgz"),
i18n("Analog clock face"));
package->addFileDefinition("widgets/panel-background", QStringLiteral("widgets/panel-background.svg"),
i18n("Background image for panels"));
package->addFileDefinition("widgets/panel-background", QStringLiteral("widgets/panel-background.svgz"),
i18n("Background image for panels"));
package->addFileDefinition("widgets/plot-background", QStringLiteral("widgets/plot-background.svg"),
i18n("Background for graphing widgets"));
package->addFileDefinition("widgets/plot-background", QStringLiteral("widgets/plot-background.svgz"),
i18n("Background for graphing widgets"));
package->addFileDefinition("widgets/tooltip", QStringLiteral("widgets/tooltip.svg"),
i18n("Background image for tooltips"));
package->addFileDefinition("widgets/tooltip", QStringLiteral("widgets/tooltip.svgz"),
i18n("Background image for tooltips"));
package->addDirectoryDefinition("opaque/dialogs", QStringLiteral("opaque/dialogs/"), i18n("Opaque images for dialogs"));
package->addFileDefinition("opaque/dialogs/background", QStringLiteral("opaque/dialogs/background.svg"),
i18n("Opaque generic dialog background"));
package->addFileDefinition("opaque/dialogs/background", QStringLiteral("opaque/dialogs/background.svgz"),
i18n("Opaque generic dialog background"));
package->addFileDefinition("opaque/dialogs/shutdowndialog", QStringLiteral("opaque/dialogs/shutdowndialog.svg"),
i18n("Opaque theme for the logout dialog"));
package->addFileDefinition("opaque/dialogs/shutdowndialog", QStringLiteral("opaque/dialogs/shutdowndialog.svgz"),
i18n("Opaque theme for the logout dialog"));
package->addDirectoryDefinition("opaque/widgets", QStringLiteral("opaque/widgets/"), i18n("Opaque images for widgets"));
package->addFileDefinition("opaque/widgets/panel-background", QStringLiteral("opaque/widgets/panel-background.svg"),
i18n("Opaque background image for panels"));
package->addFileDefinition("opaque/widgets/panel-background", QStringLiteral("opaque/widgets/panel-background.svgz"),
i18n("Opaque background image for panels"));
package->addFileDefinition("opaque/widgets/tooltip", QStringLiteral("opaque/widgets/tooltip.svg"),
i18n("Opaque background image for tooltips"));
package->addFileDefinition("opaque/widgets/tooltip", QStringLiteral("opaque/widgets/tooltip.svgz"),
i18n("Opaque background image for tooltips"));
package->addDirectoryDefinition("locolor/dialogs", QStringLiteral("locolor/dialogs/"),
i18n("Low color images for dialogs"));
package->addFileDefinition("locolor/dialogs/background", QStringLiteral("locolor/dialogs/background.svg"),
i18n("Low color generic dialog background"));
package->addFileDefinition("locolor/dialogs/background", QStringLiteral("locolor/dialogs/background.svgz"),
i18n("Low color generic dialog background"));
package->addFileDefinition("locolor/dialogs/shutdowndialog", QStringLiteral("locolor/dialogs/shutdowndialog.svg"),
i18n("Low color theme for the logout dialog"));
package->addFileDefinition("locolor/dialogs/shutdowndialog", QStringLiteral("locolor/dialogs/shutdowndialog.svgz"),
i18n("Low color theme for the logout dialog"));
package->addDirectoryDefinition("locolor/widgets", QStringLiteral("locolor/widgets/"), i18n("Images for widgets"));
package->addFileDefinition("locolor/widgets/background", QStringLiteral("locolor/widgets/background.svg"),
i18n("Low color background image for widgets"));
package->addFileDefinition("locolor/widgets/background", QStringLiteral("locolor/widgets/background.svgz"),
i18n("Low color background image for widgets"));
package->addFileDefinition("locolor/widgets/clock", QStringLiteral("locolor/widgets/clock.svg"),
i18n("Low color analog clock face"));
package->addFileDefinition("locolor/widgets/clock", QStringLiteral("locolor/widgets/clock.svgz"),
i18n("Low color analog clock face"));
package->addFileDefinition("locolor/widgets/panel-background", QStringLiteral("locolor/widgets/panel-background.svg"),
i18n("Low color background image for panels"));
package->addFileDefinition("locolor/widgets/panel-background", QStringLiteral("locolor/widgets/panel-background.svgz"),
i18n("Low color background image for panels"));
package->addFileDefinition("locolor/widgets/plot-background", QStringLiteral("locolor/widgets/plot-background.svg"),
i18n("Low color background for graphing widgets"));
package->addFileDefinition("locolor/widgets/plot-background", QStringLiteral("locolor/widgets/plot-background.svgz"),
i18n("Low color background for graphing widgets"));
package->addFileDefinition("locolor/widgets/tooltip", QStringLiteral("locolor/widgets/tooltip.svg"),
i18n("Low color background image for tooltips"));
package->addFileDefinition("locolor/widgets/tooltip", QStringLiteral("locolor/widgets/tooltip.svgz"),
i18n("Low color background image for tooltips"));
package->addFileDefinition("colors", QStringLiteral("colors"), i18n("KColorScheme configuration file"));
QStringList mimetypes;
mimetypes << QStringLiteral("image/svg+xml");
package->setDefaultMimeTypes(mimetypes);
}
};
K_EXPORT_KPACKAGE_PACKAGE_WITH_JSON(ThemePackage, "plasmatheme-packagestructure.json")
#include "plasmathemepackage.moc"

View File

@ -0,0 +1,14 @@
{
"KPlugin": {
"Authors": [
{
"Email": "aseigo@kde.org",
"Name": "Aaron Seigo"
}
],
"Id": "Plasma/Applet",
"Name": "Plasmoid",
"ServiceTypes": [ "KPackage/PackageStructure" ],
"Version": "1"
}
}

View File

@ -0,0 +1,60 @@
/******************************************************************************
* Copyright 2007-2009 by Aaron Seigo <aseigo@kde.org> *
* *
* 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 "plasma.h"
#include <kpackage/package.h>
#include <kpackage/packagestructure.h>
#include <KLocalizedString>
#include "packages_p.h"
#include "config-plasma.h"
class PlasmoidPackage : public Plasma::GenericPackage
{
Q_OBJECT
public:
PlasmoidPackage(QObject *parent = 0, const QVariantList &args = QVariantList()) : GenericPackage(parent, args) {}
void initPackage(KPackage::Package *package) Q_DECL_OVERRIDE
{
GenericPackage::initPackage(package);
package->setDefaultPackageRoot(QStringLiteral(PLASMA_RELATIVE_DATA_INSTALL_DIR "/plasmoids/"));
package->addFileDefinition("configmodel", QStringLiteral("config/config.qml"), i18n("Configuration UI pages model"));
package->addFileDefinition("mainconfigxml", QStringLiteral("config/main.xml"), i18n("Configuration XML file"));
}
void pathChanged(KPackage::Package *package) Q_DECL_OVERRIDE
{
ChangeableMainScriptPackage::pathChanged(package);
if (!package->metadata().isValid()) {
return;
}
if (package->metadata().serviceTypes().contains(QStringLiteral("Plasma/Containment"))) {
package->addFileDefinition("compactapplet", QStringLiteral("applet/CompactApplet.qml"), i18n("Custom expander for compact applets"));
} else {
package->removeDefinition("compactapplet");
}
}
};
K_EXPORT_KPACKAGE_PACKAGE_WITH_JSON(PlasmoidPackage, "plasmoid-packagestructure.json")
#include "plasmoidpackage.moc"

View File

@ -23,7 +23,6 @@
#include <QMenu>
#include "containment.h"
#include "private/packages_p.h"
namespace Plasma
{

View File

@ -40,7 +40,6 @@
#include "dataengine.h"
#include "package.h"
#include "private/applet_p.h"
#include "private/packages_p.h"
#include "private/service_p.h" // for NullService
#include "private/storage_p.h"
#include "private/package_p.h"
@ -60,11 +59,6 @@ public:
: isDefaultLoader(false),
packageRE("[^a-zA-Z0-9\\-_]")
{
KPackage::PackageLoader::self()->addKnownPackageStructure(QStringLiteral("Plasma/Applet"), new PlasmoidPackage());
KPackage::PackageLoader::self()->addKnownPackageStructure(QStringLiteral("Plasma/DataEngine"), new DataEnginePackage());
KPackage::PackageLoader::self()->addKnownPackageStructure(QStringLiteral("Plasma/Theme"), new ThemePackage());
KPackage::PackageLoader::self()->addKnownPackageStructure(QStringLiteral("Plasma/ContainmentActions"), new ContainmentActionsPackage());
KPackage::PackageLoader::self()->addKnownPackageStructure(QStringLiteral("Plasma/Generic"), new GenericPackage());
}
static QSet<QString> knownCategories();
@ -292,10 +286,6 @@ DataEngine *PluginLoader::loadDataEngine(const QString &name)
QStringList PluginLoader::listAllEngines(const QString &parentApp)
{
if (!KPackage::PackageLoader::self()->loadPackageStructure(QStringLiteral("Plasma/DataEngine"))) {
KPackage::PackageLoader::self()->addKnownPackageStructure(QStringLiteral("Plasma/DataEngine"), new DataEnginePackage());
}
QStringList engines;
// Look for C++ plugins first
auto filter = [&parentApp](const KPluginMetaData &md) -> bool
@ -323,18 +313,11 @@ QStringList PluginLoader::listAllEngines(const QString &parentApp)
KPluginInfo::List PluginLoader::listEngineInfo(const QString &parentApp)
{
if (!KPackage::PackageLoader::self()->loadPackageStructure(QStringLiteral("Plasma/DataEngine"))) {
KPackage::PackageLoader::self()->addKnownPackageStructure(QStringLiteral("Plasma/DataEngine"), new DataEnginePackage());
}
return PluginLoader::self()->listDataEngineInfo(parentApp);
}
KPluginInfo::List PluginLoader::listEngineInfoByCategory(const QString &category, const QString &parentApp)
{
if (!KPackage::PackageLoader::self()->loadPackageStructure(QStringLiteral("Plasma/DataEngine"))) {
KPackage::PackageLoader::self()->addKnownPackageStructure(QStringLiteral("Plasma/DataEngine"), new DataEnginePackage());
}
KPluginInfo::List list;
// Look for C++ plugins first
@ -489,33 +472,11 @@ Package PluginLoader::loadPackage(const QString &packageFormat, const QString &s
const QString hashkey = packageFormat + '%' + specialization;
PackageStructure *structure = d->structures.value(hashkey).data();
KPackage::PackageStructure *internalStructure = 0;
if (structure) {
return Package(structure);
}
if (packageFormat.startsWith(QLatin1String("Plasma"))) {
if (packageFormat.endsWith(QLatin1String("/Applet"))) {
internalStructure = new PlasmoidPackage();
} else if (packageFormat.endsWith(QLatin1String("/DataEngine"))) {
internalStructure = new DataEnginePackage();
} else if (packageFormat.endsWith(QLatin1String("/Theme"))) {
internalStructure = new ThemePackage();
} else if (packageFormat.endsWith(QLatin1String("/ContainmentActions"))) {
internalStructure = new ContainmentActionsPackage();
} else if (packageFormat.endsWith(QLatin1String("/Generic"))) {
internalStructure = new GenericPackage();
}
if (internalStructure) {
structure = new PackageStructure();
structure->d->internalStructure = internalStructure;
d->structures.insert(hashkey, structure);
return Package(structure);
}
}
internalStructure = KPackage::PackageLoader::self()->loadPackageStructure(packageFormat);
KPackage::PackageStructure *internalStructure = KPackage::PackageLoader::self()->loadPackageStructure(packageFormat);
if (internalStructure) {
structure = new PackageStructure();
@ -707,10 +668,6 @@ KPluginInfo::List PluginLoader::listContainmentsOfType(const QString &type,
const QString &category,
const QString &parentApp)
{
if (!KPackage::PackageLoader::self()->loadPackageStructure(QStringLiteral("Plasma/Applet"))) {
KPackage::PackageLoader::self()->addKnownPackageStructure(QStringLiteral("Plasma/Applet"), new PlasmoidPackage());
}
KConfigGroup group(KSharedConfig::openConfig(), "General");
const QStringList excluded = group.readEntry("ExcludeCategories", QStringList());
auto filter = [&type, &category, &parentApp](const KPluginMetaData &md) -> bool
@ -739,9 +696,6 @@ KPluginInfo::List PluginLoader::listContainmentsOfType(const QString &type,
KPluginInfo::List PluginLoader::listContainmentsForMimeType(const QString &mimeType)
{
if (!KPackage::PackageLoader::self()->loadPackageStructure(QStringLiteral("Plasma/Applet"))) {
KPackage::PackageLoader::self()->addKnownPackageStructure(QStringLiteral("Plasma/Applet"), new DataEnginePackage());
}
auto filter = [&mimeType](const KPluginMetaData &md) -> bool
{
return md.value(QStringLiteral("X-KDE-ServiceTypes")).contains(QLatin1String("Plasma/Containment"))
@ -753,9 +707,6 @@ KPluginInfo::List PluginLoader::listContainmentsForMimeType(const QString &mimeT
QStringList PluginLoader::listContainmentTypes()
{
if (!KPackage::PackageLoader::self()->loadPackageStructure(QStringLiteral("Plasma/Applet"))) {
KPackage::PackageLoader::self()->addKnownPackageStructure(QStringLiteral("Plasma/Applet"), new DataEnginePackage());
}
KPluginInfo::List containmentInfos = listContainments();
QSet<QString> types;

View File

@ -1,261 +0,0 @@
/******************************************************************************
* Copyright 2007-2009 by Aaron Seigo <aseigo@kde.org> *
* *
* 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 "private/packages_p.h"
#include <math.h>
#include <float.h> // FLT_MAX
#include <QCoreApplication>
#include <QFileInfo>
#include <QDebug>
#include <kconfiggroup.h>
#include <kdesktopfile.h>
#include <klocalizedstring.h>
#include <kmessagebox.h>
#include <kdeclarative/kdeclarative.h>
#include "package.h"
#include "config-plasma.h"
#include <kpackage/package.h>
namespace Plasma
{
void ChangeableMainScriptPackage::initPackage(KPackage::Package *package)
{
package->addFileDefinition("mainscript", QStringLiteral("ui/main.qml"), i18n("Main Script File"));
package->addFileDefinition("test", QStringLiteral("tests/test.qml"), i18n("Tests"));
package->setRequired("mainscript", true);
}
QString ChangeableMainScriptPackage::mainScriptConfigKey() const
{
return QStringLiteral("X-Plasma-MainScript");
}
void ChangeableMainScriptPackage::pathChanged(KPackage::Package *package)
{
if (package->path().isEmpty()) {
return;
}
KDesktopFile config(package->path() + "/metadata.desktop");
KConfigGroup cg = config.desktopGroup();
QString mainScript = cg.readEntry(mainScriptConfigKey(), QString());
if (!mainScript.isEmpty()) {
package->addFileDefinition("mainscript", mainScript, i18n("Main Script File"));
}
}
void GenericPackage::initPackage(KPackage::Package *package)
{
ChangeableMainScriptPackage::initPackage(package);
QStringList platform = KDeclarative::KDeclarative::runtimePlatform();
if (!platform.isEmpty()) {
QMutableStringListIterator it(platform);
while (it.hasNext()) {
it.next();
it.setValue("platformcontents/" + it.value());
}
platform.append(QStringLiteral("contents"));
package->setContentsPrefixPaths(platform);
}
package->setDefaultPackageRoot(QStringLiteral(PLASMA_RELATIVE_DATA_INSTALL_DIR "/packages/"));
package->addDirectoryDefinition("images", QStringLiteral("images"), i18n("Images"));
package->addDirectoryDefinition("theme", QStringLiteral("theme"), i18n("Themed Images"));
QStringList mimetypes;
mimetypes << QStringLiteral("image/svg+xml") << QStringLiteral("image/png") << QStringLiteral("image/jpeg");
package->setMimeTypes("images", mimetypes);
package->setMimeTypes("theme", mimetypes);
package->addDirectoryDefinition("config", QStringLiteral("config"), i18n("Configuration Definitions"));
mimetypes.clear();
mimetypes << QStringLiteral("text/xml");
package->setMimeTypes("config", mimetypes);
package->addDirectoryDefinition("ui", QStringLiteral("ui"), i18n("User Interface"));
package->addDirectoryDefinition("data", QStringLiteral("data"), i18n("Data Files"));
package->addDirectoryDefinition("scripts", QStringLiteral("code"), i18n("Executable Scripts"));
mimetypes.clear();
mimetypes << QStringLiteral("text/plain");
package->setMimeTypes("scripts", mimetypes);
package->addFileDefinition("screenshot", QStringLiteral("screenshot.png"), i18n("Screenshot"));
package->addDirectoryDefinition("translations", QStringLiteral("locale"), i18n("Translations"));
}
void PlasmoidPackage::initPackage(KPackage::Package *package)
{
GenericPackage::initPackage(package);
package->setDefaultPackageRoot(QStringLiteral(PLASMA_RELATIVE_DATA_INSTALL_DIR "/plasmoids/"));
package->addFileDefinition("configmodel", QStringLiteral("config/config.qml"), i18n("Configuration UI pages model"));
package->addFileDefinition("mainconfigxml", QStringLiteral("config/main.xml"), i18n("Configuration XML file"));
}
void PlasmoidPackage::pathChanged(KPackage::Package *package)
{
ChangeableMainScriptPackage::pathChanged(package);
if (!package->metadata().isValid()) {
return;
}
if (package->metadata().serviceTypes().contains(QStringLiteral("Plasma/Containment"))) {
package->addFileDefinition("compactapplet", QStringLiteral("applet/CompactApplet.qml"), i18n("Custom expander for compact applets"));
} else {
package->removeDefinition("compactapplet");
}
}
void DataEnginePackage::initPackage(KPackage::Package *package)
{
ChangeableMainScriptPackage::initPackage(package);
package->setDefaultPackageRoot(QStringLiteral(PLASMA_RELATIVE_DATA_INSTALL_DIR "/dataengines/"));
package->addDirectoryDefinition("data", QStringLiteral("data"), i18n("Data Files"));
package->addDirectoryDefinition("scripts", QStringLiteral("code"), i18n("Executable Scripts"));
QStringList mimetypes;
mimetypes << QStringLiteral("text/plain");
package->setMimeTypes("scripts", mimetypes);
package->addDirectoryDefinition("services", QStringLiteral("services/"), i18n("Service Descriptions"));
package->setMimeTypes("services", mimetypes);
package->addDirectoryDefinition("translations", QStringLiteral("locale"), i18n("Translations"));
}
void ThemePackage::initPackage(KPackage::Package *package)
{
// by default the packages have "contents/" as contentsPrefixPaths
// but for the themes we don't want that, so unset it.
package->setContentsPrefixPaths(QStringList());
package->addDirectoryDefinition("dialogs", QStringLiteral("dialogs/"), i18n("Images for dialogs"));
package->addFileDefinition("dialogs/background", QStringLiteral("dialogs/background.svg"),
i18n("Generic dialog background"));
package->addFileDefinition("dialogs/background", QStringLiteral("dialogs/background.svgz"),
i18n("Generic dialog background"));
package->addFileDefinition("dialogs/shutdowndialog", QStringLiteral("dialogs/shutdowndialog.svg"),
i18n("Theme for the logout dialog"));
package->addFileDefinition("dialogs/shutdowndialog", QStringLiteral("dialogs/shutdowndialog.svgz"),
i18n("Theme for the logout dialog"));
package->addDirectoryDefinition("wallpapers", QStringLiteral("wallpapers/"), i18n("Wallpaper packages"));
package->addDirectoryDefinition("widgets", QStringLiteral("widgets/"), i18n("Images for widgets"));
package->addFileDefinition("widgets/background", QStringLiteral("widgets/background.svg"),
i18n("Background image for widgets"));
package->addFileDefinition("widgets/background", QStringLiteral("widgets/background.svgz"),
i18n("Background image for widgets"));
package->addFileDefinition("widgets/clock", QStringLiteral("widgets/clock.svg"),
i18n("Analog clock face"));
package->addFileDefinition("widgets/clock", QStringLiteral("widgets/clock.svgz"),
i18n("Analog clock face"));
package->addFileDefinition("widgets/panel-background", QStringLiteral("widgets/panel-background.svg"),
i18n("Background image for panels"));
package->addFileDefinition("widgets/panel-background", QStringLiteral("widgets/panel-background.svgz"),
i18n("Background image for panels"));
package->addFileDefinition("widgets/plot-background", QStringLiteral("widgets/plot-background.svg"),
i18n("Background for graphing widgets"));
package->addFileDefinition("widgets/plot-background", QStringLiteral("widgets/plot-background.svgz"),
i18n("Background for graphing widgets"));
package->addFileDefinition("widgets/tooltip", QStringLiteral("widgets/tooltip.svg"),
i18n("Background image for tooltips"));
package->addFileDefinition("widgets/tooltip", QStringLiteral("widgets/tooltip.svgz"),
i18n("Background image for tooltips"));
package->addDirectoryDefinition("opaque/dialogs", QStringLiteral("opaque/dialogs/"), i18n("Opaque images for dialogs"));
package->addFileDefinition("opaque/dialogs/background", QStringLiteral("opaque/dialogs/background.svg"),
i18n("Opaque generic dialog background"));
package->addFileDefinition("opaque/dialogs/background", QStringLiteral("opaque/dialogs/background.svgz"),
i18n("Opaque generic dialog background"));
package->addFileDefinition("opaque/dialogs/shutdowndialog", QStringLiteral("opaque/dialogs/shutdowndialog.svg"),
i18n("Opaque theme for the logout dialog"));
package->addFileDefinition("opaque/dialogs/shutdowndialog", QStringLiteral("opaque/dialogs/shutdowndialog.svgz"),
i18n("Opaque theme for the logout dialog"));
package->addDirectoryDefinition("opaque/widgets", QStringLiteral("opaque/widgets/"), i18n("Opaque images for widgets"));
package->addFileDefinition("opaque/widgets/panel-background", QStringLiteral("opaque/widgets/panel-background.svg"),
i18n("Opaque background image for panels"));
package->addFileDefinition("opaque/widgets/panel-background", QStringLiteral("opaque/widgets/panel-background.svgz"),
i18n("Opaque background image for panels"));
package->addFileDefinition("opaque/widgets/tooltip", QStringLiteral("opaque/widgets/tooltip.svg"),
i18n("Opaque background image for tooltips"));
package->addFileDefinition("opaque/widgets/tooltip", QStringLiteral("opaque/widgets/tooltip.svgz"),
i18n("Opaque background image for tooltips"));
package->addDirectoryDefinition("locolor/dialogs", QStringLiteral("locolor/dialogs/"),
i18n("Low color images for dialogs"));
package->addFileDefinition("locolor/dialogs/background", QStringLiteral("locolor/dialogs/background.svg"),
i18n("Low color generic dialog background"));
package->addFileDefinition("locolor/dialogs/background", QStringLiteral("locolor/dialogs/background.svgz"),
i18n("Low color generic dialog background"));
package->addFileDefinition("locolor/dialogs/shutdowndialog", QStringLiteral("locolor/dialogs/shutdowndialog.svg"),
i18n("Low color theme for the logout dialog"));
package->addFileDefinition("locolor/dialogs/shutdowndialog", QStringLiteral("locolor/dialogs/shutdowndialog.svgz"),
i18n("Low color theme for the logout dialog"));
package->addDirectoryDefinition("locolor/widgets", QStringLiteral("locolor/widgets/"), i18n("Images for widgets"));
package->addFileDefinition("locolor/widgets/background", QStringLiteral("locolor/widgets/background.svg"),
i18n("Low color background image for widgets"));
package->addFileDefinition("locolor/widgets/background", QStringLiteral("locolor/widgets/background.svgz"),
i18n("Low color background image for widgets"));
package->addFileDefinition("locolor/widgets/clock", QStringLiteral("locolor/widgets/clock.svg"),
i18n("Low color analog clock face"));
package->addFileDefinition("locolor/widgets/clock", QStringLiteral("locolor/widgets/clock.svgz"),
i18n("Low color analog clock face"));
package->addFileDefinition("locolor/widgets/panel-background", QStringLiteral("locolor/widgets/panel-background.svg"),
i18n("Low color background image for panels"));
package->addFileDefinition("locolor/widgets/panel-background", QStringLiteral("locolor/widgets/panel-background.svgz"),
i18n("Low color background image for panels"));
package->addFileDefinition("locolor/widgets/plot-background", QStringLiteral("locolor/widgets/plot-background.svg"),
i18n("Low color background for graphing widgets"));
package->addFileDefinition("locolor/widgets/plot-background", QStringLiteral("locolor/widgets/plot-background.svgz"),
i18n("Low color background for graphing widgets"));
package->addFileDefinition("locolor/widgets/tooltip", QStringLiteral("locolor/widgets/tooltip.svg"),
i18n("Low color background image for tooltips"));
package->addFileDefinition("locolor/widgets/tooltip", QStringLiteral("locolor/widgets/tooltip.svgz"),
i18n("Low color background image for tooltips"));
package->addFileDefinition("colors", QStringLiteral("colors"), i18n("KColorScheme configuration file"));
QStringList mimetypes;
mimetypes << QStringLiteral("image/svg+xml");
package->setDefaultMimeTypes(mimetypes);
}
void ContainmentActionsPackage::initPackage(KPackage::Package *package)
{
ChangeableMainScriptPackage::initPackage(package);
package->setDefaultPackageRoot(QStringLiteral(PLASMA_RELATIVE_DATA_INSTALL_DIR "/containmentactions/"));
}
} // namespace Plasma

View File

@ -42,7 +42,6 @@
#include <kwindowsystem.h>
#include <qstandardpaths.h>
#include "private/packages_p.h"
#include "debug_p.h"
namespace Plasma

View File

@ -19,58 +19,25 @@
#include "shellpluginloader.h"
#include "private/packages.h"
#include <KPackage/PackageLoader>
#include <QDebug>
// when BC can be broken, these should become class members
static Plasma::PackageStructure *m_lnfPackage = 0;
static Plasma::PackageStructure *m_qmlPackage = 0;
static Plasma::PackageStructure *m_layoutPackage = 0;
ShellPluginLoader::ShellPluginLoader()
: Plasma::PluginLoader()/*, when BC can be broken, these should become class members
m_lnfPackage(0),
m_qmlPackage(0),
m_layoutPackage(0)*/
{
Q_ASSERT(false);
}
ShellPluginLoader::~ShellPluginLoader()
{
delete m_lnfPackage;
m_lnfPackage = 0;
delete m_qmlPackage;
m_qmlPackage = 0;
delete m_layoutPackage;
m_layoutPackage = 0;
}
Plasma::Package ShellPluginLoader::internalLoadPackage(const QString &packageFormat, const QString &specialization)
{
Q_UNUSED(specialization)
if (packageFormat == QLatin1String("Plasma/LookAndFeel")) {
if (!m_lnfPackage) {
m_lnfPackage = new LookAndFeelPackage();
}
return Plasma::Package(m_lnfPackage);
} else if (packageFormat == QLatin1String("Plasma/Wallpaper")) {
if (!m_qmlPackage) {
m_qmlPackage = new QmlWallpaperPackage();
}
return Plasma::Package(m_qmlPackage);
} else if (packageFormat == QLatin1String("Plasma/LayoutTemplate")) {
if (!m_layoutPackage) {
m_layoutPackage = new LayoutTemplatePackage();
}
return Plasma::Package(m_layoutPackage);
} else {
return Plasma::Package();
}
Q_ASSERT(false);
}
void ShellPluginLoader::init()

View File

@ -24,7 +24,10 @@
#include <plasmaquick/plasmaquick_export.h>
class PLASMAQUICK_EXPORT ShellPluginLoader : public Plasma::PluginLoader
/**
* @deprecated, don't use
*/
class PLASMAQUICK_DEPRECATED_EXPORT ShellPluginLoader : public Plasma::PluginLoader
{
public:
ShellPluginLoader();
@ -34,16 +37,6 @@ public:
protected:
Plasma::Package internalLoadPackage(const QString &packageFormat, const QString &specialization) Q_DECL_OVERRIDE;
/**
These members are actually file-static in the .cpp because binary compat must be preserved
and there is no dptr!
private:
Plasma::PackageStructure *m_lnfPackage;
Plasma::PackageStructure *m_qmlPackage;
Plasma::PackageStructure *m_layoutPackage;
**/
};
#endif