reparent applet graphicobject to containment graphicobject

This commit is contained in:
Marco Martin 2013-02-05 11:59:14 +01:00
parent b5a65921d0
commit 2734ceaebb
6 changed files with 18 additions and 5 deletions

View File

@ -469,7 +469,12 @@ QVariantList ContainmentInterface::availableScreenRegion(int id) const
void ContainmentInterface::appletAddedForward(Plasma::Applet *applet, const QPointF &pos) void ContainmentInterface::appletAddedForward(Plasma::Applet *applet, const QPointF &pos)
{ {
emit appletAdded(applet, pos); qDebug()<<"Applet added:"<<applet<<applet->name()<<applet->graphicObject();
if (applet && containment()->graphicObject() && applet->graphicObject()) {
applet->graphicObject()->setProperty("visible", false);
applet->graphicObject()->setProperty("parent", QVariant::fromValue(containment()->graphicObject()));
}
emit appletAdded(applet->graphicObject(), pos);
} }
void ContainmentInterface::appletRemovedForward(Plasma::Applet *applet) void ContainmentInterface::appletRemovedForward(Plasma::Applet *applet)

View File

@ -120,7 +120,7 @@ bool DeclarativeAppletScript::init()
setupObjects(); setupObjects();
m_qmlObject->completeInitialization(); m_qmlObject->completeInitialization();
a->setGraphicObject(m_qmlObject->rootObject()); a->setGraphicObject(m_qmlObject->rootObject());
qDebug()<<"Graphic object created:"<<a<<a->graphicObject();
return true; return true;
} }

View File

@ -51,3 +51,4 @@ install(TARGETS testplasma2 ${INSTALL_TARGETS_DEFAULT_ARGS})
add_subdirectory(qmlpackages) add_subdirectory(qmlpackages)
installPackage(testcontainment org.kde.testcontainment) installPackage(testcontainment org.kde.testcontainment)
installPackage(testapplet org.kde.testapplet)

View File

@ -53,7 +53,7 @@ void DesktopCorona::loadDefaultLayout()
Plasma::Containment *cont = addContainment("org.kde.testcontainment"); Plasma::Containment *cont = addContainment("org.kde.testcontainment");
cont->setScreen(0); cont->setScreen(0);
qDebug() << containmentForScreen(0); qDebug() << containmentForScreen(0);
Plasma::Applet *appl = cont->addApplet("foo"); Plasma::Applet *appl = cont->addApplet("org.kde.testapplet");
qDebug() << "Containment:" << cont << cont->name(); qDebug() << "Containment:" << cont << cont->name();
qDebug() << "Applet:" << appl->name() << appl; qDebug() << "Applet:" << appl->name() << appl;
} }

View File

@ -26,7 +26,14 @@ Rectangle {
width: 640 width: 640
height: 480 height: 480
property Item containment Connections {
target: plasmoid
onAppletAdded: {
print("Applet added: " + applet)
applet.parent = root
applet.visible = true
}
}
PlasmaCore.Svg { PlasmaCore.Svg {
id: actionssvg id: actionssvg

View File

@ -36,7 +36,7 @@ View::View(QWindow *parent)
setResizeMode(View::SizeRootObjectToView); setResizeMode(View::SizeRootObjectToView);
setSource(QUrl::fromLocalFile(m_package.filePath("mainscript"))); setSource(QUrl::fromLocalFile(m_package.filePath("mainscript")));
show();rootContext()->setContextProperty("plasmoid", this); show();
} }
View::~View() View::~View()