* save applet config on exit

* introduce Applet::destroy which will perform cleanups, like deleting
  config files, etc..

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=696586
This commit is contained in:
Aaron J. Seigo 2007-08-05 09:39:32 +00:00
parent 21c804908e
commit 0eafb46fc4
3 changed files with 34 additions and 3 deletions

View File

@ -340,6 +340,15 @@ Applet::Applet(QObject* parent, const QStringList& args)
Applet::~Applet()
{
needsFocus( false );
if (d->appletConfig) {
d->appletConfig->sync();
}
if (d->globalConfig) {
d->globalConfig->sync();
}
delete d;
}
@ -365,7 +374,23 @@ KConfigGroup Applet::globalConfig() const
return KConfigGroup(d->globalConfig, "General");
}
ConfigXml* Applet::configXml()
void Applet::destroy()
{
if (d->configXml) {
d->configXml->setDefaults();
}
if (d->appletConfig) {
foreach (const QString& group, d->appletConfig->groupList()) {
d->appletConfig->deleteGroup(group);
}
d->appletConfig = 0;
}
deleteLater();
}
ConfigXml* Applet::configXml() const
{
return d->configXml;
}

View File

@ -128,7 +128,7 @@ class PLASMA_EXPORT Applet : public Widget
*
* @return config skeleton object, or 0 if none
**/
ConfigXml* configXml();
ConfigXml* configXml() const;
/**
* Loads the given DataEngine
@ -476,6 +476,12 @@ class PLASMA_EXPORT Applet : public Widget
**/
void requestFocus( bool focus );
public Q_SLOTS:
/**
* Destroys the applet; it will be deleted and configurations reset.
*/
void destroy();
protected:
/**
* Returns the name of the applet.

View File

@ -94,7 +94,7 @@ public Q_SLOTS:
void setFormFactor(Plasma::FormFactor formFactor);
/**
* Adds an applet to the scene
* Adds an applet to the Corona
*
* @param name the plugin name for the applet, as given by
* KPluginInfo::pluginName()