diff --git a/applet.cpp b/applet.cpp index dffbfb1f2..178483e20 100644 --- a/applet.cpp +++ b/applet.cpp @@ -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 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) @@ -199,7 +219,7 @@ void Applet::watchForFocus(QObject *widget, bool watch) } } -void Applet::needsFocus( bool focus ) +void Applet::needsFocus(bool focus) { if (focus == QGraphicsItem::hasFocus()) { return; diff --git a/applet.h b/applet.h index bd5bd0eee..3097e3d64 100644 --- a/applet.h +++ b/applet.h @@ -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 @@ -230,7 +242,7 @@ class PLASMA_EXPORT Applet : public QObject, public QGraphicsItem * @see watchForFocus * @param focus whether to or not to request focus */ - void needsFocus( bool focus ); + void needsFocus(bool focus); /** * @internal event filter; used for focus watching @@ -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; };