Allow applets/containments/wallpaper to defer UIReadyConstraint

Summary:
This is needed so that we don't remove the splash till the wallpaper is
loaded, but also allows doing this in a generic way.

Version 2 of the patch using a normal property.

We need to have the virtual so that the containment waits for the
wallpaper.

Test Plan:
Used with wallpaper patch
Added debug to ensure it happened after the stackview in the wallpaper
is pushed

Reviewers: #plasma

Subscribers: kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D22852
This commit is contained in:
David Edmundson 2019-07-31 12:28:39 +01:00
parent 56aa6dee3a
commit d62e99460a
6 changed files with 57 additions and 5 deletions

View File

@ -169,7 +169,9 @@ void AppletInterface::init()
geometryChanged(QRectF(), QRectF(x(), y(), width(), height()));
emit busyChanged();
applet()->updateConstraints(Plasma::Types::UiReadyConstraint);
updateUiReadyConstraint();
connect(this, &AppletInterface::isLoadingChanged, this, &AppletInterface::updateUiReadyConstraint);
connect(applet(), &Plasma::Applet::activated, this,
[ = ]() {
@ -851,5 +853,16 @@ bool AppletInterface::eventFilter(QObject *watched, QEvent *event)
return AppletQuickItem::eventFilter(watched, event);
}
void AppletInterface::updateUiReadyConstraint()
{
if (!isLoading()) {
applet()->updateConstraints(Plasma::Types::UiReadyConstraint);
}
}
bool AppletInterface::isLoading() const
{
return m_loading;
}
#include "moc_appletinterface.cpp"

View File

@ -238,6 +238,8 @@ class AppletInterface : public PlasmaQuick::AppletQuickItem
*/
Q_PROPERTY(QVariantList availableScreenRegion READ availableScreenRegion NOTIFY availableScreenRegionChanged)
Q_PROPERTY(bool loading MEMBER m_loading NOTIFY isLoadingChanged)
public:
AppletInterface(DeclarativeAppletScript *script, const QVariantList &args = QVariantList(), QQuickItem *parent = nullptr);
~AppletInterface() override;
@ -448,6 +450,8 @@ Q_SIGNALS:
void configurationRequiredChanged();
void configurationRequiredReasonChanged();
void isLoadingChanged();
protected Q_SLOTS:
void init() override;
@ -455,6 +459,15 @@ protected:
bool event(QEvent *event) override;
bool eventFilter(QObject *watched, QEvent *event) override;
/*
* Returns true if this plasmoid or a dependent feature (i.e wallpaper) is loading
*/
virtual bool isLoading() const;
/*
* Set UIReadyConstraint if we're not currently loading
*/
void updateUiReadyConstraint();
private Q_SLOTS:
void destroyedChanged(bool destroyed);
@ -474,6 +487,7 @@ private:
QVariantList m_args;
Plasma::Types::BackgroundHints m_backgroundHints;
bool m_hideOnDeactivate : 1;
bool m_loading = false;
//this is used to build an emacs style shortcut
int m_oldKeyboardShortcut;
QObject *m_dummyNativeInterface;

View File

@ -88,6 +88,10 @@ void ContainmentInterface::init()
this, &ContainmentInterface::activityNameChanged);
emit activityNameChanged();
if (!m_containment->wallpaper().isEmpty()) {
loadWallpaper();
}
AppletInterface::init();
//Create the ToolBox
@ -145,10 +149,6 @@ void ContainmentInterface::init()
prop.write(expr.evaluate());
}
if (!m_containment->wallpaper().isEmpty()) {
loadWallpaper();
}
connect(m_containment.data(), &Plasma::Containment::activityChanged,
this, &ContainmentInterface::activityChanged);
connect(m_containment.data(), &Plasma::Containment::activityChanged, this,
@ -861,6 +861,8 @@ void ContainmentInterface::loadWallpaper()
//Qml seems happier if the parent gets set in this way
m_wallpaperInterface->setProperty("parent", QVariant::fromValue(this));
connect(m_wallpaperInterface, &WallpaperInterface::isLoadingChanged, this, &AppletInterface::updateUiReadyConstraint);
//set anchors
QQmlExpression expr(qmlObject()->engine()->rootContext(), m_wallpaperInterface, QStringLiteral("parent"));
QQmlProperty prop(m_wallpaperInterface, QStringLiteral("anchors.fill"));
@ -1217,4 +1219,14 @@ void ContainmentInterface::addContainmentActions(QMenu *desktopMenu, QEvent *eve
return;
}
bool ContainmentInterface::isLoading() const
{
bool loading = AppletInterface::isLoading();
if (m_wallpaperInterface) {
loading |= m_wallpaperInterface->isLoading();
}
return loading;
}
#include "moc_containmentinterface.cpp"

View File

@ -168,6 +168,8 @@ protected:
void addAppletActions(QMenu *desktopMenu, Plasma::Applet *applet, QEvent *event);
void addContainmentActions(QMenu *desktopMenu, QEvent *event);
virtual bool isLoading() const override;
Q_SIGNALS:
/**
* Emitted when an applet is added

View File

@ -266,4 +266,10 @@ WallpaperInterface * WallpaperInterface::qmlAttachedProperties(QObject* object)
return object->parent() ? nullptr : s_rootObjects.value(QtQml::qmlEngine(object));
}
bool WallpaperInterface::isLoading() const
{
return m_loading;
}
#include "moc_wallpaperinterface.cpp"

View File

@ -49,6 +49,7 @@ class WallpaperInterface : public QQuickItem
Q_PROPERTY(QString pluginName READ pluginName NOTIFY packageChanged)
Q_PROPERTY(KDeclarative::ConfigPropertyMap *configuration READ configuration NOTIFY configurationChanged)
Q_PROPERTY(bool loading MEMBER m_loading NOTIFY isLoadingChanged)
public:
explicit WallpaperInterface(ContainmentInterface *parent = nullptr);
@ -86,9 +87,12 @@ public:
static WallpaperInterface *qmlAttachedProperties(QObject *object);
bool isLoading() const;
Q_SIGNALS:
void packageChanged();
void configurationChanged();
void isLoadingChanged();
private Q_SLOTS:
void syncWallpaperPackage();
@ -103,6 +107,7 @@ private:
KDeclarative::ConfigPropertyMap *m_configuration;
KConfigLoader *m_configLoader;
KActionCollection *m_actions;
bool m_loading = false;
static QHash<QObject *, WallpaperInterface *> s_rootObjects;
};