Libplasma

plasma_applet_packagestructure.cpp
1/*
2 SPDX-FileCopyrightText: 2007-2009 Aaron Seigo <aseigo@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "config-plasma.h"
8#include "packages_p.h"
9#include <KConfigGroup>
10#include <KDesktopFile>
11#include <KPackage/Package>
12#include <KPackage/PackageStructure>
13#include <KPackage/packagestructure_compat_p>
14
15class PlasmoidPackage : public Plasma::GenericPackage
16{
17 Q_OBJECT
18public:
19 using Plasma::GenericPackage::GenericPackage;
20
21 void initPackage(KPackage::Package *package) override
22 {
23 GenericPackage::initPackage(package);
24 package->setDefaultPackageRoot(QStringLiteral(PLASMA_RELATIVE_DATA_INSTALL_DIR "/plasmoids/"));
25
26 package->addFileDefinition("configmodel", QStringLiteral("config/config.qml"));
27 package->addFileDefinition("mainconfigxml", QStringLiteral("config/main.xml"));
28 package->setRequired("metadata", true);
29 package->addFileDefinition("metadata", QStringLiteral("metadata.desktop"));
30 package->setRequired("metadata", true);
31 }
32
33 void pathChanged(KPackage::Package *package) override
34 {
35 GenericPackage::pathChanged(package);
36 if (const KPluginMetaData md = package->metadata(); md.isValid()) {
37 if (md.rawData().contains(QStringLiteral("X-Plasma-ContainmentType"))) {
38 package->addFileDefinition("compactapplet", QStringLiteral("applet/CompactApplet.qml"));
39 } else {
40 package->removeDefinition("compactapplet");
41 }
42 }
43 // The widge explorer uses it to display old incompatible plasmoids
44 KPackagePrivate::convertCompatMetaDataDesktopFile(package);
45 }
46};
47
48K_PLUGIN_CLASS_WITH_JSON(PlasmoidPackage, "plasma_applet_packagestructure.json")
49
50#include "plasma_applet_packagestructure.moc"
void setRequired(const QByteArray &key, bool required)
void addFileDefinition(const QByteArray &key, const QString &path)
void setDefaultPackageRoot(const QString &packageRoot)
KPluginMetaData metadata() const
void removeDefinition(const QByteArray &key)
#define K_PLUGIN_CLASS_WITH_JSON(classname, jsonFile)
bool isValid() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:35 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.