root qml item accessible from plasmoid.rootItem

this way objects in compactRepresentation can access the root object
properties as plasmoid.rootItem.propertyName
This commit is contained in:
Marco Martin 2013-08-22 14:54:00 +02:00
parent 9745fe5535
commit dbc02cd44b
2 changed files with 16 additions and 0 deletions

View File

@ -135,6 +135,7 @@ void AppletInterface::init()
m_qmlObject->engine()->rootContext()->setContextProperty("plasmoid", this);
m_qmlObject->completeInitialization();
emit rootItemChanged();
qDebug() << "Graphic object created:" << applet() << applet()->property("graphicObject");
@ -208,6 +209,14 @@ QObject* AppletInterface::configuration() const
return m_configuration;
}
QObject* AppletInterface::rootItem() const
{
if (!m_qmlObject) {
return 0;
}
return m_qmlObject->rootObject();
}
QString AppletInterface::icon() const
{
return applet()->icon();

View File

@ -50,6 +50,10 @@ class AppletInterface : public QQuickItem
{
Q_OBJECT
/**
* The QML root object defined in the applet main.qml
*/
Q_PROPERTY(QObject *rootItem READ rootItem NOTIFY rootItemChanged)
Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)
//TODO: writable icon
Q_PROPERTY(QString icon READ icon CONSTANT)
@ -116,6 +120,8 @@ public:
//PROPERTY ACCESSORS-------------------------------------------------------------------
QObject *rootItem() const;
QString icon() const;
QString title() const;
@ -176,6 +182,7 @@ Q_SIGNALS:
void backgroundHintsChanged();
void busyChanged();
void expandedChanged();
void rootItemChanged();
void minimumWidthChanged();
void minimumHeightChanged();