From dac1d8f2657e0b7b1fdb6f926d616a515aba360c Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Mon, 14 Jul 2014 13:23:20 +0200 Subject: [PATCH] Figure out why my plasma wasn't notifying the startup Make sure AppletPrivate::uiReady is set in applet_p.cpp when we report that the ui is ready. Make sure that if we loop through all the containments and they're all ready, we emit that it's done. So far, Corona::startupCompleted was never emitted. REVIEW: 119220 --- src/plasma/containment.cpp | 8 +++---- src/plasma/corona.cpp | 9 +++++++ src/plasma/corona.h | 2 ++ src/plasma/private/applet_p.cpp | 29 ++++------------------- src/plasma/private/applet_p.h | 1 - src/plasma/private/containment_p.cpp | 35 +++++++++++++++++++++++++++- src/plasma/private/containment_p.h | 8 ++++--- 7 files changed, 59 insertions(+), 33 deletions(-) diff --git a/src/plasma/containment.cpp b/src/plasma/containment.cpp index 377245ad3..35bfbfc2a 100644 --- a/src/plasma/containment.cpp +++ b/src/plasma/containment.cpp @@ -409,10 +409,10 @@ void Containment::addApplet(Applet *applet) d->applets << applet; - if (!applet->d->uiReady) { + if (!d->uiReady) { d->loadingApplets << applet; - if (Applet::d->uiReady) { - Applet::d->uiReady = false; + if (d->uiReady) { + d->uiReady = false; emit uiReadyChanged(false); } } @@ -536,7 +536,7 @@ QHash &Containment::containmentActions() bool Containment::isUiReady() const { - return Applet::d->uiReady && Applet::d->started; + return d->uiReady && Applet::d->started; } void Containment::setActivity(const QString &activityId) diff --git a/src/plasma/corona.cpp b/src/plasma/corona.cpp index e18f08119..a731463fc 100644 --- a/src/plasma/corona.cpp +++ b/src/plasma/corona.cpp @@ -40,6 +40,7 @@ #include "pluginloader.h" #include "private/applet_p.h" #include "private/containment_p.h" +#include "private/timetracker.h" using namespace Plasma; @@ -54,6 +55,10 @@ Corona::Corona(QObject *parent) // qDebug() << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "Corona ctor start"; #endif d->init(); + +#ifndef NDEBUG + new Plasma::TimeTracker(this); +#endif } Corona::~Corona() @@ -543,6 +548,10 @@ QList CoronaPrivate::importLayout(const KConfigGroup &con }); } } + + if (containmentsStarting <= 0) { + emit q->startupCompleted(); + } } return newContainments; diff --git a/src/plasma/corona.h b/src/plasma/corona.h index baa9ee939..f60fd74e2 100644 --- a/src/plasma/corona.h +++ b/src/plasma/corona.h @@ -41,6 +41,8 @@ class CoronaPrivate; class PLASMA_EXPORT Corona : public QObject { Q_OBJECT + Q_PROPERTY(bool isStartupCompleted READ isStartupCompleted NOTIFY startupCompleted) + Q_PROPERTY(Plasma::Package package READ package NOTIFY packageChanged) public: explicit Corona(QObject *parent = 0); diff --git a/src/plasma/private/applet_p.cpp b/src/plasma/private/applet_p.cpp index 07efc363d..b6bebe5a7 100644 --- a/src/plasma/private/applet_p.cpp +++ b/src/plasma/private/applet_p.cpp @@ -67,7 +67,6 @@ AppletPrivate::AppletPrivate(KService::Ptr service, const KPluginInfo *info, int needsConfig(false), started(false), globalShortcutEnabled(false), - uiReady(false), userConfiguring(false) { if (appletId == 0) { @@ -309,27 +308,10 @@ void AppletPrivate::setUiReady() //am i the containment? Containment *c = qobject_cast(q); 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 && started) { - emit c->uiReadyChanged(true); - } - } else { - c = q->containment(); - if (c) { - c->d->loadingApplets.remove(q); - - if (c->d->loadingApplets.isEmpty() && !c->Applet::d->uiReady) { - c->Applet::d->uiReady = true; - if (c->Applet::d->started) { - emit c->uiReadyChanged(true); - } - } - } + c->d->setUiReady(); + } else if (Containment* cc = q->containment()) { + cc->d->appletLoaded(q); } - - uiReady = true; } // put all setup routines for script here. at this point we can assume that @@ -375,9 +357,8 @@ void AppletPrivate::scheduleConstraintsUpdate(Plasma::Types::Constraints c) if (c & Plasma::Types::StartupCompletedConstraint) { started = true; - if (uiReady) { - emit q->containment()->uiReadyChanged(true); - } + if (q->isContainment()) + qobject_cast(q)->d->setStarted(); } pendingConstraints |= c; diff --git a/src/plasma/private/applet_p.h b/src/plasma/private/applet_p.h index f62da0756..76a1270be 100644 --- a/src/plasma/private/applet_p.h +++ b/src/plasma/private/applet_p.h @@ -111,7 +111,6 @@ public: bool needsConfig : 1; bool started : 1; bool globalShortcutEnabled : 1; - bool uiReady : 1; bool userConfiguring : 1; }; diff --git a/src/plasma/private/containment_p.cpp b/src/plasma/private/containment_p.cpp index f8b457828..bb32dfa3b 100644 --- a/src/plasma/private/containment_p.cpp +++ b/src/plasma/private/containment_p.cpp @@ -46,7 +46,8 @@ ContainmentPrivate::ContainmentPrivate(Containment *c): formFactor(Types::Planar), location(Types::Floating), lastScreen(-1), // never had a screen - type(Plasma::Types::NoContainmentType) + type(Plasma::Types::NoContainmentType), + uiReady(false) { //if the parent is an applet (i.e we are the systray) //we want to follow screen changed signals from the parent's containment @@ -228,4 +229,36 @@ bool ContainmentPrivate::isPanelContainment() const return type == Plasma::Types::PanelContainment || type == Plasma::Types::CustomPanelContainment; } +void ContainmentPrivate::setStarted() +{ + if (!q->Applet::d->started) { + q->Applet::d->started = true; + + if (uiReady) + emit q->uiReadyChanged(true); + } +} + +void ContainmentPrivate::setUiReady() +{ + //if we are the containment and there is still some uncomplete applet, we're still incomplete + if (!uiReady && loadingApplets.isEmpty()) { + uiReady = true; + if (q->Applet::d->started) + emit q->uiReadyChanged(true); + } +} + +void ContainmentPrivate::appletLoaded(Applet* applet) +{ + loadingApplets.remove(q); + + if (loadingApplets.isEmpty() && !uiReady) { + uiReady = true; + if (q->Applet::d->started) { + emit q->uiReadyChanged(true); + } + } +} + } diff --git a/src/plasma/private/containment_p.h b/src/plasma/private/containment_p.h index 8c691cd1f..e4b76be6c 100644 --- a/src/plasma/private/containment_p.h +++ b/src/plasma/private/containment_p.h @@ -45,8 +45,6 @@ class ContainmentPrivate { public: ContainmentPrivate(Containment *c); - - ~ContainmentPrivate(); void triggerShowAddWidgets(); @@ -60,7 +58,6 @@ public: void containmentConstraintsEvent(Plasma::Types::Constraints constraints); bool isPanelContainment() const; - void setLockToolText(); void appletDeleted(Applet *); void configChanged(); @@ -78,6 +75,10 @@ public: */ static void addDefaultActions(KActionCollection *actions, Containment *c = 0); + void setUiReady(); + void setStarted(); + void appletLoaded(Applet* applet); + Containment *q; Types::FormFactor formFactor; Types::Location location; @@ -89,6 +90,7 @@ public: int lastScreen; QString activityId; Types::ContainmentType type; + bool uiReady : 1; static const char defaultWallpaper[]; };