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:
parent
22c8b77b34
commit
899202d2fb
36
corona.cpp
36
corona.cpp
@ -28,6 +28,7 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
#include <KDebug>
|
#include <KDebug>
|
||||||
|
#include <KGlobal>
|
||||||
#include <KLocale>
|
#include <KLocale>
|
||||||
#include <KMimeType>
|
#include <KMimeType>
|
||||||
#include <KWindowSystem>
|
#include <KWindowSystem>
|
||||||
@ -54,9 +55,13 @@ public:
|
|||||||
: immutable(false),
|
: immutable(false),
|
||||||
kioskImmutable(false),
|
kioskImmutable(false),
|
||||||
mimetype("text/x-plasmoidservicename"),
|
mimetype("text/x-plasmoidservicename"),
|
||||||
configName("plasma-appletsrc"),
|
|
||||||
config(0)
|
config(0)
|
||||||
{
|
{
|
||||||
|
if (KGlobal::hasMainComponent()) {
|
||||||
|
configName = KGlobal::mainComponent().componentName() + "-appletsrc";
|
||||||
|
} else {
|
||||||
|
configName = "plasma-appletsrc";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~Private()
|
~Private()
|
||||||
@ -156,16 +161,17 @@ QString Corona::appletMimeType()
|
|||||||
return d->mimetype;
|
return d->mimetype;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Corona::saveApplets(const QString &config) const
|
void Corona::saveApplets(const QString &configName) const
|
||||||
{
|
{
|
||||||
KSharedConfigPtr cg = KSharedConfig::openConfig(config);
|
KSharedConfigPtr c;
|
||||||
d->saveApplets(cg);
|
|
||||||
|
if (configName.isEmpty() || configName == d->configName) {
|
||||||
|
c = config();
|
||||||
|
} else {
|
||||||
|
c = KSharedConfig::openConfig(configName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Corona::saveApplets() const
|
d->saveApplets(c);
|
||||||
{
|
|
||||||
d->saveApplets(config());
|
|
||||||
scheduleConfigSync();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Corona::scheduleConfigSync() const
|
void Corona::scheduleConfigSync() const
|
||||||
@ -193,9 +199,12 @@ bool appletConfigLessThan(const KConfigGroup &c1, const KConfigGroup &c2)
|
|||||||
void Corona::loadApplets(const QString& configName)
|
void Corona::loadApplets(const QString& configName)
|
||||||
{
|
{
|
||||||
clearApplets();
|
clearApplets();
|
||||||
if (configName != d->configName) {
|
KSharedConfigPtr c;
|
||||||
d->configName = configName;
|
|
||||||
d->config = 0;
|
if (configName.isEmpty() || configName == d->configName) {
|
||||||
|
c = config();
|
||||||
|
} else {
|
||||||
|
c = KSharedConfig::openConfig(configName);
|
||||||
}
|
}
|
||||||
|
|
||||||
KConfigGroup containments(config(), "Containments");
|
KConfigGroup containments(config(), "Containments");
|
||||||
@ -288,11 +297,6 @@ void Corona::loadApplets(const QString& configName)
|
|||||||
setImmutable(coronaConfig.readEntry("locked", false));
|
setImmutable(coronaConfig.readEntry("locked", false));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Corona::loadApplets()
|
|
||||||
{
|
|
||||||
loadApplets(d->configName);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Corona::loadDefaultSetup()
|
void Corona::loadDefaultSetup()
|
||||||
{
|
{
|
||||||
//FIXME: implement support for system-wide defaults
|
//FIXME: implement support for system-wide defaults
|
||||||
|
26
corona.h
26
corona.h
@ -74,20 +74,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
QString appletMimeType();
|
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
|
* Loads the default (system wide) layout for this user
|
||||||
**/
|
**/
|
||||||
@ -105,14 +91,18 @@ public:
|
|||||||
|
|
||||||
public Q_SLOTS:
|
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
|
* Called when there have been changes made to configuration that should be saved
|
||||||
|
Loading…
x
Reference in New Issue
Block a user