fix delayed loading of containments
This commit is contained in:
parent
336055edc5
commit
0d9bc6d7be
@ -46,11 +46,6 @@ ContainmentInterface::ContainmentInterface(DeclarativeAppletScript *parent)
|
|||||||
setAcceptedMouseButtons(Qt::RightButton);
|
setAcceptedMouseButtons(Qt::RightButton);
|
||||||
|
|
||||||
qmlRegisterType<ContainmentInterface>();
|
qmlRegisterType<ContainmentInterface>();
|
||||||
}
|
|
||||||
|
|
||||||
void ContainmentInterface::init()
|
|
||||||
{
|
|
||||||
AppletInterface::init();
|
|
||||||
|
|
||||||
connect(containment(), &Plasma::Containment::appletRemoved,
|
connect(containment(), &Plasma::Containment::appletRemoved,
|
||||||
this, &ContainmentInterface::appletRemovedForward);
|
this, &ContainmentInterface::appletRemovedForward);
|
||||||
@ -67,16 +62,25 @@ void ContainmentInterface::init()
|
|||||||
connect(containment()->corona(), &Plasma::Corona::availableScreenRegionChanged,
|
connect(containment()->corona(), &Plasma::Corona::availableScreenRegionChanged,
|
||||||
this, &ContainmentInterface::availableScreenRegionChanged);
|
this, &ContainmentInterface::availableScreenRegionChanged);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContainmentInterface::init()
|
||||||
|
{
|
||||||
|
AppletInterface::init();
|
||||||
|
|
||||||
//HACK, why appletAddedForward doesn't get called?
|
|
||||||
foreach (Plasma::Applet *applet, containment()->applets()) {
|
|
||||||
appletAddedForward(applet);
|
|
||||||
}
|
|
||||||
foreach (QObject *appletObj, m_appletInterfaces) {
|
foreach (QObject *appletObj, m_appletInterfaces) {
|
||||||
AppletInterface *applet = qobject_cast<AppletInterface *>(appletObj);
|
AppletInterface *applet = qobject_cast<AppletInterface *>(appletObj);
|
||||||
|
if (applet) {
|
||||||
if (!applet->qmlObject()) {
|
if (!applet->qmlObject()) {
|
||||||
applet->init();
|
applet->init();
|
||||||
}
|
}
|
||||||
|
m_appletInterfaces << applet;
|
||||||
|
emit appletAdded(applet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_appletInterfaces.isEmpty()) {
|
||||||
|
emit appletsChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,17 +146,22 @@ QVariantList ContainmentInterface::availableScreenRegion(int id) const
|
|||||||
|
|
||||||
void ContainmentInterface::appletAddedForward(Plasma::Applet *applet)
|
void ContainmentInterface::appletAddedForward(Plasma::Applet *applet)
|
||||||
{
|
{
|
||||||
|
if (!applet) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QObject *appletGraphicObject = applet->property("graphicObject").value<QObject *>();
|
QObject *appletGraphicObject = applet->property("graphicObject").value<QObject *>();
|
||||||
QObject *contGraphicObject = containment()->property("graphicObject").value<QObject *>();
|
QObject *contGraphicObject = containment()->property("graphicObject").value<QObject *>();
|
||||||
|
|
||||||
qDebug() << "Applet added:" << applet << applet->title() << appletGraphicObject;
|
qDebug() << "Applet added on containment:" << containment()->title() << contGraphicObject
|
||||||
|
<< "Applet: " << applet << applet->title() << appletGraphicObject;
|
||||||
|
|
||||||
if (applet && contGraphicObject && appletGraphicObject) {
|
if (contGraphicObject && appletGraphicObject) {
|
||||||
appletGraphicObject->setProperty("visible", false);
|
appletGraphicObject->setProperty("visible", false);
|
||||||
appletGraphicObject->setProperty("parent", QVariant::fromValue(contGraphicObject));
|
appletGraphicObject->setProperty("parent", QVariant::fromValue(contGraphicObject));
|
||||||
|
|
||||||
//if an appletGraphicObject is not set, we have to display some error message
|
//if an appletGraphicObject is not set, we have to display some error message
|
||||||
} else if (applet && contGraphicObject) {
|
} else if (contGraphicObject) {
|
||||||
QObject *errorUi = qmlObject()->createObjectFromSource(QUrl::fromLocalFile(containment()->corona()->package().filePath("appleterror")));
|
QObject *errorUi = qmlObject()->createObjectFromSource(QUrl::fromLocalFile(containment()->corona()->package().filePath("appleterror")));
|
||||||
|
|
||||||
if (errorUi) {
|
if (errorUi) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user