summaryrefslogtreecommitdiff
path: root/libsowatch/declarativewatchlet.cpp
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2011-09-27 04:51:30 +0200
committerJavier S. Pedro <maemo@javispedro.com>2011-09-27 04:51:30 +0200
commita644a7cc6749f8dd5ca20589ee6e59acc2892b3e (patch)
treeb995528dc14d1f58d9d7c958d1eaad855b2a2412 /libsowatch/declarativewatchlet.cpp
parent0822b88738e00625efd27ccca9119885272924d2 (diff)
downloadsowatch-a644a7cc6749f8dd5ca20589ee6e59acc2892b3e.tar.gz
sowatch-a644a7cc6749f8dd5ca20589ee6e59acc2892b3e.zip
new qmafw watchlet
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:";