move the tracking of uiReady into libplasma
doesn't still have nothing about ui, is completely bookkeeping, but is easier to have it correct there
This commit is contained in:
parent
ebdfbb2e25
commit
8750d01f40
@ -434,6 +434,10 @@ void Applet::flushPendingConstraintsEvents()
|
||||
Plasma::Types::Constraints c = d->pendingConstraints;
|
||||
d->pendingConstraints = Types::NoConstraint;
|
||||
|
||||
if (c & Plasma::Types::UiReadyConstraint) {
|
||||
d->setUiReady();
|
||||
}
|
||||
|
||||
if (c & Plasma::Types::StartupCompletedConstraint) {
|
||||
//common actions
|
||||
bool unlocked = immutability() == Types::Mutable;
|
||||
|
@ -364,7 +364,7 @@ class PLASMA_EXPORT Applet : public QObject
|
||||
* @since 4.4
|
||||
*/
|
||||
void statusChanged(Plasma::Types::ItemStatus status);
|
||||
|
||||
|
||||
//CONFIGURATION
|
||||
/**
|
||||
* Emitted when an applet has changed values in its configuration
|
||||
@ -375,7 +375,6 @@ class PLASMA_EXPORT Applet : public QObject
|
||||
* applets.
|
||||
*/
|
||||
void configNeedsSaving();
|
||||
|
||||
|
||||
//ACTIONS
|
||||
/**
|
||||
|
@ -395,6 +395,12 @@ void Containment::addApplet(Applet *applet)
|
||||
|
||||
d->applets << applet;
|
||||
|
||||
if (!applet->d->uiReady) {
|
||||
d->loadingApplets << applet;
|
||||
static_cast<Applet *>(this)->d->uiReady = false;
|
||||
emit uiReadyChanged(false);
|
||||
}
|
||||
|
||||
connect(applet, SIGNAL(configNeedsSaving()), this, SIGNAL(configNeedsSaving()));
|
||||
connect(applet, SIGNAL(appletDeleted(Plasma::Applet*)), this, SLOT(appletDeleted(Plasma::Applet*)));
|
||||
connect(applet, SIGNAL(statusChanged(Plasma::Types::ItemStatus)), this, SLOT(checkStatus(Plasma::Types::ItemStatus)));
|
||||
@ -510,6 +516,11 @@ QHash<QString, ContainmentActions*> &Containment::containmentActions()
|
||||
return d->localActionPlugins;
|
||||
}
|
||||
|
||||
bool Containment::isUiReady() const
|
||||
{
|
||||
return static_cast<const Applet *>(this)->d->uiReady;
|
||||
}
|
||||
|
||||
void Containment::setActivity(const QString &activityId)
|
||||
{
|
||||
if (activityId.isEmpty() || d->activityId == activityId) {
|
||||
|
@ -205,6 +205,11 @@ class PLASMA_EXPORT Containment : public Applet
|
||||
QHash<QString, ContainmentActions*> &containmentActions();
|
||||
|
||||
|
||||
/**
|
||||
* @returns true when the ui of this containment is fully loaded, as well the ui of every applet in it
|
||||
*/
|
||||
bool isUiReady() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* This signal is emitted when a new applet is created by the containment
|
||||
@ -262,6 +267,12 @@ Q_SIGNALS:
|
||||
*/
|
||||
void formFactorChanged(Plasma::Types::FormFactor formFactor);
|
||||
|
||||
/**
|
||||
* Emitted when the ui has been fully loaded and is fully working
|
||||
* @param uiReady true when the ui of the containment is ready, as well the ui of each applet in it
|
||||
*/
|
||||
void uiReadyChanged(bool uiReady);
|
||||
|
||||
public Q_SLOTS:
|
||||
/**
|
||||
* Informs the Corona as to what position it is in. This is informational
|
||||
|
@ -53,8 +53,9 @@ enum Constraint {
|
||||
ImmutableConstraint = 8, /**< the immutability (locked) nature of the applet changed */
|
||||
StartupCompletedConstraint = 16, /**< application startup has completed */
|
||||
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
|
||||
ImmutableConstraint | UiReadyConstraint
|
||||
};
|
||||
Q_ENUMS(Constraint)
|
||||
Q_DECLARE_FLAGS(Constraints, Constraint)
|
||||
|
@ -67,7 +67,8 @@ AppletPrivate::AppletPrivate(KService::Ptr service, const KPluginInfo *info, int
|
||||
transient(false),
|
||||
needsConfig(false),
|
||||
started(false),
|
||||
globalShortcutEnabled(false)
|
||||
globalShortcutEnabled(false),
|
||||
uiReady(false)
|
||||
{
|
||||
if (appletId == 0) {
|
||||
appletId = ++s_maxAppletId;
|
||||
@ -270,6 +271,29 @@ void AppletPrivate::propagateConfigChanged()
|
||||
q->configChanged();
|
||||
}
|
||||
|
||||
void AppletPrivate::setUiReady()
|
||||
{
|
||||
//am i the containment?
|
||||
Containment *c = qobject_cast<Containment *>(q);
|
||||
if (c) {
|
||||
//if we are the containment and there is still some uncomplete applet, we're still incomplete
|
||||
if (!c->d->loadingApplets.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
} 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 = true;
|
||||
emit q->containment()->uiReadyChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uiReady = true;
|
||||
}
|
||||
|
||||
void AppletPrivate::setIsContainment(bool nowIsContainment, bool forceUpdate)
|
||||
{
|
||||
if (isContainment == nowIsContainment && !forceUpdate) {
|
||||
|
@ -69,6 +69,7 @@ public:
|
||||
void updateShortcuts();
|
||||
void globalShortcutChanged();
|
||||
void propagateConfigChanged();
|
||||
void setUiReady();
|
||||
|
||||
static KActionCollection* defaultActions(QObject *parent);
|
||||
|
||||
@ -114,6 +115,7 @@ public:
|
||||
bool needsConfig : 1;
|
||||
bool started : 1;
|
||||
bool globalShortcutEnabled : 1;
|
||||
bool uiReady : 1;
|
||||
};
|
||||
|
||||
} // Plasma namespace
|
||||
|
@ -22,6 +22,7 @@
|
||||
#define CONTAINMENT_P_H
|
||||
|
||||
#include <kactioncollection.h>
|
||||
#include <QSet>
|
||||
|
||||
#include "plasma.h"
|
||||
#include "applet.h"
|
||||
@ -97,6 +98,8 @@ public:
|
||||
Types::FormFactor formFactor;
|
||||
Types::Location location;
|
||||
QList<Applet *> applets;
|
||||
//Applets still considered not ready
|
||||
QSet <Applet *> loadingApplets;
|
||||
QString wallpaper;
|
||||
QHash<QString, ContainmentActions*> localActionPlugins;
|
||||
int screen;
|
||||
|
@ -157,6 +157,11 @@ Q_SIGNALS:
|
||||
*/
|
||||
void saveState(KConfigGroup &group) const;
|
||||
|
||||
/**
|
||||
* @param uiReady true if the UI for this applet is ready
|
||||
*/
|
||||
void uiReadyChanged(bool uiReady);
|
||||
|
||||
public Q_SLOTS:
|
||||
|
||||
/**
|
||||
|
@ -186,20 +186,7 @@ void AppletInterface::init()
|
||||
geometryChanged(QRectF(), QRectF(x(), y(), width(), height()));
|
||||
emit busyChanged();
|
||||
|
||||
if (!qobject_cast<Plasma::Containment *>(applet())) {
|
||||
m_appletScriptEngine->setUiReady(true);
|
||||
|
||||
ContainmentInterface *containmentGraphicObject = qobject_cast<ContainmentInterface *>(applet()->containment()->property("graphicObject").value<QObject *>());
|
||||
|
||||
if (containmentGraphicObject) {
|
||||
DeclarativeAppletScript *containmentScript = containmentGraphicObject->m_appletScriptEngine;
|
||||
|
||||
containmentScript->m_inProgressAppletInterfaces.remove(this);
|
||||
if (containmentScript->m_inProgressAppletInterfaces.isEmpty()) {
|
||||
containmentScript->setUiReady(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
applet()->updateConstraints(Plasma::Types::UiReadyConstraint);
|
||||
}
|
||||
|
||||
Plasma::Types::FormFactor AppletInterface::formFactor() const
|
||||
|
@ -82,9 +82,6 @@ void ContainmentInterface::init()
|
||||
if (!m_appletInterfaces.isEmpty()) {
|
||||
emit appletsChanged();
|
||||
}
|
||||
if (m_appletScriptEngine->m_inProgressAppletInterfaces.isEmpty()) {
|
||||
m_appletScriptEngine->setUiReady(true);
|
||||
}
|
||||
}
|
||||
|
||||
QList <QObject *> ContainmentInterface::applets()
|
||||
@ -176,7 +173,6 @@ void ContainmentInterface::appletAddedForward(Plasma::Applet *applet)
|
||||
}
|
||||
|
||||
m_appletInterfaces << appletGraphicObject;
|
||||
m_appletScriptEngine->m_inProgressAppletInterfaces.insert(appletGraphicObject);
|
||||
emit appletAdded(appletGraphicObject);
|
||||
emit appletsChanged();
|
||||
}
|
||||
|
@ -56,8 +56,7 @@ K_EXPORT_PLASMA_APPLETSCRIPTENGINE(declarativeappletscript, DeclarativeAppletScr
|
||||
|
||||
DeclarativeAppletScript::DeclarativeAppletScript(QObject *parent, const QVariantList &args)
|
||||
: Plasma::AppletScript(parent),
|
||||
m_interface(0),
|
||||
m_uiReady(false)
|
||||
m_interface(0)
|
||||
{
|
||||
qmlRegisterType<AppletInterface>();
|
||||
qmlRegisterType<ConfigPropertyMap>();
|
||||
@ -115,21 +114,6 @@ void DeclarativeAppletScript::constraintsEvent(Plasma::Types::Constraints constr
|
||||
}
|
||||
}
|
||||
|
||||
void DeclarativeAppletScript::setUiReady(bool ready)
|
||||
{
|
||||
if (m_uiReady == ready) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_uiReady = ready;
|
||||
emit uiReadyChanged(ready);
|
||||
}
|
||||
|
||||
bool DeclarativeAppletScript::isUiReady() const
|
||||
{
|
||||
return m_uiReady;
|
||||
}
|
||||
|
||||
void DeclarativeAppletScript::activate()
|
||||
{
|
||||
#if 0
|
||||
|
@ -46,9 +46,6 @@ public:
|
||||
|
||||
void constraintsEvent(Plasma::Types::Constraints constraints);
|
||||
|
||||
void setUiReady(bool ready);
|
||||
bool isUiReady() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void executeAction(const QString &name);
|
||||
void activate();
|
||||
@ -64,8 +61,6 @@ Q_SIGNALS:
|
||||
|
||||
private:
|
||||
AppletInterface *m_interface;
|
||||
bool m_uiReady;
|
||||
QSet<QObject *> m_inProgressAppletInterfaces;
|
||||
friend class AppletInterface;
|
||||
friend class ContainmentInterface;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user