use an internal package loader

internal kpackage loader used to load Plasma/generic plasma/plasmoid etc
directly from kpackage

Change-Id: Ibd91b0d18b233291978ac667f7bf768a8bdc3c9b
This commit is contained in:
Marco Martin 2015-02-17 18:31:12 +01:00 committed by Sebastian Kügler
parent 47206f89b1
commit bda055367f
4 changed files with 108 additions and 0 deletions

View File

@ -67,6 +67,7 @@ set(Plasma_LIB_SRCS
package.cpp
packagestructure.cpp
private/packages.cpp
private/plasmakpackageloader_p.cpp
#graphics
framesvg.cpp

View File

@ -44,6 +44,7 @@
#include "private/storage_p.h"
#include "private/package_p.h"
#include "private/packagestructure_p.h"
#include "private/plasmakpackageloader_p.h"
namespace Plasma
{
@ -120,6 +121,7 @@ QString PluginLoaderPrivate::parentAppConstraint(const QString &parentApp)
PluginLoader::PluginLoader()
: d(new PluginLoaderPrivate)
{
KPackage::PackageLoader::self()->setPackageLoader(new Plasma::KPackageLoader);
}
PluginLoader::~PluginLoader()

View File

@ -0,0 +1,62 @@
/*
* Copyright 2015 Marco Martin <mart@kde.org>
*
* This program 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, or
* (at your option) any later version.
*
* This program 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 General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "plasmakpackageloader_p.h"
#include "packages_p.h"
namespace Plasma
{
KPackageLoader::KPackageLoader()
: KPackage::PackageLoader()
{
}
KPackageLoader::~KPackageLoader()
{
}
KPackage::Package KPackageLoader::internalLoadPackage(const QString &packageFormat)
{
KPackage::PackageStructure *structure = 0;
if (packageFormat.startsWith("Plasma")) {
if (packageFormat.endsWith("/Applet")) {
structure = new PlasmoidPackage();
} else if (packageFormat.endsWith("/DataEngine")) {
structure = new DataEnginePackage();
} else if (packageFormat.endsWith("/Theme")) {
structure = new ThemePackage();
} else if (packageFormat.endsWith("/ContainmentActions")) {
structure = new ContainmentActionsPackage();
} else if (packageFormat.endsWith("/Generic")) {
structure = new GenericPackage();
}
if (structure) {
return KPackage::Package(structure);
}
}
return KPackage::Package();
}
}

View File

@ -0,0 +1,43 @@
/*
* Copyright 2015 Marco Martin <mart@kde.org>
*
* This program 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, or
* (at your option) any later version.
*
* This program 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 General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef PLASMA_PACKAGELOADER_P_H
#define PLASMA_PACKAGELOADER_P_H
#include <kpackage/package.h>
#include <kpackage/packageloader.h>
namespace Plasma
{
class KPackageLoader : public KPackage::PackageLoader
{
public:
KPackageLoader();
~KPackageLoader();
protected:
KPackage::Package internalLoadPackage(const QString &packageFormat);
};
}
#endif