Libplasma

wallpaper.cpp
1/*
2 SPDX-FileCopyrightText: 2007-2009 Aaron Seigo <aseigo@kde.org>
3 SPDX-FileCopyrightText: 2013 Sebastian Kügler <sebas@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#include <KPackage/PackageStructure>
9#include <KRuntimePlatform>
10
11class QmlWallpaperPackage : public KPackage::PackageStructure
12{
14public:
15 using KPackage::PackageStructure::PackageStructure;
16
17 void initPackage(KPackage::Package *package) override
18 {
19 package->addFileDefinition("mainscript", QStringLiteral("ui/main.qml"));
20 package->setRequired("mainscript", true);
21
23 if (!platform.isEmpty()) {
24 QMutableStringListIterator it(platform);
25 while (it.hasNext()) {
26 it.next();
27 it.setValue(QStringLiteral("platformcontents/") + it.value());
28 }
29
30 platform.append(QStringLiteral("contents"));
31 package->setContentsPrefixPaths(platform);
32 }
33
34 package->setDefaultPackageRoot(QStringLiteral("plasma/wallpapers/"));
35
36 package->addDirectoryDefinition("images", QStringLiteral("images"));
37 package->addDirectoryDefinition("theme", QStringLiteral("theme"));
38 const QStringList mimetypes{QStringLiteral("image/svg+xml"), QStringLiteral("image/png"), QStringLiteral("image/jpeg")};
39 package->setMimeTypes("images", mimetypes);
40 package->setMimeTypes("theme", mimetypes);
41
42 package->addDirectoryDefinition("config", QStringLiteral("config"));
43 package->setMimeTypes("config", QStringList{QStringLiteral("text/xml")});
44
45 package->addDirectoryDefinition("ui", QStringLiteral("ui"));
46
47 package->addDirectoryDefinition("data", QStringLiteral("data"));
48
49 package->addDirectoryDefinition("scripts", QStringLiteral("code"));
50 package->setMimeTypes("scripts", QStringList{QStringLiteral("text/plain")});
51
52 package->addDirectoryDefinition("translations", QStringLiteral("locale"));
53 }
54};
55
56K_PLUGIN_CLASS_WITH_JSON(QmlWallpaperPackage, "plasma-packagestructure-wallpaper.json")
57
58#include "wallpaper.moc"
void setContentsPrefixPaths(const QStringList &prefixPaths)
void setRequired(const QByteArray &key, bool required)
void setMimeTypes(const QByteArray &key, const QStringList &mimeTypes)
void addDirectoryDefinition(const QByteArray &key, const QString &path)
void addFileDefinition(const QByteArray &key, const QString &path)
void setDefaultPackageRoot(const QString &packageRoot)
#define K_PLUGIN_CLASS_WITH_JSON(classname, jsonFile)
KCOREADDONS_EXPORT QStringList runtimePlatform()
void append(QList< T > &&value)
bool isEmpty() const const
Q_OBJECTQ_OBJECT
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:34:35 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.