introduce the signal Corona::startupCompleted()

when emitted we are sure all containments *graphics objects*
 have been created
This commit is contained in:
Marco Martin 2014-04-22 14:57:17 +02:00
parent ac1e50d3aa
commit 47dfda75c0
6 changed files with 49 additions and 8 deletions

View File

@ -526,7 +526,8 @@ QHash<QString, ContainmentActions*> &Containment::containmentActions()
bool Containment::isUiReady() const
{
return static_cast<const Applet *>(this)->d->uiReady;
const Applet *a = static_cast<const Applet *>(this);
return a->d->uiReady && a->d->started;
}
void Containment::setActivity(const QString &activityId)

View File

@ -180,6 +180,11 @@ QList<Containment*> 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<Plasma::Containment *> 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;
}

View File

@ -68,6 +68,12 @@ public:
*/
QList<Containment*> 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

View File

@ -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)

View File

@ -298,20 +298,23 @@ void AppletPrivate::setUiReady()
{
//am i the containment?
Containment *c = qobject_cast<Containment *>(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<Applet *>(q->containment())->d->uiReady) {
static_cast<Applet *>(q->containment())->d->uiReady = true;
emit q->containment()->uiReadyChanged(true);
Applet *a = static_cast<Applet *>(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;

View File

@ -57,6 +57,7 @@ public:
QTimer *configSyncTimer;
QList<Containment*> containments;
KActionCollection actions;
int containmentsStarting;
};
}