allow swapping of arbitrary containments, not just this view's containment
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=872751
This commit is contained in:
parent
2f501ace5e
commit
333b91acfb
18
view.cpp
18
view.cpp
@ -253,7 +253,16 @@ Containment *View::containment() const
|
||||
|
||||
Containment *View::swapContainment(const QString &name, const QVariantList &args)
|
||||
{
|
||||
Containment *old = d->containment;
|
||||
return swapContainment(d->containment, name, args);
|
||||
}
|
||||
|
||||
Containment *View::swapContainment(Plasma::Containment *existing, const QString &name, const QVariantList &args)
|
||||
{
|
||||
if (!existing) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Containment *old = existing;
|
||||
Plasma::Corona *corona = old->corona();
|
||||
Plasma::Containment *c = corona->addContainment(name, args);
|
||||
if (c) {
|
||||
@ -263,8 +272,10 @@ Containment *View::swapContainment(const QString &name, const QVariantList &args
|
||||
// ensure that the old containments configuration is up to date
|
||||
old->save(oldConfig);
|
||||
|
||||
// set our containment to the new one
|
||||
setContainment(c);
|
||||
if (old == d->containment) {
|
||||
// set our containment to the new one
|
||||
setContainment(c);
|
||||
}
|
||||
|
||||
// Copy configuration to new containment
|
||||
oldConfig.copyTo(&newConfig);
|
||||
@ -286,6 +297,7 @@ Containment *View::swapContainment(const QString &name, const QVariantList &args
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
return old;
|
||||
}
|
||||
|
||||
|
11
view.h
11
view.h
@ -121,6 +121,17 @@ public:
|
||||
*/
|
||||
Containment *containment() const;
|
||||
|
||||
/**
|
||||
* Swaps one containment with another.
|
||||
*
|
||||
* @param existing the existing containment to swap out
|
||||
* @param name the plugin name for the new containment.
|
||||
* @param args argument list to pass to the containment
|
||||
*/
|
||||
Containment *swapContainment(Plasma::Containment *existing,
|
||||
const QString &name,
|
||||
const QVariantList &args = QVariantList());
|
||||
|
||||
/**
|
||||
* Swap the containment for this view, which will also cause the view
|
||||
* to track the geometry of the containment.
|
||||
|
Loading…
Reference in New Issue
Block a user