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:
parent
1b6070d807
commit
44fe05f668
113
applet.cpp
113
applet.cpp
@ -33,6 +33,8 @@
|
||||
|
||||
#include "plasma/corona.h"
|
||||
#include "plasma/dataenginemanager.h"
|
||||
#include "plasma/package.h"
|
||||
#include "plasma/packages_p.h"
|
||||
#include "plasma/plasma.h"
|
||||
#include "plasma/svg.h"
|
||||
|
||||
@ -45,56 +47,75 @@ namespace Plasma
|
||||
|
||||
class Applet::Private
|
||||
{
|
||||
public:
|
||||
Private( KService::Ptr appletDescription, int uniqueID )
|
||||
: appletId( uniqueID ),
|
||||
globalConfig( 0 ),
|
||||
appletConfig( 0 ),
|
||||
appletDescription(appletDescription ? new KPluginInfo(appletDescription) : 0),
|
||||
background(0),
|
||||
failureText(0),
|
||||
immutable(false),
|
||||
hasConfigurationInterface(false),
|
||||
failed(false)
|
||||
{
|
||||
if (appletId == 0) {
|
||||
appletId = nextId();
|
||||
}
|
||||
|
||||
if (appletId > s_maxAppletId) {
|
||||
s_maxAppletId = appletId;
|
||||
}
|
||||
public:
|
||||
Private(KService::Ptr service, int uniqueID)
|
||||
: appletId(uniqueID),
|
||||
globalConfig(0),
|
||||
appletConfig(0),
|
||||
appletDescription(service ? new KPluginInfo(service) : 0),
|
||||
package(0),
|
||||
background(0),
|
||||
failureText(0),
|
||||
immutable(false),
|
||||
hasConfigurationInterface(false),
|
||||
failed(false)
|
||||
{
|
||||
if (appletId == 0) {
|
||||
appletId = nextId();
|
||||
}
|
||||
|
||||
~Private()
|
||||
{
|
||||
foreach ( const QString& engine, loadedEngines ) {
|
||||
DataEngineManager::self()->unloadDataEngine( engine );
|
||||
if (appletId > s_maxAppletId) {
|
||||
s_maxAppletId = appletId;
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
++s_maxAppletId;
|
||||
return s_maxAppletId;
|
||||
~Private()
|
||||
{
|
||||
foreach ( const QString& engine, loadedEngines ) {
|
||||
DataEngineManager::self()->unloadDataEngine( engine );
|
||||
}
|
||||
delete appletDescription;
|
||||
delete background;
|
||||
delete package;
|
||||
}
|
||||
|
||||
//TODO: examine the usage of memory here; there's a pretty large
|
||||
// number of members at this point.
|
||||
uint appletId;
|
||||
KSharedConfig::Ptr globalConfig;
|
||||
KSharedConfig::Ptr appletConfig;
|
||||
KPluginInfo* appletDescription;
|
||||
QList<QObject*> watchedForFocus;
|
||||
QStringList loadedEngines;
|
||||
static uint s_maxAppletId;
|
||||
Plasma::Svg *background;
|
||||
Plasma::LineEdit *failureText;
|
||||
bool immutable : 1;
|
||||
bool hasConfigurationInterface : 1;
|
||||
bool failed : 1;
|
||||
static uint nextId()
|
||||
{
|
||||
++s_maxAppletId;
|
||||
return s_maxAppletId;
|
||||
}
|
||||
|
||||
//TODO: examine the usage of memory here; there's a pretty large
|
||||
// number of members at this point.
|
||||
uint appletId;
|
||||
KSharedConfig::Ptr globalConfig;
|
||||
KSharedConfig::Ptr appletConfig;
|
||||
KPluginInfo* appletDescription;
|
||||
Package* package;
|
||||
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;
|
||||
@ -102,9 +123,9 @@ uint Applet::Private::s_maxAppletId = 0;
|
||||
Applet::Applet(QGraphicsItem *parent,
|
||||
const QString& serviceID,
|
||||
uint appletId)
|
||||
: QObject(0),
|
||||
Widget(parent),
|
||||
d(new Private(KService::serviceByStorageId(serviceID), appletId))
|
||||
: QObject(0),
|
||||
Widget(parent),
|
||||
d(new Private(KService::serviceByStorageId(serviceID), appletId))
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
41
packages.h
41
packages.h
@ -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
|
Loading…
Reference in New Issue
Block a user