add the concept of immutable to applets

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=678565
This commit is contained in:
Aaron J. Seigo 2007-06-21 18:24:05 +00:00
parent 5f8c6be988
commit c2815e1f84
2 changed files with 39 additions and 5 deletions

View File

@ -42,7 +42,8 @@ class Applet::Private
: appletId( uniqueID ),
globalConfig( 0 ),
appletConfig( 0 ),
appletDescription(new KPluginInfo(appletDescription))
appletDescription(new KPluginInfo(appletDescription)),
immutable(false)
{
if (appletId > s_maxAppletId) {
s_maxAppletId = appletId;
@ -70,6 +71,7 @@ class Applet::Private
QList<QObject*> watchedForFocus;
QStringList loadedEngines;
static uint s_maxAppletId;
bool immutable;
};
uint Applet::Private::s_maxAppletId = 0;
@ -81,6 +83,7 @@ Applet::Applet(QGraphicsItem *parent,
QGraphicsItem(parent),
d(new Private(KService::serviceByStorageId(serviceID), appletId))
{
init();
}
Applet::Applet(QObject* parent, const QStringList& args)
@ -88,6 +91,7 @@ Applet::Applet(QObject* parent, const QStringList& args)
QGraphicsItem(0),
d(new Private(KService::serviceByStorageId(args[0]), args[1].toInt()))
{
init();
// the brain damage seen in the initialization list is due to the
// inflexibility of KService::createInstance
}
@ -98,6 +102,12 @@ Applet::~Applet()
delete d;
}
void Applet::init()
{
setImmutable(globalAppletConfig().isImmutable() ||
appletConfig().isImmutable());
}
KConfigGroup Applet::appletConfig() const
{
if ( !d->appletConfig ) {
@ -141,11 +151,21 @@ void Applet::constraintsUpdated()
kDebug() << "Applet::constraintsUpdate(): constraints are FormFactor: " << formFactor() << ", Location: " << location() << endl;
}
QString Applet::name()
QString Applet::name() const
{
return d->appletDescription->name();
}
bool Applet::immutable() const
{
return d->immutable;
}
void Applet::setImmutable(bool immutable)
{
d->immutable = immutable;
}
void Applet::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(painter)

View File

@ -174,7 +174,19 @@ class PLASMA_EXPORT Applet : public QObject, public QGraphicsItem
* .desktop file.
* @return the user-visible name for the applet.
**/
QString name();
QString name() const;
/**
* @return true if this applet is immutable
**/
bool immutable() const;
/**
* Sets whether or not this applet is immutable or not
*
* @arg immutable true if this applet should not be changable
**/
void setImmutable(bool immutable);
/**
* Reimplemented from QGraphicsItem
@ -238,6 +250,8 @@ class PLASMA_EXPORT Applet : public QObject, public QGraphicsItem
bool eventFilter( QObject *o, QEvent *e );
private:
void init();
class Private;
Private* const d;
};