diff options
author | Javier S. Pedro <maemo@javispedro.com> | 2012-08-13 21:31:52 +0200 |
---|---|---|
committer | Javier S. Pedro <maemo@javispedro.com> | 2012-08-13 21:31:52 +0200 |
commit | abdf3b1eaba8151f1b8e862750c38cb7a5411d2a (patch) | |
tree | 69e314d80a332295dd5475fc91f45c2078eaead5 /libsowatch/declarativewatchlet.cpp | |
parent | 51701e30d710ad016ddf2d306cdd7be122ddf25b (diff) | |
download | sowatch-abdf3b1eaba8151f1b8e862750c38cb7a5411d2a.tar.gz sowatch-abdf3b1eaba8151f1b8e862750c38cb7a5411d2a.zip |
make watchsimulator work again
Diffstat (limited to 'libsowatch/declarativewatchlet.cpp')
-rw-r--r-- | libsowatch/declarativewatchlet.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/libsowatch/declarativewatchlet.cpp b/libsowatch/declarativewatchlet.cpp index 68d6c28..510a68f 100644 --- a/libsowatch/declarativewatchlet.cpp +++ b/libsowatch/declarativewatchlet.cpp @@ -1,6 +1,7 @@ #include <QtCore/QDebug> #include <QtDeclarative/QtDeclarative> #include "watchserver.h" +#include "watch.h" #include "gconfkey.h" #include "declarativewatchwrapper.h" #include "declarativewatchlet.h" @@ -17,6 +18,8 @@ DeclarativeWatchlet::DeclarativeWatchlet(WatchServer* server, const QString& id) _wrapper(0) { setScene(new QGraphicsScene(this)); + scene()->setItemIndexMethod(QGraphicsScene::NoIndex); + scene()->setStickyFocus(true); if (!_registered) { qmlRegisterUncreatableType<DeclarativeWatchWrapper>("com.javispedro.sowatch", 1, 0, @@ -27,7 +30,13 @@ DeclarativeWatchlet::DeclarativeWatchlet(WatchServer* server, const QString& id) } _engine = new QDeclarativeEngine(this); +#if !defined(QT_NO_DEBUG) + QString qmlDir = QDir::current().absoluteFilePath(SOWATCH_QML_DIR); + qDebug() << "Using debug QML import path: " << qmlDir; _engine->addImportPath(SOWATCH_QML_DIR); +#else + _engine->addImportPath(SOWATCH_QML_DIR); +#endif _wrapper = new DeclarativeWatchWrapper(server, server->watch(), this); _engine->rootContext()->setContextProperty("watch", _wrapper); @@ -80,6 +89,19 @@ QDeclarativeItem* DeclarativeWatchlet::rootObject() void DeclarativeWatchlet::activate() { + // Now we certainly know the watch's area, so it is a good moment to + // resize the root object if needed. + if (_item) { + Watch *watch = this->watch(); + if (!qFuzzyCompare(watch->width(), _item->width())) { + qDebug() << "Resizing root object to width" << watch->width(); + _item->setWidth(watch->width()); + } + if (!qFuzzyCompare(watch->height(), _item->height())) { + qDebug() << "Resizing root object to height" << watch->width(); + _item->setHeight(watch->height()); + } + } GraphicsWatchlet::activate(); _wrapper->activate(); } @@ -99,7 +121,6 @@ void DeclarativeWatchlet::setRootObject(QDeclarativeItem *item) } _item = item; - // TODO Resize _item scene()->addItem(_item); } |