From b5a65921d089c5aaab1eedf0d3e11a6d4f1d3c90 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Tue, 5 Feb 2013 11:03:40 +0100 Subject: [PATCH] get rid of the ugly async syncgraphicObject() --- .../qml/plasmoid/declarativeappletscript.cpp | 6 ++++- shell/view.cpp | 25 +++++++------------ shell/view.h | 3 --- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/scriptengines/qml/plasmoid/declarativeappletscript.cpp b/scriptengines/qml/plasmoid/declarativeappletscript.cpp index bbffb78ea..63e1fbc8b 100644 --- a/scriptengines/qml/plasmoid/declarativeappletscript.cpp +++ b/scriptengines/qml/plasmoid/declarativeappletscript.cpp @@ -91,6 +91,7 @@ bool DeclarativeAppletScript::init() engine->setNetworkAccessManagerFactory(new PackageAccessManagerFactory(&package(), &m_auth)); m_qmlObject->setQmlPath(mainScript()); + if (!m_qmlObject->engine() || !m_qmlObject->engine()->rootContext() || !m_qmlObject->engine()->rootContext()->isValid() || m_qmlObject->mainComponent()->isError()) { QString reason; @@ -102,7 +103,9 @@ bool DeclarativeAppletScript::init() } Plasma::Applet *a = applet(); + Plasma::Containment *cont = qobject_cast(a); + if (cont) { m_interface = new ContainmentInterface(this); @@ -115,6 +118,8 @@ bool DeclarativeAppletScript::init() this, SLOT(activate())); setupObjects(); + m_qmlObject->completeInitialization(); + a->setGraphicObject(m_qmlObject->rootObject()); return true; } @@ -123,7 +128,6 @@ void DeclarativeAppletScript::qmlCreationFinished() { //If it's a popupapplet and the root object has a "compactRepresentation" component, use that instead of the icon Plasma::Applet *a = applet(); - a->setGraphicObject(m_qmlObject->rootObject()); //TODO: access rootItem from m_interface //m_self->setProperty("rootItem", QVariant::fromValue(m_qmlObject->rootObject())); diff --git a/shell/view.cpp b/shell/view.cpp index c83eb76db..233a1b3a4 100644 --- a/shell/view.cpp +++ b/shell/view.cpp @@ -58,10 +58,16 @@ void View::setContainment(Plasma::Containment *cont) return; } - connect(cont, SIGNAL(graphicObjectChanged()), this, SLOT(syncGraphicObject())); - if (m_containment.data()->graphicObject()) { - syncGraphicObject(); + qDebug() << "using as graphic containment" << m_containment.data()->graphicObject()<graphicObject()) { + qWarning() << "Containment not valid (yet?)"; + return; + } + + m_containment.data()->graphicObject()->setProperty("visible", false); + m_containment.data()->graphicObject()->setProperty("parent", QVariant::fromValue(rootObject())); + rootObject()->setProperty("containment", QVariant::fromValue(m_containment.data()->graphicObject())); } } @@ -70,17 +76,4 @@ Plasma::Containment *View::containment() const return m_containment.data(); } -void View::syncGraphicObject() -{ - qDebug() << "using as graphic containment" << m_containment.data()->graphicObject()<graphicObject()) { - qWarning() << "Containment not valid (yet?)"; - return; - } - - m_containment.data()->graphicObject()->setProperty("visible", false); - m_containment.data()->graphicObject()->setProperty("parent", QVariant::fromValue(rootObject())); - rootObject()->setProperty("containment", QVariant::fromValue(m_containment.data()->graphicObject())); -} - #include "moc_view.cpp" diff --git a/shell/view.h b/shell/view.h index cb52187ea..6bf6dbbe5 100644 --- a/shell/view.h +++ b/shell/view.h @@ -37,9 +37,6 @@ public: void setContainment(Plasma::Containment *cont); Plasma::Containment *containment() const; -protected Q_SLOTS: - void syncGraphicObject(); - private: Plasma::Package m_package; QWeakPointer m_containment;