From 22918af6b444590e06a2eba0d586da4a301a68de Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Tue, 19 Feb 2013 14:47:11 +0100 Subject: [PATCH] better organization of DeclarativeAppletScript::init( --- .../qml/plasmoid/declarativeappletscript.cpp | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/scriptengines/qml/plasmoid/declarativeappletscript.cpp b/src/scriptengines/qml/plasmoid/declarativeappletscript.cpp index 145f60dcc..f45578e3a 100644 --- a/src/scriptengines/qml/plasmoid/declarativeappletscript.cpp +++ b/src/scriptengines/qml/plasmoid/declarativeappletscript.cpp @@ -68,9 +68,13 @@ DeclarativeAppletScript::~DeclarativeAppletScript() bool DeclarativeAppletScript::init() { - Plasma::Containment *pc = qobject_cast(applet()); + Plasma::Applet *a = applet(); + Plasma::Containment *pc = qobject_cast(a); if (pc) { + m_interface = new ContainmentInterface(this); + + //Try to determine the containment type QString type = pc->pluginInfo().property("X-Plasma-ContainmentType").toString(); if (type == "DesktopContainment") { @@ -82,8 +86,19 @@ bool DeclarativeAppletScript::init() } else if (type == "CustomPanelContainment") { pc->setContainmentType(Plasma::CustomPanelContainment); } + //fail? so it's a normal Applet + } else { + m_interface = new AppletInterface(this); } + m_interface->setParent(this); + // set the graphicObject dynamic property on applet + a->setProperty("graphicObject", QVariant::fromValue(m_interface)); + + connect(applet(), SIGNAL(activate()), + this, SLOT(activate())); + + m_qmlObject = new QmlObject(applet()); m_qmlObject->setInitializationDelayed(true); //FIXME: what replaced this? @@ -124,19 +139,6 @@ bool DeclarativeAppletScript::init() setLaunchErrorMessage(reason); } - Plasma::Applet *a = applet(); - - if (pc) { - m_interface = new ContainmentInterface(this); - //fail? so it's a normal Applet - } else { - m_interface = new AppletInterface(this); - } - - m_interface->setParent(this); - - connect(applet(), SIGNAL(activate()), - this, SLOT(activate())); setupObjects(); @@ -144,8 +146,6 @@ bool DeclarativeAppletScript::init() m_interface->setUiObject(m_qmlObject->rootObject()); - // set the graphicObject dynamic property on applet - a->setProperty("graphicObject", QVariant::fromValue(m_interface)); qDebug() << "Graphic object created:" << a << a->property("graphicObject"); //Create the ToolBox