From 8d5d8daeb310782d5992bd76dae0ad8911dadbec Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Mon, 30 Jul 2007 16:19:07 +0000 Subject: [PATCH] give the configxml object our config object; probably works better that way ;) svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=694408 --- applet.cpp | 42 ++++++++++++++++++++++++++++-------------- applet.h | 9 +++++++++ 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/applet.cpp b/applet.cpp index 350a3c687..a2571265f 100644 --- a/applet.cpp +++ b/applet.cpp @@ -149,7 +149,7 @@ public: QString xmlPath = package->filePath("mainconfigxml"); if (!xmlPath.isEmpty()) { QFile file(xmlPath); - configXml = new ConfigXml(xmlPath, &file); + configXml = new ConfigXml(config(), &file); } if (!package->filePath("mainconfigui").isEmpty()) { @@ -258,6 +258,26 @@ public: 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 // number of members at this point. uint appletId; @@ -309,14 +329,7 @@ Applet::~Applet() KConfigGroup Applet::config() const { - if (!d->appletConfig) { - QString file = KStandardDirs::locateLocal( "appdata", - "applets/" + instanceName() + "rc", - true ); - d->appletConfig = KSharedConfig::openConfig( file ); - } - - return KConfigGroup(d->appletConfig, "General"); + return KConfigGroup(d->config(), "General"); } KConfigGroup Applet::config(const QString& group) const @@ -336,6 +349,11 @@ KConfigGroup Applet::globalConfig() const return KConfigGroup(d->globalConfig, "General"); } +ConfigXml* Applet::configXml() +{ + return d->configXml; +} + DataEngine* Applet::dataEngine(const QString& name) const { int index = d->loadedEngines.indexOf(name); @@ -622,11 +640,7 @@ QString Applet::globalName() const QString Applet::instanceName() const { - if (!d->appletDescription.isValid()) { - return QString(); - } - - return d->appletDescription.service()->library() + QString::number( d->appletId ); + d->instanceName(); } void Applet::watchForFocus(QObject *widget, bool watch) diff --git a/applet.h b/applet.h index 4ba12a719..39864100d 100644 --- a/applet.h +++ b/applet.h @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -119,6 +120,14 @@ class PLASMA_EXPORT Applet : public QObject, public Widget */ 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 *