summaryrefslogtreecommitdiff
path: root/libsowatch/declarativewatchlet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libsowatch/declarativewatchlet.cpp')
-rw-r--r--libsowatch/declarativewatchlet.cpp27
1 files changed, 24 insertions, 3 deletions
diff --git a/libsowatch/declarativewatchlet.cpp b/libsowatch/declarativewatchlet.cpp
index ca60fb0..dbd4759 100644
--- a/libsowatch/declarativewatchlet.cpp
+++ b/libsowatch/declarativewatchlet.cpp
@@ -29,6 +29,11 @@ DeclarativeWatchlet::DeclarativeWatchlet(WatchServer* server, const QString& id)
_engine->rootContext()->setContextProperty("watch", _wrapper);
}
+DeclarativeWatchlet::~DeclarativeWatchlet()
+{
+
+}
+
void DeclarativeWatchlet::setSource(const QUrl &url)
{
if (_item) {
@@ -64,6 +69,11 @@ QDeclarativeContext* DeclarativeWatchlet::rootContext()
return _engine->rootContext();
}
+QDeclarativeItem* DeclarativeWatchlet::rootObject()
+{
+ return _item;
+}
+
void DeclarativeWatchlet::activate()
{
GraphicsWatchlet::activate();
@@ -76,6 +86,19 @@ void DeclarativeWatchlet::deactivate()
GraphicsWatchlet::deactivate();
}
+void DeclarativeWatchlet::setRootObject(QDeclarativeItem *item)
+{
+ Q_ASSERT(_item == 0); /* This function should not be called with a current object. */
+ if (!item) {
+ qWarning() << "QML root object is not a declarative item?";
+ return;
+ }
+
+ _item = item;
+ // TODO Resize _item
+ scene()->addItem(_item);
+}
+
void DeclarativeWatchlet::handleComponentStatus(QDeclarativeComponent::Status status)
{
QObject *obj;
@@ -93,9 +116,7 @@ void DeclarativeWatchlet::handleComponentStatus(QDeclarativeComponent::Status st
qWarning() << _component->errors();
return;
}
- Q_ASSERT(_item == 0);
- _item = qobject_cast<QDeclarativeItem*>(obj);
- scene()->addItem(_item);
+ setRootObject(qobject_cast<QDeclarativeItem*>(obj));
break;
case QDeclarativeComponent::Error:
qWarning() << "QML has errors found while loading:";