From 4746d9074e0f51354c6c272d569e12d376863a52 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Tue, 5 Mar 2013 13:34:18 +0100 Subject: [PATCH] add apluginloader for a custom package structure probably this package structure goes into libplasma --- src/shell/CMakeLists.txt | 2 ++ src/shell/desktopcorona.cpp | 4 +++ src/shell/desktopcorona.h | 2 ++ src/shell/shellpackage.cpp | 53 +++++++++++++++++++++++++++++++++ src/shell/shellpackage.h | 36 ++++++++++++++++++++++ src/shell/shellpluginloader.cpp | 45 ++++++++++++++++++++++++++++ src/shell/shellpluginloader.h | 37 +++++++++++++++++++++++ 7 files changed, 179 insertions(+) create mode 100644 src/shell/shellpackage.cpp create mode 100644 src/shell/shellpackage.h create mode 100644 src/shell/shellpluginloader.cpp create mode 100644 src/shell/shellpluginloader.h diff --git a/src/shell/CMakeLists.txt b/src/shell/CMakeLists.txt index ee2c2c971..a6f98006d 100644 --- a/src/shell/CMakeLists.txt +++ b/src/shell/CMakeLists.txt @@ -36,6 +36,8 @@ add_executable(testplasma2 main.cpp desktopcorona.cpp panelview.cpp + shellpluginloader.cpp + shellpackage.cpp view.cpp ) diff --git a/src/shell/desktopcorona.cpp b/src/shell/desktopcorona.cpp index 8882c4945..da305020b 100644 --- a/src/shell/desktopcorona.cpp +++ b/src/shell/desktopcorona.cpp @@ -24,6 +24,7 @@ #include #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)), diff --git a/src/shell/desktopcorona.h b/src/shell/desktopcorona.h index 983a63a9f..627493ce4 100644 --- a/src/shell/desktopcorona.h +++ b/src/shell/desktopcorona.h @@ -30,6 +30,7 @@ class View; namespace Plasma { class Applet; + class PluginLoader; } // namespace Plasma @@ -76,6 +77,7 @@ private: QDesktopWidget *m_desktopWidget; QList m_views; QHash m_panelViews; + Plasma::PluginLoader *m_pluginLoader; }; #endif diff --git a/src/shell/shellpackage.cpp b/src/shell/shellpackage.cpp new file mode 100644 index 000000000..103798d11 --- /dev/null +++ b/src/shell/shellpackage.cpp @@ -0,0 +1,53 @@ +/****************************************************************************** +* Copyright 2007-2009 by Aaron Seigo * +* * +* 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 + +#include + + +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); +} + + diff --git a/src/shell/shellpackage.h b/src/shell/shellpackage.h new file mode 100644 index 000000000..99dc46057 --- /dev/null +++ b/src/shell/shellpackage.h @@ -0,0 +1,36 @@ +/****************************************************************************** +* Copyright 2007 by Aaron Seigo * +* Copyright 2013 by Marco Martin * +* * +* 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 +#include + + + +class ShellPackageStructure : public Plasma::PackageStructure +{ +public: + void initPackage(Plasma::Package *package); +}; + + +#endif // SHELLPACKAGE_H diff --git a/src/shell/shellpluginloader.cpp b/src/shell/shellpluginloader.cpp new file mode 100644 index 000000000..a25ed19a3 --- /dev/null +++ b/src/shell/shellpluginloader.cpp @@ -0,0 +1,45 @@ +/* + * Copyright 2013 Marco Martin + * + * 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(); + } +} diff --git a/src/shell/shellpluginloader.h b/src/shell/shellpluginloader.h new file mode 100644 index 000000000..7a47905f2 --- /dev/null +++ b/src/shell/shellpluginloader.h @@ -0,0 +1,37 @@ +/* + * Copyright 2013 Marco Martin + * + * 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 + + +class ShellPluginLoader: public Plasma::PluginLoader +{ +public: + ShellPluginLoader(); + ~ShellPluginLoader(); + +protected: + Plasma::Package internalLoadPackage(const QString &packageFormat, const QString &specialization); + +}; + +#endif