Add swapContainment function
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=849802
This commit is contained in:
parent
0a2eb79e61
commit
bacc1d65d4
27
view.cpp
27
view.cpp
@ -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
11
view.h
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user