diff --git a/src/plasma/containment.cpp b/src/plasma/containment.cpp index 30909667f..3b7797e0c 100644 --- a/src/plasma/containment.cpp +++ b/src/plasma/containment.cpp @@ -526,7 +526,8 @@ QHash &Containment::containmentActions() bool Containment::isUiReady() const { - return static_cast(this)->d->uiReady; + const Applet *a = static_cast(this); + return a->d->uiReady && a->d->started; } void Containment::setActivity(const QString &activityId) diff --git a/src/plasma/corona.cpp b/src/plasma/corona.cpp index 194df4972..c689cb6d6 100644 --- a/src/plasma/corona.cpp +++ b/src/plasma/corona.cpp @@ -180,6 +180,11 @@ QList Corona::containments() const return d->containments; } +bool Corona::isStartupCompleted() const +{ + return d->containmentsStarting <= 0; +} + KSharedConfigPtr Corona::config() const { if (!d->config) { @@ -308,7 +313,8 @@ CoronaPrivate::CoronaPrivate(Corona *corona) immutability(Types::Mutable), config(0), configSyncTimer(new QTimer(corona)), - actions(corona) + actions(corona), + containmentsStarting(0) { //TODO: make Package path configurable KConfigGroup config(KSharedConfig::openConfig(), "General"); @@ -525,6 +531,22 @@ QList CoronaPrivate::importLayout(const KConfigGroup &con #endif } + if (!mergeConfig) { + containmentsStarting = 0; + foreach (Containment *containment, containments) { + if (!containment->isUiReady() && containment->lastScreen() < q->numScreens()) { + ++containmentsStarting; + QObject::connect(containment, &Plasma::Containment::uiReadyChanged, [=](){ + --containmentsStarting; + if (containmentsStarting <= 0) { + qDebug() << "Corona Startup Completed"; + emit q->startupCompleted(); + } + }); + } + } + } + return newContainments; } diff --git a/src/plasma/corona.h b/src/plasma/corona.h index 06ebbb091..882666385 100644 --- a/src/plasma/corona.h +++ b/src/plasma/corona.h @@ -68,6 +68,12 @@ public: */ QList containments() const; + /** + * @returns true when the startup is over, and + * all the ui graphics has been instantiated + */ + bool isStartupCompleted() const; + /** * Returns the config file used to store the configuration for this Corona */ @@ -265,6 +271,11 @@ Q_SIGNALS: */ void packageChanged(const Plasma::Package &package); + /** + * Emitted when the startup phase has been completed + */ + void startupCompleted(); + protected: /** * Loads the default (system wide) layout for this user diff --git a/src/plasma/plasma.h b/src/plasma/plasma.h index c590dd709..61c9c2954 100644 --- a/src/plasma/plasma.h +++ b/src/plasma/plasma.h @@ -55,7 +55,7 @@ enum Constraint { ContextConstraint = 32, /**< the context (e.g. activity) has changed */ UiReadyConstraint = 64, /** The ui has been completely loaded (FIXME: merged with StartupCompletedConstraint?) */ AllConstraints = FormFactorConstraint | LocationConstraint | ScreenConstraint | - ImmutableConstraint | UiReadyConstraint + ImmutableConstraint }; Q_ENUMS(Constraint) Q_DECLARE_FLAGS(Constraints, Constraint) diff --git a/src/plasma/private/applet_p.cpp b/src/plasma/private/applet_p.cpp index f733391dc..b815c29fa 100644 --- a/src/plasma/private/applet_p.cpp +++ b/src/plasma/private/applet_p.cpp @@ -298,20 +298,23 @@ void AppletPrivate::setUiReady() { //am i the containment? Containment *c = qobject_cast(q); - if (c) { + if (c && c->isContainment()) { //if we are the containment and there is still some uncomplete applet, we're still incomplete if (!c->d->loadingApplets.isEmpty()) { return; - } else if (!uiReady) { + } else if (!uiReady && started) { emit c->uiReadyChanged(true); } } else { c = q->containment(); if (c) { q->containment()->d->loadingApplets.remove(q); - if (q->containment()->d->loadingApplets.isEmpty() && !static_cast(q->containment())->d->uiReady) { - static_cast(q->containment())->d->uiReady = true; - emit q->containment()->uiReadyChanged(true); + Applet *a = static_cast(q->containment()); + if (q->containment()->d->loadingApplets.isEmpty() && !a->d->uiReady) { + a->d->uiReady = true; + if (a->d->started) { + emit q->containment()->uiReadyChanged(true); + } } } } @@ -362,6 +365,9 @@ void AppletPrivate::scheduleConstraintsUpdate(Plasma::Types::Constraints c) if (c & Plasma::Types::StartupCompletedConstraint) { started = true; + if (uiReady) { + emit q->containment()->uiReadyChanged(true); + } } pendingConstraints |= c; diff --git a/src/plasma/private/corona_p.h b/src/plasma/private/corona_p.h index 3d10313b4..f978351be 100644 --- a/src/plasma/private/corona_p.h +++ b/src/plasma/private/corona_p.h @@ -57,6 +57,7 @@ public: QTimer *configSyncTimer; QList containments; KActionCollection actions; + int containmentsStarting; }; }