From 9b52bfad89e6a8977d739842fd7d6f6bbdaa0383 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 8 Aug 2013 16:12:31 +0200 Subject: [PATCH] the scriptengine has an uiReady property will be used for some experiments later: we can track if the ui machinery has been correctly initialized. we'll use that to ensure the applets gets initialized and prepared only after their containment has been --- .../qml/plasmoid/appletinterface.cpp | 1 + .../qml/plasmoid/declarativeappletscript.cpp | 18 +++++++++++++++++- .../qml/plasmoid/declarativeappletscript.h | 5 +++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/scriptengines/qml/plasmoid/appletinterface.cpp b/src/scriptengines/qml/plasmoid/appletinterface.cpp index a9a3e626b..092e63b21 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.cpp +++ b/src/scriptengines/qml/plasmoid/appletinterface.cpp @@ -185,6 +185,7 @@ void AppletInterface::init() } geometryChanged(QRectF(), QRectF(x(), y(), width(), height())); emit busyChanged(); + m_appletScriptEngine->setUiReady(true); } Plasma::Types::FormFactor AppletInterface::formFactor() const diff --git a/src/scriptengines/qml/plasmoid/declarativeappletscript.cpp b/src/scriptengines/qml/plasmoid/declarativeappletscript.cpp index dc1242498..dc9ac00aa 100644 --- a/src/scriptengines/qml/plasmoid/declarativeappletscript.cpp +++ b/src/scriptengines/qml/plasmoid/declarativeappletscript.cpp @@ -56,7 +56,8 @@ K_EXPORT_PLASMA_APPLETSCRIPTENGINE(declarativeappletscript, DeclarativeAppletScr DeclarativeAppletScript::DeclarativeAppletScript(QObject *parent, const QVariantList &args) : Plasma::AppletScript(parent), - m_interface(0) + m_interface(0), + m_uiReady(false) { qmlRegisterType(); qmlRegisterType(); @@ -114,6 +115,21 @@ 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 diff --git a/src/scriptengines/qml/plasmoid/declarativeappletscript.h b/src/scriptengines/qml/plasmoid/declarativeappletscript.h index f1082777c..1182a0113 100644 --- a/src/scriptengines/qml/plasmoid/declarativeappletscript.h +++ b/src/scriptengines/qml/plasmoid/declarativeappletscript.h @@ -45,6 +45,9 @@ public: void constraintsEvent(Plasma::Types::Constraints constraints); + void setUiReady(bool ready); + bool isUiReady() const; + public Q_SLOTS: void executeAction(const QString &name); void activate(); @@ -56,9 +59,11 @@ Q_SIGNALS: void formFactorChanged(); void locationChanged(); void contextChanged(); + void uiReadyChanged(bool ready); private: AppletInterface *m_interface; + bool m_uiReady; friend class AppletInterface; };