KPackage

packages.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 "packages_p.h"
8
9#include <math.h>
10
11#include <KLocalizedString>
12
13#include "kpackage/package.h"
14
15void GenericPackage::initPackage(KPackage::Package *package)
16{
18
19 package->setDefaultPackageRoot(QStringLiteral("kpackage/generic/"));
20
21 package->addDirectoryDefinition("images", QStringLiteral("images"));
22 package->addDirectoryDefinition("theme", QStringLiteral("theme"));
23 const QStringList mimetypes{QStringLiteral("image/svg+xml"), QStringLiteral("image/png"), QStringLiteral("image/jpeg")};
24 package->setMimeTypes("images", mimetypes);
25 package->setMimeTypes("theme", mimetypes);
26
27 package->addDirectoryDefinition("config", QStringLiteral("config"));
28 package->setMimeTypes("config", QStringList{QStringLiteral("text/xml")});
29
30 package->addDirectoryDefinition("ui", QStringLiteral("ui"));
31
32 package->addDirectoryDefinition("data", QStringLiteral("data"));
33
34 package->addDirectoryDefinition("scripts", QStringLiteral("code"));
35 package->setMimeTypes("scripts", QStringList{QStringLiteral("text/plain")});
36
37 package->addDirectoryDefinition("translations", QStringLiteral("locale"));
38}
39
40void GenericQMLPackage::initPackage(KPackage::Package *package)
41{
42 GenericPackage::initPackage(package);
43
44 package->addFileDefinition("mainscript", QStringLiteral("ui/main.qml"));
45 package->setRequired("mainscript", true);
46 package->setDefaultPackageRoot(QStringLiteral("kpackage/genericqml/"));
47}
48
49#include "moc_packages_p.cpp"
virtual void initPackage(Package *package)
Called when a the PackageStructure should initialize a Package with the initial structure.
object representing an installed package
Definition package.h:63
void setRequired(const QByteArray &key, bool required)
Sets whether or not a given part of the structure is required or not.
Definition package.cpp:678
void setMimeTypes(const QByteArray &key, const QStringList &mimeTypes)
Define mimeTypes for a given part of the structure The path must already have been added using addDir...
Definition package.cpp:698
void addDirectoryDefinition(const QByteArray &key, const QString &path)
Adds a directory to the structure of the package.
Definition package.cpp:625
void addFileDefinition(const QByteArray &key, const QString &path)
Adds a file to the structure of the package.
Definition package.cpp:645
void setDefaultPackageRoot(const QString &packageRoot)
Sets preferred package root.
Definition package.cpp:133
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:13:38 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.