Libplasma

shellpackage.cpp
1/*
2 SPDX-FileCopyrightText: 2013 Marco Martin <notmart@gmail.com>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include <KPackage/PackageLoader>
8#include <KPackage/PackageStructure>
9
10#include <QDebug>
11#include <QDir>
12#include <QStandardPaths>
13
14#define DEFAULT_SHELL "org.kde.plasma.desktop"
15
16class ShellPackage : public KPackage::PackageStructure
17{
19public:
20 using KPackage::PackageStructure::PackageStructure;
21
22 void initPackage(KPackage::Package *package) override
23 {
24 package->setDefaultPackageRoot(QStringLiteral("plasma/shells/"));
25
26 // Directories
27 package->addDirectoryDefinition("applet", QStringLiteral("applet"));
28 package->addDirectoryDefinition("configuration", QStringLiteral("configuration"));
29 package->addDirectoryDefinition("explorer", QStringLiteral("explorer"));
30 package->addDirectoryDefinition("views", QStringLiteral("views"));
31
32 package->setMimeTypes("applet", QStringList{QStringLiteral("text/x-qml")});
33 package->setMimeTypes("configuration", QStringList{QStringLiteral("text/x-qml")});
34 package->setMimeTypes("views", QStringList{QStringLiteral("text/x-qml")});
35
36 // Files
37 // Default layout
38 package->addFileDefinition("defaultlayout", QStringLiteral("layout.js"));
39 package->addFileDefinition("defaults", QStringLiteral("defaults"));
40 package->setMimeTypes("defaultlayout", QStringList{QStringLiteral("application/javascript"), QStringLiteral("text/javascript")});
41 package->setMimeTypes("defaults", QStringList{QStringLiteral("text/plain")});
42
43 // OSD
44 package->addDirectoryDefinition("osd", QStringLiteral("osd"));
45 package->addFileDefinition("osdmainscript", QStringLiteral("osd/Osd.qml"));
46
47 // Applet furniture
48 package->addFileDefinition("appleterror", QStringLiteral("applet/AppletError.qml"));
49 package->addFileDefinition("compactapplet", QStringLiteral("applet/CompactApplet.qml"));
50 package->addFileDefinition("defaultcompactrepresentation", QStringLiteral("applet/DefaultCompactRepresentation.qml"));
51
52 // Configuration
53 package->addFileDefinition("appletconfigurationui", QStringLiteral("configuration/AppletConfiguration.qml"));
54 package->addFileDefinition("containmentconfigurationui", QStringLiteral("configuration/ContainmentConfiguration.qml"));
55 package->addFileDefinition("panelconfigurationui", QStringLiteral("configuration/PanelConfiguration.qml"));
56 package->addFileDefinition("appletalternativesui", QStringLiteral("explorer/AppletAlternatives.qml"));
57 package->addFileDefinition("containmentmanagementui", QStringLiteral("configuration/ShellContainmentConfiguration.qml"));
58
59 // Widget explorer
60 package->addFileDefinition("widgetexplorer", QStringLiteral("explorer/WidgetExplorer.qml"));
61
62 // Lock screen
63 package->addDirectoryDefinition("lockscreen", QStringLiteral("lockscreen"));
64 package->addFileDefinition("lockscreenmainscript", QStringLiteral("lockscreen/LockScreen.qml"));
65
66 package->addFileDefinition("interactiveconsole", QStringLiteral("InteractiveConsole.qml"));
67 }
68
69 void pathChanged(KPackage::Package *package) override
70 {
71 if (!package->metadata().isValid()) {
72 return;
73 }
74
75 const QString pluginName = package->metadata().pluginId();
76 if (!pluginName.isEmpty() && pluginName != QStringLiteral(DEFAULT_SHELL)) {
77 const QString fallback = package->metadata().value(u"X-Plasma-FallbackPackage", QStringLiteral(DEFAULT_SHELL));
78
79 KPackage::Package pkg = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Plasma/Shell"), fallback);
80 package->setFallbackPackage(pkg);
81 } else if (package->fallbackPackage().isValid() && pluginName == QStringLiteral(DEFAULT_SHELL)) {
83 }
84 }
85};
86
87K_PLUGIN_CLASS_WITH_JSON(ShellPackage, "plasma-packagestructure-plasma-shell.json")
88
89#include "shellpackage.moc"
Package loadPackage(const QString &packageFormat, const QString &packagePath=QString())
static PackageLoader * self()
void setMimeTypes(const QByteArray &key, const QStringList &mimeTypes)
bool isValid() const
void addDirectoryDefinition(const QByteArray &key, const QString &path)
void addFileDefinition(const QByteArray &key, const QString &path)
void setDefaultPackageRoot(const QString &packageRoot)
KPluginMetaData metadata() const
KPackage::Package fallbackPackage() const
void setFallbackPackage(const KPackage::Package &package)
#define K_PLUGIN_CLASS_WITH_JSON(classname, jsonFile)
QString pluginId() const
bool value(QStringView key, bool defaultValue) const
bool isValid() const
Q_OBJECTQ_OBJECT
bool isEmpty() const 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.