* add Corona::addContainmentDelayed for more control on the Corona subclass side during default layout loading
* accept bad config objectsin Applet::save and Containment::save * move some initialization code around to be more robust with external use (will make more sense in next commit to workspace/plasma/plasma) svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=828940
This commit is contained in:
parent
31c7b8d064
commit
0e5f15dc50
@ -148,8 +148,13 @@ uint Applet::id() const
|
||||
return d->appletId;
|
||||
}
|
||||
|
||||
void Applet::save(KConfigGroup &group) const
|
||||
void Applet::save(KConfigGroup &g) const
|
||||
{
|
||||
KConfigGroup group = g;
|
||||
if (!group.isValid()) {
|
||||
group = *d->mainConfigGroup();
|
||||
}
|
||||
|
||||
// we call the dptr member directly for locked since isImmutable()
|
||||
// also checks kiosk and parent containers
|
||||
group.writeEntry("immutability", (int)d->immutability);
|
||||
@ -1444,7 +1449,7 @@ QSizeF Applet::sizeHint(Qt::SizeHint which, const QSizeF & constraint) const
|
||||
} else if (formFactor() == Vertical && which == Qt::MinimumSize) {
|
||||
hint.setWidth(0);
|
||||
}
|
||||
|
||||
|
||||
// enforce a square size in panels
|
||||
if (d->aspectRatioMode == Plasma::Square) {
|
||||
if (formFactor() == Horizontal) {
|
||||
|
@ -250,8 +250,13 @@ void Containment::restore(KConfigGroup &group)
|
||||
setImmutability((ImmutabilityType)group.readEntry("immutability", (int)Mutable));
|
||||
}
|
||||
|
||||
void Containment::save(KConfigGroup &group) const
|
||||
void Containment::save(KConfigGroup &g) const
|
||||
{
|
||||
KConfigGroup group = g;
|
||||
if (!group.isValid()) {
|
||||
group = config();
|
||||
}
|
||||
|
||||
// locking is saved in Applet::save
|
||||
Applet::save(group);
|
||||
group.writeEntry("screen", d->screen);
|
||||
@ -533,6 +538,10 @@ void Containment::addApplet(Applet *applet, const QPointF &pos, bool delayInit)
|
||||
return;
|
||||
}
|
||||
|
||||
if (d->applets.contains(applet)) {
|
||||
kDebug() << "already have this applet!";
|
||||
}
|
||||
|
||||
Containment *currentContainment = applet->containment();
|
||||
|
||||
if (containmentType() == PanelContainment) {
|
||||
@ -560,6 +569,8 @@ void Containment::addApplet(Applet *applet, const QPointF &pos, bool delayInit)
|
||||
|
||||
d->applets << applet;
|
||||
|
||||
connect(applet, SIGNAL(configNeedsSaving()), this, SIGNAL(configNeedsSaving()));
|
||||
connect(applet, SIGNAL(releaseVisualFocus()), this, SIGNAL(releaseVisualFocus()));
|
||||
connect(applet, SIGNAL(destroyed(QObject*)), this, SLOT(appletDestroyed(QObject*)));
|
||||
|
||||
if (pos != QPointF(-1, -1)) {
|
||||
@ -1253,8 +1264,6 @@ Applet* ContainmentPrivate::addApplet(const QString& name, const QVariantList& a
|
||||
|
||||
//kDebug() << applet->name() << "sizehint:" << applet->sizeHint() << "geometry:" << applet->geometry();
|
||||
|
||||
QObject::connect(applet, SIGNAL(configNeedsSaving()), q, SIGNAL(configNeedsSaving()));
|
||||
QObject::connect(applet, SIGNAL(releaseVisualFocus()), q, SIGNAL(releaseVisualFocus()));
|
||||
q->addApplet(applet, appletGeometry.topLeft(), delayInit);
|
||||
return applet;
|
||||
}
|
||||
|
22
corona.cpp
22
corona.cpp
@ -120,7 +120,9 @@ public:
|
||||
if (pluginName.isEmpty()) {
|
||||
// default to the desktop containment
|
||||
pluginName = "desktop";
|
||||
} else if (pluginName != "null") {
|
||||
}
|
||||
|
||||
if (pluginName != "null") {
|
||||
applet = Applet::load(pluginName, id, args);
|
||||
containment = dynamic_cast<Containment*>(applet);
|
||||
}
|
||||
@ -138,11 +140,14 @@ public:
|
||||
}
|
||||
|
||||
containment->setIsContainment(true);
|
||||
q->addItem(containment);
|
||||
|
||||
if (!delayedInit) {
|
||||
q->addItem(containment);
|
||||
containment->init();
|
||||
containment->updateConstraints(Plasma::StartupCompletedConstraint);
|
||||
KConfigGroup cg = containment->config();
|
||||
containment->save(cg);
|
||||
q->requestConfigSync();
|
||||
}
|
||||
|
||||
containments.append(containment);
|
||||
@ -270,7 +275,7 @@ void Corona::loadLayout(const QString& configName)
|
||||
continue;
|
||||
}
|
||||
|
||||
addItem(c);
|
||||
//addItem(c);
|
||||
c->init();
|
||||
c->restore(containmentConfig);
|
||||
}
|
||||
@ -325,11 +330,12 @@ KSharedConfigPtr Corona::config() const
|
||||
|
||||
Containment* Corona::addContainment(const QString& name, const QVariantList& args)
|
||||
{
|
||||
Containment *c = d->addContainment(name, args, 0, false);
|
||||
KConfigGroup cg = c->config();
|
||||
c->save(cg);
|
||||
requestConfigSync();
|
||||
return c;
|
||||
return d->addContainment(name, args, 0, false);
|
||||
}
|
||||
|
||||
Containment* Corona::addContainmentDelayed(const QString& name, const QVariantList& args)
|
||||
{
|
||||
return d->addContainment(name, args, 0, true);
|
||||
}
|
||||
|
||||
void Corona::loadDefaultLayout()
|
||||
|
16
corona.h
16
corona.h
@ -172,6 +172,22 @@ protected:
|
||||
**/
|
||||
virtual void loadDefaultLayout();
|
||||
|
||||
/**
|
||||
* Loads a containment with delayed initialization, primarily useful
|
||||
* for implementations of loadDefaultLayout. The caller is responsible
|
||||
* for all initializating, saving and notification of a new containment.
|
||||
*
|
||||
* @param name the plugin name for the containment, as given by
|
||||
* KPluginInfo::pluginName(). If an empty string is passed in, the defalt
|
||||
* containment plugin will be used (usually DesktopContainment). If the
|
||||
* string literal "null" is passed in, then no plugin will be loaded and
|
||||
* a simple Containment object will be created instead.
|
||||
* @param args argument list to pass to the containment
|
||||
*
|
||||
* @return a pointer to the containment on success, or 0 on failure
|
||||
**/
|
||||
Containment *addContainmentDelayed(const QString& name, const QVariantList& args = QVariantList());
|
||||
|
||||
//Reimplemented from QGraphicsScene
|
||||
void dragEnterEvent(QGraphicsSceneDragDropEvent* event);
|
||||
void dragLeaveEvent(QGraphicsSceneDragDropEvent* event);
|
||||
|
Loading…
x
Reference in New Issue
Block a user