give the configxml object our config object; probably works better that way ;)

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=694408
This commit is contained in:
Aaron J. Seigo 2007-07-30 16:19:07 +00:00
parent b1fafa0edc
commit 8d5d8daeb3
2 changed files with 37 additions and 14 deletions

View File

@ -149,7 +149,7 @@ public:
QString xmlPath = package->filePath("mainconfigxml"); QString xmlPath = package->filePath("mainconfigxml");
if (!xmlPath.isEmpty()) { if (!xmlPath.isEmpty()) {
QFile file(xmlPath); QFile file(xmlPath);
configXml = new ConfigXml(xmlPath, &file); configXml = new ConfigXml(config(), &file);
} }
if (!package->filePath("mainconfigui").isEmpty()) { if (!package->filePath("mainconfigui").isEmpty()) {
@ -258,6 +258,26 @@ public:
return s_maxAppletId; return s_maxAppletId;
} }
KSharedConfig::Ptr config() {
if (!appletConfig) {
QString file = KStandardDirs::locateLocal("appdata",
"applets/" + instanceName() + "rc",
true);
appletConfig = KSharedConfig::openConfig(file);
}
return appletConfig;
}
QString instanceName()
{
if (!appletDescription.isValid()) {
return QString();
}
return appletDescription.service()->library() + QString::number(appletId);
}
//TODO: examine the usage of memory here; there's a pretty large //TODO: examine the usage of memory here; there's a pretty large
// number of members at this point. // number of members at this point.
uint appletId; uint appletId;
@ -309,14 +329,7 @@ Applet::~Applet()
KConfigGroup Applet::config() const KConfigGroup Applet::config() const
{ {
if (!d->appletConfig) { return KConfigGroup(d->config(), "General");
QString file = KStandardDirs::locateLocal( "appdata",
"applets/" + instanceName() + "rc",
true );
d->appletConfig = KSharedConfig::openConfig( file );
}
return KConfigGroup(d->appletConfig, "General");
} }
KConfigGroup Applet::config(const QString& group) const KConfigGroup Applet::config(const QString& group) const
@ -336,6 +349,11 @@ KConfigGroup Applet::globalConfig() const
return KConfigGroup(d->globalConfig, "General"); return KConfigGroup(d->globalConfig, "General");
} }
ConfigXml* Applet::configXml()
{
return d->configXml;
}
DataEngine* Applet::dataEngine(const QString& name) const DataEngine* Applet::dataEngine(const QString& name) const
{ {
int index = d->loadedEngines.indexOf(name); int index = d->loadedEngines.indexOf(name);
@ -622,11 +640,7 @@ QString Applet::globalName() const
QString Applet::instanceName() const QString Applet::instanceName() const
{ {
if (!d->appletDescription.isValid()) { d->instanceName();
return QString();
}
return d->appletDescription.service()->library() + QString::number( d->appletId );
} }
void Applet::watchForFocus(QObject *widget, bool watch) void Applet::watchForFocus(QObject *widget, bool watch)

View File

@ -26,6 +26,7 @@
#include <ksharedconfig.h> #include <ksharedconfig.h>
#include <kgenericfactory.h> #include <kgenericfactory.h>
#include <plasma/configxml.h>
#include <plasma/plasma.h> #include <plasma/plasma.h>
#include <plasma/widgets/widget.h> #include <plasma/widgets/widget.h>
@ -119,6 +120,14 @@ class PLASMA_EXPORT Applet : public QObject, public Widget
*/ */
KConfigGroup globalConfig() const; KConfigGroup globalConfig() const;
/**
* Returns the config skeleton object from this applet's package,
* if any.
*
* @return config skeleton object, or 0 if none
**/
ConfigXml* configXml();
/** /**
* Loads the given DataEngine * Loads the given DataEngine
* *