diff --git a/applet.cpp b/applet.cpp index 386911270..a2fe6cc9c 100644 --- a/applet.cpp +++ b/applet.cpp @@ -45,6 +45,7 @@ class Applet::Private appletConfig( 0 ), appletDescription(new KPluginInfo(appletDescription)), immutable(false), + hasConfigurationInterface(false), background(0) { if (appletId > s_maxAppletId) { @@ -75,6 +76,7 @@ class Applet::Private QStringList loadedEngines; static uint s_maxAppletId; bool immutable; + bool hasConfigurationInterface; Plasma::Svg *background; }; @@ -269,6 +271,16 @@ void Applet::needsFocus(bool focus) emit requestFocus(focus); } +bool Applet::hasConfigurationInterface() +{ + return d->hasConfigurationInterface; +} + +void Applet::setHasConfigurationInterface(bool hasInterface) +{ + d->hasConfigurationInterface = hasInterface; +} + bool Applet::eventFilter( QObject *o, QEvent * e ) { if ( !d->watchedForFocus.contains( o ) ) @@ -284,6 +296,10 @@ bool Applet::eventFilter( QObject *o, QEvent * e ) return QObject::eventFilter(o, e); } +void Applet::configureDialog() +{ +} + KPluginInfo::List Applet::knownApplets() { QHash applets; diff --git a/applet.h b/applet.h index f06e19c51..2d8424202 100644 --- a/applet.h +++ b/applet.h @@ -135,12 +135,17 @@ class PLASMA_EXPORT Applet : public QObject, public QGraphicsItem **/ static KPluginInfo::List knownApplets(); + /** + * @return true if this plasmoid provides a GUI configuration + **/ + bool hasConfigurationInterface(); + /** * Reimplement this slot to show a configuration dialog and let the user * play with the plasmoid options. Called when the user selects the configure entry - * from the contextual menu. + * from the context menu. */ - virtual void configureDialog(){} //default implementation is empty + virtual void configureDialog(); /** * Attempts to load an applet, returning a pointer to the applet if @@ -259,6 +264,15 @@ class PLASMA_EXPORT Applet : public QObject, public QGraphicsItem */ void needsFocus(bool focus); + /** + * Sets whether or not this applet provides a user interface for configuring + * the applet. It defaults to false, and if true is passed in you should + * also reimplement configureDialog() + * + * @arg hasInterface whether or not there is a user interface available + **/ + void setHasConfigurationInterface(bool hasInterface); + /** * @internal event filter; used for focus watching **/ diff --git a/corona.cpp b/corona.cpp index fe860badc..8d4db2e82 100644 --- a/corona.cpp +++ b/corona.cpp @@ -313,17 +313,26 @@ void Corona::contextMenuEvent(QGraphicsSceneContextMenuEvent *contextMenuEvent) } else if (applet->immutable()) { return; } else { - desktopMenu.addSeparator(); - - QAction* configureApplet = new QAction(i18n("Settings..."), this); + //desktopMenu.addSeparator(); + bool hasEntries = false; + if (applet->hasConfigurationInterface()) { + QAction* configureApplet = new QAction(i18n("%1 Settings...", applet->name()), this); connect(configureApplet, SIGNAL(triggered(bool)), - applet, SLOT(configureDialog())); //This isn't implemented in Applet yet... + applet, SLOT(configureDialog())); desktopMenu.addAction(configureApplet); + hasEntries = true; + } + if (!d->immutable) { - QAction* closeApplet = new QAction(i18n("Close"), this); + QAction* closeApplet = new QAction(i18n("Close this %1", applet->name()), this); connect(closeApplet, SIGNAL(triggered(bool)), applet, SLOT(deleteLater())); desktopMenu.addAction(closeApplet); + hasEntries = true; + } + + if (!hasEntries) { + return; } } desktopMenu.exec(point.toPoint());