Add swapContainment function

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=849802
This commit is contained in:
Petri Damstén 2008-08-20 08:07:09 +00:00
parent 0a2eb79e61
commit bacc1d65d4
2 changed files with 38 additions and 0 deletions

View File

@ -25,6 +25,7 @@
#include "corona.h"
#include "containment.h"
#include "wallpaper.h"
using namespace Plasma;
@ -235,6 +236,32 @@ Containment* View::containment() const
return d->containment;
}
Containment* View::swapContainment(Containment* old, const QString& name, const QVariantList& args)
{
Plasma::Corona* corona = old->corona();
KConfigGroup containmentConfig = old->config();
Plasma::Containment *c = corona->addContainment(name, args);
if (c) {
KConfigGroup cfg = c->config();
if (old->wallpaper()) {
old->wallpaper()->save(KConfigGroup(&cfg, "Wallpaper"));
}
c->restore(containmentConfig);
foreach (QGraphicsItem* item, old->childItems()) {
Plasma::Applet* applet = dynamic_cast<Plasma::Applet*>(item);
if (applet) {
QRectF geom = applet->geometry();
item->setParentItem(c);
applet->setGeometry(geom);
}
}
setContainment(c);
old->destroy();
return c;
}
return old;
}
KConfigGroup View::config() const
{
KConfigGroup views(KGlobal::config(), "PlasmaViews");

11
view.h
View File

@ -118,6 +118,17 @@ public:
*/
Containment* containment() const;
/**
* Swap the containment for this view, which will also cause the view
* to track the geometry of the containment.
*
* @param old Pointer to old containment
* @param name the plugin name for the new containment.
* @param args argument list to pass to the containment
*/
Containment* swapContainment(Containment* old, const QString& name,
const QVariantList& args = QVariantList());
/**
* Set whether or not the view should adjust its size when the associated
* containment does.