add initializeLayout and separate the start up stuff from loadLayout into it so that we can properly load add on layouts

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=811892
This commit is contained in:
Aaron J. Seigo 2008-05-23 23:12:05 +00:00
parent e9989989c5
commit 590b3cebd8
2 changed files with 41 additions and 25 deletions

View File

@ -240,9 +240,28 @@ void Corona::Private::scheduleConfigSync()
}
}
void Corona::loadLayout(const QString& configName)
void Corona::initializeLayout(const QString &configName)
{
clearContainments();
loadLayout(configName);
if (d->containments.isEmpty()) {
loadDefaultLayout();
if (!d->containments.isEmpty()) {
d->scheduleConfigSync();
}
}
if (config()->isImmutable()) {
d->updateContainmentImmutability();
}
KConfigGroup coronaConfig(config(), "General");
setImmutability((ImmutabilityType)coronaConfig.readEntry("immutability", (int)Mutable));
}
void Corona::loadLayout(const QString& configName)
{
KSharedConfigPtr c;
if (configName.isEmpty() || configName == d->configName) {
@ -273,32 +292,18 @@ void Corona::loadLayout(const QString& configName)
c->restore(containmentConfig);
}
if (d->containments.isEmpty()) {
loadDefaultLayout();
if (!d->containments.isEmpty()) {
d->scheduleConfigSync();
foreach (Containment* containment, d->containments) {
QString cid = QString::number(containment->id());
KConfigGroup containmentConfig(&containments, cid);
foreach(Applet* applet, containment->applets()) {
applet->init();
}
} else {
foreach (Containment* containment, d->containments) {
QString cid = QString::number(containment->id());
KConfigGroup containmentConfig(&containments, cid);
foreach(Applet* applet, containment->applets()) {
applet->init();
}
containment->updateConstraints(Plasma::StartupCompletedConstraint);
containment->flushPendingConstraintsEvents();
emit containmentAdded(containment);
}
containment->updateConstraints(Plasma::StartupCompletedConstraint);
containment->flushPendingConstraintsEvents();
emit containmentAdded(containment);
}
if (config()->isImmutable()) {
d->updateContainmentImmutability();
}
KConfigGroup coronaConfig(config(), "General");
setImmutability((ImmutabilityType)coronaConfig.readEntry("immutability", (int)Mutable));
}
Containment* Corona::containmentForScreen(int screen) const

View File

@ -94,7 +94,18 @@ public:
public Q_SLOTS:
/**
* Load applet layout from a config file
* Initializes the layout from a config file. This will first clear any existing
* Containments, load a layout from the requested configuration file, request the
* default layout if needed and update immutability.
*
* @param config the name of the config file to load from,
* or the default config file if QString()
*/
void initializeLayout(const QString &config = QString());
/**
* Load applet layout from a config file. The results will be added to the
* current set of Containments.
*
* @param config the name of the config file to load from,
* or the default config file if QString()