diff --git a/autotests/coronatest.cpp b/autotests/coronatest.cpp index 8e74c83cb..58e1b6996 100644 --- a/autotests/coronatest.cpp +++ b/autotests/coronatest.cpp @@ -28,7 +28,9 @@ Plasma::Applet *SimpleLoader::internalLoadApplet(const QString &name, uint apple const QVariantList &args) { if (name == "simpleapplet") { - return new SimpleApplet(); + return new SimpleApplet(0, QString(), appletId); + } else if (name == "simplecontainment") { + return new SimpleContainment(0, QString(), appletId); } else { return 0; } @@ -66,6 +68,22 @@ SimpleApplet::SimpleApplet(QObject *parent , const QString &serviceId, uint appl } +SimpleContainment::SimpleContainment(QObject *parent , const QString &serviceId, uint appletId) + : Plasma::Containment(parent, serviceId, appletId) +{ + QTime time = QTime::currentTime(); + qsrand((uint)time.msec()); + + //updateConstraints(Plasma::Types::UiReadyConstraint); + m_timer.setSingleShot(true); + m_timer.setInterval(qrand() % ((500 + 1) - 100) + 100); + m_timer.start(); + connect(&m_timer, &QTimer::timeout, [=]() { + updateConstraints(Plasma::Types::UiReadyConstraint); + }); +} + + static void runKBuildSycoca() { @@ -117,13 +135,10 @@ void CoronaTest::restore() void CoronaTest::startupCompletion() { - QEXPECT_FAIL("", "Uiready behavior broken in master.", Continue); QVERIFY(!m_corona->isStartupCompleted()); - QEXPECT_FAIL("", "Uiready behavior broken in master.", Continue); QVERIFY(!m_corona->containments().first()->isUiReady()); QSignalSpy spy(m_corona, SIGNAL(startupCompleted())); - QEXPECT_FAIL("", "Uiready behavior broken in master.", Continue); QVERIFY(spy.wait(1000)); QVERIFY(m_corona->isStartupCompleted()); diff --git a/autotests/coronatest.h b/autotests/coronatest.h index 2e5b9c39f..d4098ef3c 100644 --- a/autotests/coronatest.h +++ b/autotests/coronatest.h @@ -55,6 +55,16 @@ private: QTimer m_timer; }; +class SimpleContainment : public Plasma::Containment +{ + Q_OBJECT + +public: + explicit SimpleContainment(QObject *parent = 0, const QString &serviceId = QString(), uint appletId = 0); +private: + QTimer m_timer; +}; + class CoronaTest : public QObject { Q_OBJECT diff --git a/autotests/plasma-test-appletsrc b/autotests/plasma-test-appletsrc index 457108ef7..677d9f8f4 100644 --- a/autotests/plasma-test-appletsrc +++ b/autotests/plasma-test-appletsrc @@ -4,7 +4,7 @@ formfactor=0 immutability=1 lastScreen=0 location=0 -plugin=simpleapplet +plugin=simplecontainment [Containments][1][Applets][2] immutability=1 diff --git a/src/plasma/containment.cpp b/src/plasma/containment.cpp index 35bfbfc2a..ff9c1846f 100644 --- a/src/plasma/containment.cpp +++ b/src/plasma/containment.cpp @@ -281,6 +281,12 @@ void Containment::restoreContents(KConfigGroup &group) d->createApplet(plugin, QVariantList(), appId); } + + for (Applet *applet : Containment::applets()) { + if (!applet->pluginInfo().isValid()) { + applet->updateConstraints(Plasma::Types::UiReadyConstraint); + } + } } Plasma::Types::ContainmentType Containment::containmentType() const @@ -536,7 +542,7 @@ QHash &Containment::containmentActions() bool Containment::isUiReady() const { - return d->uiReady && Applet::d->started; + return d->uiReady && d->appletsUiReady && Applet::d->started; } void Containment::setActivity(const QString &activityId) diff --git a/src/plasma/corona.cpp b/src/plasma/corona.cpp index 9a6b601f2..c6bd9497a 100644 --- a/src/plasma/corona.cpp +++ b/src/plasma/corona.cpp @@ -540,8 +540,9 @@ QList CoronaPrivate::importLayout(const KConfigGroup &con if (!containment->isUiReady() && containment->lastScreen() < q->numScreens()) { ++containmentsStarting; QObject::connect(containment, &Plasma::Containment::uiReadyChanged, [=](bool ready) { - if (!ready) + if (!ready) { return; + } --containmentsStarting; if (containmentsStarting <= 0) { diff --git a/src/plasma/private/applet_p.cpp b/src/plasma/private/applet_p.cpp index b6bebe5a7..985379fe0 100644 --- a/src/plasma/private/applet_p.cpp +++ b/src/plasma/private/applet_p.cpp @@ -357,8 +357,9 @@ void AppletPrivate::scheduleConstraintsUpdate(Plasma::Types::Constraints c) if (c & Plasma::Types::StartupCompletedConstraint) { started = true; - if (q->isContainment()) + if (q->isContainment()) { qobject_cast(q)->d->setStarted(); + } } pendingConstraints |= c; diff --git a/src/plasma/private/containment_p.cpp b/src/plasma/private/containment_p.cpp index 018abfec8..616bc9342 100644 --- a/src/plasma/private/containment_p.cpp +++ b/src/plasma/private/containment_p.cpp @@ -47,7 +47,8 @@ ContainmentPrivate::ContainmentPrivate(Containment *c): location(Types::Floating), lastScreen(-1), // never had a screen type(Plasma::Types::NoContainmentType), - uiReady(false) + uiReady(false), + appletsUiReady(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 @@ -210,7 +211,6 @@ Applet *ContainmentPrivate::createApplet(const QString &name, const QVariantList qWarning() << "Applet" << name << "could not be loaded."; applet = new Applet(0, QString(), id); applet->setLaunchErrorMessage(i18n("Could not find requested component: %1", name)); - applet->updateConstraints(Plasma::Types::UiReadyConstraint); } q->addApplet(applet); @@ -235,28 +235,30 @@ void ContainmentPrivate::setStarted() if (!q->Applet::d->started) { q->Applet::d->started = true; - if (uiReady) + 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()) { + if (!uiReady) { uiReady = true; - if (q->Applet::d->started) + if (q->Applet::d->started && appletsUiReady && loadingApplets.isEmpty()) { emit q->uiReadyChanged(true); + } } } void ContainmentPrivate::appletLoaded(Applet* applet) { - loadingApplets.remove(q); + loadingApplets.remove(applet); - if (loadingApplets.isEmpty() && !uiReady) { - uiReady = true; - if (q->Applet::d->started) { + if (loadingApplets.isEmpty() && !appletsUiReady) { + appletsUiReady = true; + if (q->Applet::d->started && uiReady) { emit q->uiReadyChanged(true); } } diff --git a/src/plasma/private/containment_p.h b/src/plasma/private/containment_p.h index e4b76be6c..f82af8831 100644 --- a/src/plasma/private/containment_p.h +++ b/src/plasma/private/containment_p.h @@ -91,6 +91,7 @@ public: QString activityId; Types::ContainmentType type; bool uiReady : 1; + bool appletsUiReady : 1; static const char defaultWallpaper[]; };