replace graphicObject with a dynamic property

This commit is contained in:
Marco Martin 2013-02-05 13:15:32 +01:00
parent 2734ceaebb
commit 7f654acfd2
7 changed files with 24 additions and 46 deletions

View File

@ -203,20 +203,6 @@ uint Applet::id() const
return d->appletId;
}
QObject *Applet::graphicObject() const
{
return d->graphicObject;
}
void Applet::setGraphicObject(QObject *obj)
{
if (d->graphicObject == obj) {
return;
}
d->graphicObject = obj;
emit graphicObjectChanged();
}
void Applet::save(KConfigGroup &g) const
{
if (d->transient) {

View File

@ -94,13 +94,6 @@ class PLASMA_EXPORT Applet : public QObject
*/
uint id() const;
/**
* @since: 5.0
* A pointer to the graphical representation of this applet
*/
QObject *graphicObject() const;
void setGraphicObject(QObject *obj);
/**
* Returns the KConfigGroup to access the applets configuration.
*
@ -576,10 +569,6 @@ class PLASMA_EXPORT Applet : public QObject
bool hasValidAssociatedApplication() const;
Q_SIGNALS:
/**
* emitted when/if the graphic representation of the applet changes
*/
void graphicObjectChanged();
/**
* This signal indicates that an application launch, window

View File

@ -71,7 +71,6 @@ AppletPrivate::AppletPrivate(KService::Ptr service, const KPluginInfo *info, int
itemStatus(UnknownStatus),
preferredSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored),
modificationsTimer(0),
graphicObject(0),
hasConfigurationInterface(false),
failed(false),
isContainment(false),

View File

@ -173,9 +173,6 @@ public:
QBasicTimer constraintsTimer;
QBasicTimer *modificationsTimer;
// Everything graphics related that remains in Applet
QObject *graphicObject;
// a great green field of booleans :)
bool hasConfigurationInterface : 1;
bool failed : 1;

View File

@ -469,17 +469,23 @@ QVariantList ContainmentInterface::availableScreenRegion(int id) const
void ContainmentInterface::appletAddedForward(Plasma::Applet *applet, const QPointF &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()));
QObject *appletGraphicObject = applet->property("graphicObject").value<QObject *>();
QObject *contGraphicObject = containment()->property("graphicObject").value<QObject *>();
qDebug() << "Applet added:" << applet << applet->name() << appletGraphicObject;
if (applet && contGraphicObject && appletGraphicObject) {
appletGraphicObject->setProperty("visible", false);
appletGraphicObject->setProperty("parent", QVariant::fromValue(contGraphicObject));
}
emit appletAdded(applet->graphicObject(), pos);
emit appletAdded(appletGraphicObject, pos);
}
void ContainmentInterface::appletRemovedForward(Plasma::Applet *applet)
{
emit appletRemoved(applet);
QObject *appletGraphicObject = applet->property("graphicObject").value<QObject *>();
emit appletRemoved(appletGraphicObject);
}
QString ContainmentInterface::activityName() const

View File

@ -118,9 +118,11 @@ bool DeclarativeAppletScript::init()
this, SLOT(activate()));
setupObjects();
m_qmlObject->completeInitialization();
a->setGraphicObject(m_qmlObject->rootObject());
qDebug()<<"Graphic object created:"<<a<<a->graphicObject();
a->setProperty("graphicObject", QVariant::fromValue(m_qmlObject->rootObject()));
qDebug() << "Graphic object created:" << a << a->property("graphicObject");
return true;
}

View File

@ -58,16 +58,15 @@ void View::setContainment(Plasma::Containment *cont)
return;
}
if (m_containment.data()->graphicObject()) {
qDebug() << "using as graphic containment" << m_containment.data()->graphicObject()<<m_containment.data();
if (!m_containment || !m_containment.data()->graphicObject()) {
qWarning() << "Containment not valid (yet?)";
return;
}
QObject *graphicObject = m_containment.data()->property("graphicObject").value<QObject *>();
if (graphicObject) {
qDebug() << "using as graphic containment" << graphicObject << m_containment.data();
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()));
graphicObject->setProperty("visible", false);
graphicObject->setProperty("parent", QVariant::fromValue(rootObject()));
rootObject()->setProperty("containment", QVariant::fromValue(graphicObject));
} else {
qWarning() << "Containment graphic object not valid";
}
}