make the type property writable (no wonder it wasn't documented on techbase!)
This commit is contained in:
parent
5362e4e3b6
commit
ffeb10641b
@ -277,6 +277,48 @@ QString Containment::type() const
|
||||
return d->containment.data()->pluginName();
|
||||
}
|
||||
|
||||
void Containment::setType(const QString &type)
|
||||
{
|
||||
if (!d->containment || d->containment.data()->pluginName() == type || type.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Plasma::Containment *old = d->containment.data();
|
||||
Plasma::Corona *corona = old->corona();
|
||||
Plasma::Containment *c = corona->addContainmentDelayed(type);
|
||||
if (c) {
|
||||
c->init();
|
||||
|
||||
KConfigGroup oldConfig = old->config();
|
||||
KConfigGroup newConfig = c->config();
|
||||
|
||||
// ensure that the old containments configuration is up to date
|
||||
old->save(oldConfig);
|
||||
|
||||
// Copy configuration to new containment
|
||||
oldConfig.copyTo(&newConfig);
|
||||
|
||||
// load the configuration of the old containment into the new one
|
||||
c->restore(newConfig);
|
||||
c->updateConstraints(Plasma::StartupCompletedConstraint);
|
||||
c->flushPendingConstraintsEvents();
|
||||
foreach (Plasma::Applet *applet, c->applets()) {
|
||||
applet->init();
|
||||
// We have to flush the applet constraints manually
|
||||
applet->flushPendingConstraintsEvents();
|
||||
}
|
||||
|
||||
// destroy the old one
|
||||
old->destroy(false);
|
||||
|
||||
// and now save the config
|
||||
c->save(newConfig);
|
||||
corona->requestConfigSync();
|
||||
|
||||
d->containment = c;
|
||||
}
|
||||
}
|
||||
|
||||
void Containment::remove()
|
||||
{
|
||||
if (d->containment) {
|
||||
|
@ -49,7 +49,7 @@ class PLASMAGENERICSHELL_EXPORT Containment : public Applet
|
||||
Q_PROPERTY(QString wallpaperPlugin READ wallpaperPlugin WRITE setWallpaperPlugin)
|
||||
Q_PROPERTY(QString wallpaperMode READ wallpaperMode WRITE setWallpaperMode)
|
||||
Q_PROPERTY(bool locked READ locked WRITE setLocked)
|
||||
Q_PROPERTY(QString type READ type)
|
||||
Q_PROPERTY(QString type READ type WRITE setType)
|
||||
Q_PROPERTY(QString formFactor READ formFactor)
|
||||
Q_PROPERTY(QList<int> widgetIds READ widgetIds)
|
||||
Q_PROPERTY(int screen READ screen WRITE setScreen)
|
||||
@ -62,6 +62,7 @@ public:
|
||||
|
||||
uint id() const;
|
||||
QString type() const;
|
||||
void setType(const QString &type);
|
||||
QString formFactor() const;
|
||||
QList<int> widgetIds() const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user