From kde-commits Fri Jan 11 18:22:20 2008 From: =?utf-8?q?Aaron=20J=2E=20Seigo?= Date: Fri, 11 Jan 2008 18:22:20 +0000 To: kde-commits Subject: KDE/kdebase/workspace/libs/plasma Message-Id: <1200075740.336360.19547.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=120007575508020 SVN commit 760003 by aseigo: make globalConfig() work properly even for containments BUG:155454 M +20 -5 applet.cpp --- trunk/KDE/kdebase/workspace/libs/plasma/applet.cpp #760002:760003 @@ -507,11 +507,14 @@ KConfigGroup Applet::globalConfig() const { KConfigGroup globalAppletConfig; - if (containment() && containment()->corona()) { - KSharedConfig::Ptr coronaConfig = containment()->corona()->config(); - globalAppletConfig = KConfigGroup(coronaConfig, "AppletGlobals"); + const Containment *c = isContainment() ? dynamic_cast(this) : containment(); + QString group = isContainment() ? "ContainmentGlobals" : "AppletGlobals"; + + if (c && c->corona()) { + KSharedConfig::Ptr coronaConfig = c->corona()->config(); + globalAppletConfig = KConfigGroup(coronaConfig, group); } else { - globalAppletConfig = KConfigGroup(KGlobal::config(), "AppletGlobals"); + globalAppletConfig = KConfigGroup(KGlobal::config(), group); } return KConfigGroup(&globalAppletConfig, globalName()); @@ -935,14 +938,26 @@ Containment* Applet::containment() const { +/* + * while this is probably "more correct", much of the code in applet assumes containment + * returns zero in the case that this is a containment itself. + * if (isContainment()) { + return dynamic_cast(const_cast(this)); + } +*/ + QGraphicsItem *parent = parentItem(); Containment *c = 0; + while (parent) { - if ((c = dynamic_cast(parent))) { + Containment *possibleC = dynamic_cast(parent); + if (possibleC && possibleC->isContainment()) { + c = possibleC; break; } parent = parent->parentItem(); } + return c; }