fix up swapContainment a bit; it doesn't need to take the old containment, as we already know what that is, document with some comments, and make better use of save/restore and addApplet
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=849912
This commit is contained in:
parent
3687d22770
commit
3f7d35a61b
27
view.cpp
27
view.cpp
@ -236,27 +236,38 @@ Containment* View::containment() const
|
||||
return d->containment;
|
||||
}
|
||||
|
||||
Containment* View::swapContainment(Containment* old, const QString& name, const QVariantList& args)
|
||||
Containment* View::swapContainment(const QString& name, const QVariantList& args)
|
||||
{
|
||||
Containment *old = d->containment;
|
||||
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"));
|
||||
}
|
||||
// ensure that the old containments configuration is up to date
|
||||
old->save(containmentConfig);
|
||||
|
||||
// load the configuration of the old containment into the new one
|
||||
c->restore(containmentConfig);
|
||||
|
||||
// move the applets from the old to the new containment
|
||||
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);
|
||||
c->addApplet(applet, applet->pos(), true);
|
||||
}
|
||||
}
|
||||
|
||||
// set our containment
|
||||
setContainment(c);
|
||||
|
||||
// destroy the old one
|
||||
old->destroy();
|
||||
|
||||
// and now save the config
|
||||
containmentConfig = c->config();
|
||||
c->save(containmentConfig);
|
||||
corona->requestConfigSync();
|
||||
|
||||
return c;
|
||||
}
|
||||
return old;
|
||||
|
3
view.h
3
view.h
@ -122,11 +122,10 @@ public:
|
||||
* 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,
|
||||
Containment* swapContainment(const QString& name,
|
||||
const QVariantList& args = QVariantList());
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user