BIC Monday: slight change in the way we handle saving/loading of applets. it no longer sets the internal config name. makes importing/exporting snippets of applets easier, and it also prevents plasmoidviewer from clobbering plasma settings

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=773847
This commit is contained in:
Aaron J. Seigo 2008-02-11 21:43:09 +00:00
parent 22c8b77b34
commit 899202d2fb
2 changed files with 29 additions and 35 deletions

View File

@ -28,6 +28,7 @@
#include <QTimer>
#include <KDebug>
#include <KGlobal>
#include <KLocale>
#include <KMimeType>
#include <KWindowSystem>
@ -54,9 +55,13 @@ public:
: immutable(false),
kioskImmutable(false),
mimetype("text/x-plasmoidservicename"),
configName("plasma-appletsrc"),
config(0)
{
if (KGlobal::hasMainComponent()) {
configName = KGlobal::mainComponent().componentName() + "-appletsrc";
} else {
configName = "plasma-appletsrc";
}
}
~Private()
@ -156,16 +161,17 @@ QString Corona::appletMimeType()
return d->mimetype;
}
void Corona::saveApplets(const QString &config) const
void Corona::saveApplets(const QString &configName) const
{
KSharedConfigPtr cg = KSharedConfig::openConfig(config);
d->saveApplets(cg);
}
KSharedConfigPtr c;
void Corona::saveApplets() const
{
d->saveApplets(config());
scheduleConfigSync();
if (configName.isEmpty() || configName == d->configName) {
c = config();
} else {
c = KSharedConfig::openConfig(configName);
}
d->saveApplets(c);
}
void Corona::scheduleConfigSync() const
@ -193,9 +199,12 @@ bool appletConfigLessThan(const KConfigGroup &c1, const KConfigGroup &c2)
void Corona::loadApplets(const QString& configName)
{
clearApplets();
if (configName != d->configName) {
d->configName = configName;
d->config = 0;
KSharedConfigPtr c;
if (configName.isEmpty() || configName == d->configName) {
c = config();
} else {
c = KSharedConfig::openConfig(configName);
}
KConfigGroup containments(config(), "Containments");
@ -288,11 +297,6 @@ void Corona::loadApplets(const QString& configName)
setImmutable(coronaConfig.readEntry("locked", false));
}
void Corona::loadApplets()
{
loadApplets(d->configName);
}
void Corona::loadDefaultSetup()
{
//FIXME: implement support for system-wide defaults

View File

@ -74,20 +74,6 @@ public:
*/
QString appletMimeType();
/**
* Save applets to a config file
*
* @param config the name of the config file to save to
*/
void saveApplets(const QString &config) const;
/**
* Load applet layout from a config file
*
* @param config the name of the config file to load from
*/
void loadApplets(const QString &config);
/**
* Loads the default (system wide) layout for this user
**/
@ -105,14 +91,18 @@ public:
public Q_SLOTS:
/**
* Load applets from the default config file
* Load applet layout from a config file
*
* @param config the name of the config file to load from,
* or the default config file if QString()
*/
void loadApplets();
void loadApplets(const QString &config = QString());
/**
* Save applets to the default config file
* Save applets to file
* @arg config the file to save to, or the default config file if QString()
*/
void saveApplets() const;
void saveApplets(const QString &config = QString()) const;
/**
* Called when there have been changes made to configuration that should be saved