create a Package if we have a scripted plasmoid on hand.

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=690104
This commit is contained in:
Aaron J. Seigo 2007-07-20 03:28:34 +00:00
parent 1b6070d807
commit 44fe05f668
2 changed files with 67 additions and 87 deletions

View File

@ -33,6 +33,8 @@
#include "plasma/corona.h" #include "plasma/corona.h"
#include "plasma/dataenginemanager.h" #include "plasma/dataenginemanager.h"
#include "plasma/package.h"
#include "plasma/packages_p.h"
#include "plasma/plasma.h" #include "plasma/plasma.h"
#include "plasma/svg.h" #include "plasma/svg.h"
@ -45,56 +47,75 @@ namespace Plasma
class Applet::Private class Applet::Private
{ {
public: public:
Private( KService::Ptr appletDescription, int uniqueID ) Private(KService::Ptr service, int uniqueID)
: appletId( uniqueID ), : appletId(uniqueID),
globalConfig( 0 ), globalConfig(0),
appletConfig( 0 ), appletConfig(0),
appletDescription(appletDescription ? new KPluginInfo(appletDescription) : 0), appletDescription(service ? new KPluginInfo(service) : 0),
background(0), package(0),
failureText(0), background(0),
immutable(false), failureText(0),
hasConfigurationInterface(false), immutable(false),
failed(false) hasConfigurationInterface(false),
{ failed(false)
if (appletId == 0) { {
appletId = nextId(); if (appletId == 0) {
} appletId = nextId();
if (appletId > s_maxAppletId) {
s_maxAppletId = appletId;
}
} }
~Private() if (appletId > s_maxAppletId) {
{ s_maxAppletId = appletId;
foreach ( const QString& engine, loadedEngines ) { }
DataEngineManager::self()->unloadDataEngine( engine );
if (appletDescription &&
!appletDescription->property("X-Plasma-Language").toString().isEmpty()) {
QString path = KStandardDirs::locate("appdata",
"plasmoids/" +
appletDescription->pluginName());
if (!path.isEmpty()) {
package = new Package(path,
appletDescription->pluginName(),
PlasmoidStructure());
if (!package->isValid()) {
delete package;
package = 0;
}
} }
delete appletDescription;
delete background;
} }
}
static uint nextId() ~Private()
{ {
++s_maxAppletId; foreach ( const QString& engine, loadedEngines ) {
return s_maxAppletId; DataEngineManager::self()->unloadDataEngine( engine );
} }
delete appletDescription;
delete background;
delete package;
}
//TODO: examine the usage of memory here; there's a pretty large static uint nextId()
// number of members at this point. {
uint appletId; ++s_maxAppletId;
KSharedConfig::Ptr globalConfig; return s_maxAppletId;
KSharedConfig::Ptr appletConfig; }
KPluginInfo* appletDescription;
QList<QObject*> watchedForFocus; //TODO: examine the usage of memory here; there's a pretty large
QStringList loadedEngines; // number of members at this point.
static uint s_maxAppletId; uint appletId;
Plasma::Svg *background; KSharedConfig::Ptr globalConfig;
Plasma::LineEdit *failureText; KSharedConfig::Ptr appletConfig;
bool immutable : 1; KPluginInfo* appletDescription;
bool hasConfigurationInterface : 1; Package* package;
bool failed : 1; QList<QObject*> watchedForFocus;
QStringList loadedEngines;
static uint s_maxAppletId;
Plasma::Svg *background;
Plasma::LineEdit *failureText;
bool immutable : 1;
bool hasConfigurationInterface : 1;
bool failed : 1;
}; };
uint Applet::Private::s_maxAppletId = 0; uint Applet::Private::s_maxAppletId = 0;
@ -102,9 +123,9 @@ uint Applet::Private::s_maxAppletId = 0;
Applet::Applet(QGraphicsItem *parent, Applet::Applet(QGraphicsItem *parent,
const QString& serviceID, const QString& serviceID,
uint appletId) uint appletId)
: QObject(0), : QObject(0),
Widget(parent), Widget(parent),
d(new Private(KService::serviceByStorageId(serviceID), appletId)) d(new Private(KService::serviceByStorageId(serviceID), appletId))
{ {
init(); init();
} }

View File

@ -1,41 +0,0 @@
/******************************************************************************
* Copyright (C) 2007 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. *
*******************************************************************************/
#ifndef PLASMA_PACKAGES
#define PLASMA_PACKAGES
#include <plasma/packagestructure.h>
namespace Plasma
{
class PlasmoidStructure : public PackageStructure
{
public:
PlasmoidStructure();
};
class ThemePackageStructure : public PackageStructure
{
public:
ThemePackageStructure();
};
} // namespace Plasma
#endif