diff --git a/corona.cpp b/corona.cpp index 459006f24..21e711f70 100644 --- a/corona.cpp +++ b/corona.cpp @@ -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 diff --git a/corona.h b/corona.h index a8ef959a8..42b553033 100644 --- a/corona.h +++ b/corona.h @@ -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()