add apluginloader for a custom package structure

probably this package structure goes into libplasma
This commit is contained in:
Marco Martin 2013-03-05 13:34:18 +01:00
parent 90cf52e6c6
commit 4746d9074e
7 changed files with 179 additions and 0 deletions

View File

@ -36,6 +36,8 @@ add_executable(testplasma2
main.cpp
desktopcorona.cpp
panelview.cpp
shellpluginloader.cpp
shellpackage.cpp
view.cpp
)

View File

@ -24,6 +24,7 @@
#include <QDesktopWidget>
#include "panelview.h"
#include "shellpluginloader.h"
#include "view.h"
@ -33,6 +34,9 @@ DesktopCorona::DesktopCorona(QObject *parent)
: Plasma::Corona(parent),
m_desktopWidget(QApplication::desktop())
{
m_pluginLoader = new ShellPluginLoader();
Plasma::PluginLoader::setPluginLoader(m_pluginLoader);
connect(m_desktopWidget, SIGNAL(resized(int)),
this, SLOT(screenResized(int)));
connect(m_desktopWidget, SIGNAL(screenCountChanged(int)),

View File

@ -30,6 +30,7 @@ class View;
namespace Plasma
{
class Applet;
class PluginLoader;
} // namespace Plasma
@ -76,6 +77,7 @@ private:
QDesktopWidget *m_desktopWidget;
QList <View *> m_views;
QHash<Plasma::Containment *, PanelView *> m_panelViews;
Plasma::PluginLoader *m_pluginLoader;
};
#endif

View File

@ -0,0 +1,53 @@
/******************************************************************************
* Copyright 2007-2009 by Aaron Seigo <aseigo@kde.org> *
* *
* This library 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 of the License, or (at your option) any later version. *
* *
* This library 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 *
* Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public License *
* along with this library; see the file COPYING.LIB. If not, write to *
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301, USA. *
*******************************************************************************/
#include "shellpackage.h"
#include <KLocalizedString>
#include <Plasma/Package>
void ShellPackageStructure::initPackage(Plasma::Package *package)
{
package->setDefaultPackageRoot("plasma/shells/");
//Directories
package->addDirectoryDefinition("components", "components", i18n("UI components"));
package->addDirectoryDefinition("views", "views", i18n("User interface for the views that will show containments"));
package->setMimeTypes("components", QStringList() << "text/x-qml");
package->setMimeTypes("views", QStringList() << "text/x-qml");
//Files
package->addFileDefinition("layout", "layout.js", i18n("Default layout file"));
package->addFileDefinition("defaults", "defaults", i18n("Default plugins for containments, containmentActions etc"));
package->setMimeTypes("layout", QStringList() << "application/javascript");
package->setMimeTypes("layout", QStringList() << "text/plain");
package->addFileDefinition("appleterror", "components/AppletError.qml", i18n("Error message shown when an applet fails loading"));
package->addFileDefinition("compactapplet", "components/CompactApplet.qml", i18n("QML component that shows an applet in a popup"));
package->addFileDefinition("defaultcompactrepresentation", "components/DefaultCompactRepresentation.qml", i18n("Compact representation of an applet when collapsed in a popup, for instance as an icon. applets can override this component."));
package->addFileDefinition("widgetexplorer", "components/WidgetExplorer.qml", i18n("Widgets explorer ui"));
//package->setRequired("mainscript", true);
}

36
src/shell/shellpackage.h Normal file
View File

@ -0,0 +1,36 @@
/******************************************************************************
* Copyright 2007 by Aaron Seigo <aseigo@kde.org> *
* Copyright 2013 by Marco Martin <mart@kde.org> *
* *
* This library 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 of the License, or (at your option) any later version. *
* *
* This library 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 *
* Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public License *
* along with this library; see the file COPYING.LIB. If not, write to *
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301, USA. *
*******************************************************************************/
#ifndef SHELLPACKAGE_H
#define SHELLPACKAGE_H
#include <Plasma/PackageStructure>
#include <Plasma/Plasma>
class ShellPackageStructure : public Plasma::PackageStructure
{
public:
void initPackage(Plasma::Package *package);
};
#endif // SHELLPACKAGE_H

View File

@ -0,0 +1,45 @@
/*
* Copyright 2013 Marco Martin <mart@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU 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 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 "shellpluginloader.h"
#include "shellpackage.h"
ShellPluginLoader::ShellPluginLoader()
: Plasma::PluginLoader()
{
}
ShellPluginLoader::~ShellPluginLoader()
{
}
Plasma::Package ShellPluginLoader::internalLoadPackage(const QString &packageFormat, const QString &specialization)
{
Q_UNUSED(specialization)
if (packageFormat.endsWith("/Shell")) {
Plasma::PackageStructure *structure = new ShellPackageStructure();
return Plasma::Package(structure);
} else {
return Plasma::Package();
}
}

View File

@ -0,0 +1,37 @@
/*
* Copyright 2013 Marco Martin <mart@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU 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 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 SHELLPLUGINLOADER_H
#define SHELLPLUGINLOADER_H
#include <Plasma/PluginLoader>
class ShellPluginLoader: public Plasma::PluginLoader
{
public:
ShellPluginLoader();
~ShellPluginLoader();
protected:
Plasma::Package internalLoadPackage(const QString &packageFormat, const QString &specialization);
};
#endif