diff options
author | Javier S. Pedro <maemo@javispedro.com> | 2013-05-11 19:17:07 +0200 |
---|---|---|
committer | Javier S. Pedro <maemo@javispedro.com> | 2013-05-11 19:17:07 +0200 |
commit | bf083973efd101e05d75882b63aad9bdfa37dfbc (patch) | |
tree | c07769c2a82e4b5bba8d3d02558eb4c69a531001 | |
parent | bc899047089079dde323e84a57efe46ce6af653d (diff) | |
download | sowatch-bf083973efd101e05d75882b63aad9bdfa37dfbc.tar.gz sowatch-bf083973efd101e05d75882b63aad9bdfa37dfbc.zip |
store watchlets in model
-rw-r--r-- | libsowatch/declarativewatchlet.cpp | 1 | ||||
-rw-r--r-- | libsowatch/libsowatch.pro | 6 | ||||
-rw-r--r-- | libsowatch/sowatch.h | 2 | ||||
-rw-r--r-- | libsowatch/watch.cpp | 10 | ||||
-rw-r--r-- | libsowatch/watch.h | 6 | ||||
-rw-r--r-- | libsowatch/watchlet.cpp | 5 | ||||
-rw-r--r-- | libsowatch/watchlet.h | 6 | ||||
-rw-r--r-- | libsowatch/watchletsmodel.cpp | 116 | ||||
-rw-r--r-- | libsowatch/watchletsmodel.h | 53 | ||||
-rw-r--r-- | libsowatch/watchserver.cpp | 36 | ||||
-rw-r--r-- | libsowatch/watchserver.h | 10 | ||||
-rw-r--r-- | liveview/liveview.cpp | 72 | ||||
-rw-r--r-- | liveview/liveview.h | 11 | ||||
-rw-r--r-- | liveview/liveviewpaintengine.cpp | 6 | ||||
-rw-r--r-- | liveview/liveviewplugin.cpp | 1 | ||||
-rw-r--r-- | nekowatchlet/liveview.qml | 48 | ||||
-rw-r--r-- | nekowatchlet/nekowatchlet.pro | 3 | ||||
-rw-r--r-- | qmapwatchlet/compassview.cpp | 2 |
18 files changed, 349 insertions, 45 deletions
diff --git a/libsowatch/declarativewatchlet.cpp b/libsowatch/declarativewatchlet.cpp index 6508ce5..c223b8d 100644 --- a/libsowatch/declarativewatchlet.cpp +++ b/libsowatch/declarativewatchlet.cpp @@ -2,6 +2,7 @@ #include <QtDeclarative/QtDeclarative> #include "watchserver.h" #include "watch.h" +#include "notificationsmodel.h" #include "gconfkey.h" #include "declarativewatchwrapper.h" #include "declarativewatchlet.h" diff --git a/libsowatch/libsowatch.pro b/libsowatch/libsowatch.pro index ce0468e..e042e7a 100644 --- a/libsowatch/libsowatch.pro +++ b/libsowatch/libsowatch.pro @@ -34,7 +34,8 @@ SOURCES += \ allwatchscanner.cpp \ configkey.cpp \ gconfkey.cpp \ - notificationsmodel.cpp + notificationsmodel.cpp \ + watchletsmodel.cpp HEADERS += \ watchserver.h \ @@ -57,7 +58,8 @@ HEADERS += \ allwatchscanner.h \ configkey.h \ gconfkey.h \ - notificationsmodel.h + notificationsmodel.h \ + watchletsmodel.h TRANSLATIONS += libsowatch_en.ts libsowatch_es.ts diff --git a/libsowatch/sowatch.h b/libsowatch/sowatch.h index 31ee48a..4acea75 100644 --- a/libsowatch/sowatch.h +++ b/libsowatch/sowatch.h @@ -16,11 +16,13 @@ #include "weathernotification.h" #include "notificationprovider.h" #include "notificationplugininterface.h" +#include "notificationsmodel.h" #include "watchlet.h" #include "graphicswatchlet.h" #include "declarativewatchlet.h" #include "watchletplugininterface.h" +#include "watchletsmodel.h" #include "registry.h" #include "allwatchscanner.h" diff --git a/libsowatch/watch.cpp b/libsowatch/watch.cpp index e37cdf8..caf46c4 100644 --- a/libsowatch/watch.cpp +++ b/libsowatch/watch.cpp @@ -19,3 +19,13 @@ void Watch::vibrate(int msecs) /* The default implementation does nothing. */ Q_UNUSED(msecs); } + +void Watch::setWatchletsModel(WatchletsModel *model) +{ + Q_UNUSED(model); +} + +void Watch::setNotificationsModel(NotificationsModel *model) +{ + Q_UNUSED(model); +} diff --git a/libsowatch/watch.h b/libsowatch/watch.h index b0a2a93..27e3d04 100644 --- a/libsowatch/watch.h +++ b/libsowatch/watch.h @@ -13,6 +13,9 @@ namespace sowatch { +class WatchletsModel; +class NotificationsModel; + class SOWATCH_EXPORT Watch : public QObject, public QPaintDevice { Q_OBJECT @@ -57,6 +60,9 @@ public: virtual void queryCharging() = 0; virtual bool charging() const = 0; + virtual void setWatchletsModel(WatchletsModel *model); + virtual void setNotificationsModel(NotificationsModel *model); + public slots: /** Go back to the idle screen. */ virtual void displayIdleScreen() = 0; diff --git a/libsowatch/watchlet.cpp b/libsowatch/watchlet.cpp index 03ede41..0bcfa1d 100644 --- a/libsowatch/watchlet.cpp +++ b/libsowatch/watchlet.cpp @@ -48,6 +48,11 @@ void Watchlet::deactivate() emit deactivated(); } +void Watchlet::setWatchletsModel(WatchletsModel *model) +{ + Q_UNUSED(model); +} + void Watchlet::setNotificationsModel(NotificationsModel *model) { Q_UNUSED(model); diff --git a/libsowatch/watchlet.h b/libsowatch/watchlet.h index f32d495..f994447 100644 --- a/libsowatch/watchlet.h +++ b/libsowatch/watchlet.h @@ -2,6 +2,7 @@ #define SOWATCH_WATCHLET_H #include <QtCore/QObject> +#include <QtDeclarative/QtDeclarative> #include "sowatch_global.h" namespace sowatch @@ -9,6 +10,7 @@ namespace sowatch class Watch; class WatchServer; +class WatchletsModel; class Notification; class NotificationsModel; @@ -19,6 +21,7 @@ class SOWATCH_EXPORT Watchlet : public QObject Q_PROPERTY(bool active READ isActive NOTIFY activeChanged) public: + Watchlet(); Watchlet(Watch *watch, const QString& id); ~Watchlet(); @@ -33,6 +36,7 @@ public: virtual void deactivate(); // Some properties + virtual void setWatchletsModel(WatchletsModel *model); virtual void setNotificationsModel(NotificationsModel *model); virtual bool handlesNotification(Notification* notification) const; @@ -53,4 +57,6 @@ private: } +QML_DECLARE_TYPE(sowatch::Watchlet) + #endif // SOWATCH_WATCHLET_H diff --git a/libsowatch/watchletsmodel.cpp b/libsowatch/watchletsmodel.cpp new file mode 100644 index 0000000..9e06928 --- /dev/null +++ b/libsowatch/watchletsmodel.cpp @@ -0,0 +1,116 @@ +#include <QtCore/QDebug> + +#include "registry.h" +#include "watchletplugininterface.h" +#include "watchletsmodel.h" + +using namespace sowatch; + +WatchletsModel::WatchletsModel(QObject *parent) : + QAbstractListModel(parent) +{ + QHash<int, QByteArray> roles = roleNames(); + roles[TitleRole] = QByteArray("title"); + roles[ObjectRole] = QByteArray("object"); + setRoleNames(roles); +} + +int WatchletsModel::rowCount(const QModelIndex &parent) const +{ + return parent.isValid() ? 0 : _list.count(); +} + +QVariant WatchletsModel::data(const QModelIndex &index, int role) const +{ + if (!index.isValid()) return QVariant(); + const int row = index.row(); + if (row >= _list.size()) { + qWarning() << "Could not seek to" << row; + return QVariant(); + } + + const Watchlet *watchlet = _list.at(row); + const WatchletInfo& info = _info.at(row); + + switch (role) { + case Qt::DisplayRole: + return QVariant::fromValue(info.name); + case ObjectRole: + return QVariant::fromValue(const_cast<sowatch::Watchlet*>(watchlet)); + } + return QVariant(); +} + +int WatchletsModel::size() const +{ + return _list.size(); +} + +Watchlet * WatchletsModel::at(int position) const +{ + Q_ASSERT(position < _list.size()); + return const_cast<sowatch::Watchlet*>(_list.at(position)); +} + +void WatchletsModel::add(Watchlet *w) +{ + insert(_list.size(), w); +} + +void WatchletsModel::insert(int position, Watchlet *w) +{ + Q_ASSERT(position >= 0 && position <= _list.size()); + + beginInsertRows(QModelIndex(), position, position); + _list.insert(position, w); + _info.insert(position, getInfoForWatchlet(w)); + endInsertRows(); + + emit modelChanged(); +} + +void WatchletsModel::move(const Watchlet *w, int to) +{ + move(_list.indexOf(const_cast<Watchlet*>(w)), to); +} + +void WatchletsModel::move(int position, int to) +{ + Q_ASSERT(position >= 0 && position < _list.size()); + Q_ASSERT(to >= 0 && to < _list.size()); + + beginMoveRows(QModelIndex(), position, position, QModelIndex(), to); + _list.move(position, to); + _info.move(position, to); + endMoveRows(); + + emit modelChanged(); +} + +void WatchletsModel::remove(const Watchlet *w) +{ + remove(_list.indexOf(const_cast<Watchlet*>(w))); +} + +void WatchletsModel::remove(int position) +{ + Q_ASSERT(position >= 0 && position < _list.size()); + + beginRemoveRows(QModelIndex(), position, position); + _list.removeAt(position); + _info.removeAt(position); + endRemoveRows(); + + emit modelChanged(); +} + +WatchletsModel::WatchletInfo WatchletsModel::getInfoForWatchlet(const Watchlet *w) +{ + QString id = w->id(); + WatchletPluginInterface *plugin = Registry::registry()->getWatchletPlugin(id); + if (plugin) { + return plugin->describeWatchlet(id); + } else { + return WatchletInfo(); + } +} diff --git a/libsowatch/watchletsmodel.h b/libsowatch/watchletsmodel.h new file mode 100644 index 0000000..cdb6be4 --- /dev/null +++ b/libsowatch/watchletsmodel.h @@ -0,0 +1,53 @@ +#ifndef SOWATCH_WATCHLETSMODEL_H +#define SOWATCH_WATCHLETSMODEL_H + +#include <QtCore/QAbstractListModel> + +#include "watchlet.h" +#include "watchletplugininterface.h" + +namespace sowatch +{ + +class WatchletsModel : public QAbstractListModel +{ + Q_OBJECT + +public: + explicit WatchletsModel(QObject *parent = 0); + + enum DataRoles { + ObjectRole = Qt::UserRole, + TitleRole = Qt::DisplayRole + }; + + int rowCount(const QModelIndex &parent) const; + QVariant data(const QModelIndex &index, int role) const; + + int size() const; + Watchlet * at(int position) const; + + void add(Watchlet *w); + void insert(int position, Watchlet *w); + void move(const Watchlet *w, int to); + void move(int position, int to); + void remove(const Watchlet *w); + void remove(int position); + +signals: + void modelChanged(); + +protected: + typedef WatchletPluginInterface::WatchletInfo WatchletInfo; + + static WatchletInfo getInfoForWatchlet(const Watchlet *w); + +private: + QList<Watchlet*> _list; + QList<WatchletInfo> _info; + +}; + +} + +#endif // WATCHLETSMODEL_H diff --git a/libsowatch/watchserver.cpp b/libsowatch/watchserver.cpp index fa4011f..c82c3ee 100644 --- a/libsowatch/watchserver.cpp +++ b/libsowatch/watchserver.cpp @@ -1,8 +1,10 @@ #include <QtCore/QDebug> -#include "notificationprovider.h" #include "watch.h" #include "watchlet.h" +#include "watchletsmodel.h" +#include "notificationprovider.h" +#include "notificationsmodel.h" #include "watchserver.h" using namespace sowatch; @@ -12,6 +14,7 @@ WatchServer::WatchServer(Watch* watch, QObject* parent) : _nextWatchletButton(-1), _oldNotificationThreshold(300), _idleWatchlet(0), _notificationWatchlet(0), + _watchlets(new WatchletsModel(this)), _notifications(new NotificationsModel(this)), _activeWatchlet(0), _currentWatchlet(0), _currentWatchletIndex(-1), _syncTimeTimer(new QTimer(this)) @@ -20,10 +23,14 @@ WatchServer::WatchServer(Watch* watch, QObject* parent) : connect(_watch, SIGNAL(disconnected()), SLOT(handleWatchDisconnected())); connect(_watch, SIGNAL(idling()), SLOT(handleWatchIdling())); connect(_watch, SIGNAL(buttonPressed(int)), SLOT(handleWatchButtonPress(int))); + connect(_watch, SIGNAL(watchletRequested(QString)), + SLOT(handleWatchletRequested(QString))); connect(_syncTimeTimer, SIGNAL(timeout()), SLOT(syncTime())); _syncTimeTimer->setSingleShot(true); _syncTimeTimer->setInterval(24 * 3600 * 1000); // Once a day + + _watch->setWatchletsModel(_watchlets); } Watch* WatchServer::watch() @@ -94,10 +101,14 @@ void WatchServer::setNotificationWatchlet(Watchlet *watchlet) } } +const WatchletsModel * WatchServer::watchlets() const +{ + return _watchlets; +} + void WatchServer::addWatchlet(Watchlet *watchlet) { - Q_ASSERT(watchlet); - insertWatchlet(_watchlets.size(), watchlet); + insertWatchlet(_watchlets->size(), watchlet); } void WatchServer::insertWatchlet(int position, Watchlet *watchlet) @@ -110,20 +121,18 @@ void WatchServer::insertWatchlet(int position, Watchlet *watchlet) setWatchletProperties(watchlet); - _watchlets.insert(position, watchlet); + _watchlets->insert(position, watchlet); _watchletIds[id] = watchlet; } void WatchServer::moveWatchlet(const Watchlet *watchlet, int to) { const QString id = watchlet->id(); - int index = _watchlets.indexOf(const_cast<Watchlet*>(watchlet)); Q_ASSERT(watchlet->watch() == _watch); Q_ASSERT(_watchletIds.contains(id)); - Q_ASSERT(index >= 0); - _watchlets.move(index, to); + _watchlets->move(watchlet, to); } void WatchServer::removeWatchlet(const Watchlet *watchlet) @@ -139,7 +148,7 @@ void WatchServer::removeWatchlet(const Watchlet *watchlet) unsetWatchletProperties(const_cast<Watchlet*>(watchlet)); - _watchlets.removeAll(const_cast<Watchlet*>(watchlet)); + _watchlets->remove(watchlet); _watchletIds.remove(id); } @@ -261,12 +270,14 @@ void WatchServer::closeWatchlet() void WatchServer::setWatchletProperties(Watchlet *watchlet) { Q_ASSERT(watchlet->watch() == _watch); + watchlet->setWatchletsModel(_watchlets); watchlet->setNotificationsModel(_notifications); } void WatchServer::unsetWatchletProperties(Watchlet *watchlet) { Q_ASSERT(watchlet->watch() == _watch); + watchlet->setWatchletsModel(0); watchlet->setNotificationsModel(0); } @@ -301,11 +312,11 @@ void WatchServer::nextWatchlet() { qDebug() << "current watchlet index" << _currentWatchletIndex; _currentWatchletIndex++; - if (_currentWatchletIndex >= _watchlets.size() || _currentWatchletIndex < 0) { + if (_currentWatchletIndex >= _watchlets->size() || _currentWatchletIndex < 0) { _currentWatchletIndex = -1; closeWatchlet(); } else { - Watchlet* watchlet = _watchlets.at(_currentWatchletIndex); + Watchlet* watchlet = _watchlets->at(_currentWatchletIndex); openWatchlet(watchlet); } } @@ -396,6 +407,11 @@ void WatchServer::handleWatchButtonPress(int button) } } +void WatchServer::handleWatchletRequested(const QString &id) +{ + openWatchlet(id); +} + void WatchServer::handleNotificationChanged() { QObject *obj = sender(); diff --git a/libsowatch/watchserver.h b/libsowatch/watchserver.h index 43bb7d4..a1cda45 100644 --- a/libsowatch/watchserver.h +++ b/libsowatch/watchserver.h @@ -8,15 +8,16 @@ #include <QtCore/QTimer> #include "sowatch_global.h" -#include "notificationsmodel.h" +#include "notification.h" namespace sowatch { class Watch; class Watchlet; +class WatchletsModel; class NotificationProvider; -class WeatherNotification; +class NotificationsModel; class SOWATCH_EXPORT WatchServer : public QObject { @@ -41,6 +42,8 @@ public: Watchlet *notificationWatchlet(); void setNotificationWatchlet(Watchlet *watchlet); + const WatchletsModel * watchlets() const; + void addWatchlet(Watchlet *watchlet); void insertWatchlet(int position, Watchlet *watchlet); void moveWatchlet(const Watchlet *watchlet, int to); @@ -87,7 +90,7 @@ private: Watchlet *_notificationWatchlet; /** A list of watchlets, in order. */ - QList<Watchlet*> _watchlets; + WatchletsModel *_watchlets; /** Stores all the watchlets with a given watchled id. */ QMap<QString, Watchlet*> _watchletIds; @@ -123,6 +126,7 @@ private slots: void handleWatchDisconnected(); void handleWatchIdling(); void handleWatchButtonPress(int button); + void handleWatchletRequested(const QString& id); void handleNotificationChanged(); void handleNotificationDismissed(); diff --git a/liveview/liveview.cpp b/liveview/liveview.cpp index df2b099..aa8a472 100644 --- a/liveview/liveview.cpp +++ b/liveview/liveview.cpp @@ -11,6 +11,7 @@ QTM_USE_NAMESPACE LiveView::LiveView(ConfigKey* settings, QObject* parent) : BluetoothWatch(QBluetoothAddress(settings->value("address").toString()), parent), _settings(settings->getSubkey(QString(), this)), + _watchlets(0), _24hMode(settings->value("24h-mode", false).toBool()), _screenWidth(0), _screenHeight(0), _sendTimer(new QTimer(this)) @@ -31,6 +32,7 @@ LiveView::~LiveView() QPaintEngine* LiveView::paintEngine() const { if (!_paintEngine) { + qDebug() << "Constructing paint engine"; _paintEngine = new LiveViewPaintEngine; } @@ -120,7 +122,10 @@ bool LiveView::charging() const void LiveView::displayIdleScreen() { - + if (_mode != RootMenuMode) { + _mode = RootMenuMode; + refreshMenu(); + } } void LiveView::displayNotification(Notification *notification) @@ -130,6 +135,7 @@ void LiveView::displayNotification(Notification *notification) void LiveView::displayApplication() { + _mode = ApplicationMode; setMenuSize(0); // TODO } @@ -138,6 +144,17 @@ void LiveView::vibrate(int msecs) // TODO } +void LiveView::setWatchletsModel(WatchletsModel *model) +{ + if (_watchlets) { + disconnect(_watchlets, 0, this, 0); + } + _watchlets = model; + if (_watchlets) { + connect(_watchlets, SIGNAL(modelChanged()), SLOT(handleWatchletsChanged())); + } +} + QImage* LiveView::image() { return &_image; @@ -149,6 +166,7 @@ void LiveView::renderImage(int x, int y, const QImage &image) buffer.open(QIODevice::WriteOnly); if (image.save(&buffer, "PNG")) { displayBitmap(x, y, buffer.buffer()); + qDebug() << "render image " << x << 'x' << y << "size" << image.size(); } else { qWarning() << "Failed to encode image"; } @@ -161,6 +179,8 @@ void LiveView::clear() void LiveView::setupBluetoothWatch() { + _mode = RootMenuMode; + connect(_socket, SIGNAL(readyRead()), SLOT(handleDataReceived())); updateDisplayProperties(); refreshMenu(); @@ -173,11 +193,14 @@ void LiveView::desetupBluetoothWatch() void LiveView::refreshMenu() { - setMenuSize(3); + if (_mode == RootMenuMode) { + setMenuSize(3); + } } void LiveView::send(const Message &msg) { + Q_ASSERT(_connected); _sendingMsgs.enqueue(msg); if (!_sendTimer->isActive()) { _sendTimer->start(); @@ -248,7 +271,7 @@ void LiveView::enableLed(const QColor& color, unsigned short delay, unsigned sho { QByteArray data; - quint16 rgb; + quint16 rgb = 0; rgb |= ((color.red() & 0xF8) << 8); rgb |= ((color.green() & 0xFC) << 3); rgb |= ((color.blue() & 0xF8) >> 3); @@ -308,13 +331,6 @@ void LiveView::handleDeviceStatusChange(const Message &msg) if (msg.data.size() == 1) { DeviceStatus status = static_cast<DeviceStatus>(msg.data.at(0)); qDebug() << "liveview device status change" << status; - switch (status) { - case DeviceOn: - refreshMenu(); - break; - default: - break; - } } sendResponse(DeviceStatusChangeResponse, ResponseOk); } @@ -350,21 +366,8 @@ void LiveView::handleNavigation(const Message &msg) // TODO if (event == 32) { - qDebug() << "Navigation, sending bitmap"; - - setMenuSize(0); - - displayClear(); - - QFile f(SOWATCH_RESOURCES_DIR "/liveview/graphics/menu_missed_calls.png"); - f.open(QIODevice::ReadOnly); - displayBitmap(2, 22, f.readAll()); - f.close(); - - f.setFileName(SOWATCH_RESOURCES_DIR "/liveview/graphics/menu_messages.png"); - f.open(QIODevice::ReadOnly); - displayBitmap(12, 22, f.readAll()); - f.close(); + qDebug() << "Navigation, requesting watchlet"; + emit watchletRequested("com.javispedro.sowatch.neko"); } } @@ -414,8 +417,10 @@ void LiveView::handleDisplayProperties(const Message &msg) return; } - _screenWidth = msg.data[0]; - _screenHeight = msg.data[1]; + _screenWidth = static_cast<unsigned char>(msg.data[0]); + _screenHeight = static_cast<unsigned char>(msg.data[1]); + + qDebug() << "LiveView display properties:" << _screenWidth << 'x' << _screenHeight; // Recreate the display image _image = QImage(_screenWidth, _screenHeight, QImage::Format_RGB16); @@ -531,7 +536,11 @@ void LiveView::handleSendTimerTick() packet.replace(HEADER_SIZE, data_size, msg.data); #if PROTOCOL_DEBUG - qDebug() << "sending" << packet.toHex(); + if (packet.size() < 20) { + qDebug() << "sending" << packet.toHex(); + } else { + qDebug() << "sending" << packet.left(20).toHex() << "..."; + } #endif _socket->write(packet); @@ -542,3 +551,10 @@ void LiveView::handleSendTimerTick() _sendTimer->stop(); } } + +void LiveView::handleWatchletsChanged() +{ + if (_connected) { + refreshMenu(); + } +} diff --git a/liveview/liveview.h b/liveview/liveview.h index 4a2e165..65ce523 100644 --- a/liveview/liveview.h +++ b/liveview/liveview.h @@ -41,6 +41,8 @@ public: void vibrate(int msecs); + void setWatchletsModel(WatchletsModel *model); + // Only for application mode QImage* image(); /** Render a image in a certain position. */ @@ -98,6 +100,11 @@ protected: MenuOther = 1 }; + enum Mode { + RootMenuMode = 0, + ApplicationMode + }; + struct Message { MessageType type; QByteArray data; @@ -137,9 +144,11 @@ protected: private slots: void handleDataReceived(); void handleSendTimerTick(); + void handleWatchletsChanged(); private: ConfigKey *_settings; + WatchletsModel *_watchlets; bool _24hMode : 1; @@ -147,6 +156,8 @@ private: int _screenHeight; QStringList _buttons; + Mode _mode; + // Required by QPaintDevice mutable LiveViewPaintEngine* _paintEngine; QImage _image; diff --git a/liveview/liveviewpaintengine.cpp b/liveview/liveviewpaintengine.cpp index 1785d62..f774884 100644 --- a/liveview/liveviewpaintengine.cpp +++ b/liveview/liveviewpaintengine.cpp @@ -1,11 +1,13 @@ +#include <QtCore/QDebug> + #include "liveviewpaintengine.h" using namespace sowatch; LiveViewPaintEngine::LiveViewPaintEngine() : - WatchPaintEngine() + WatchPaintEngine(), _watch(0) { - + qDebug() << "SE CCONS"; } bool LiveViewPaintEngine::begin(QPaintDevice *pdev) diff --git a/liveview/liveviewplugin.cpp b/liveview/liveviewplugin.cpp index c7d862e..1f34949 100644 --- a/liveview/liveviewplugin.cpp +++ b/liveview/liveviewplugin.cpp @@ -31,6 +31,7 @@ WatchScanner* LiveViewPlugin::getScanner(QObject *parent) QUrl LiveViewPlugin::getConfigQmlUrl(const QString &driver) { + Q_UNUSED(driver); return QUrl(); } diff --git a/nekowatchlet/liveview.qml b/nekowatchlet/liveview.qml new file mode 100644 index 0000000..a9c5712 --- /dev/null +++ b/nekowatchlet/liveview.qml @@ -0,0 +1,48 @@ +import QtQuick 1.0 + +Item { + Neko { + id: neko + running: watch.active + + targetX: goal.x + targetY: goal.y + } + + Rectangle { + id: goal + width: 2 + height: 2 + color: "black" + + Behavior on x { SmoothedAnimation { velocity: 80; }} + Behavior on y { SmoothedAnimation { velocity: 80; }} + } + + function goToRandomPosition() { + goal.x = 16 + Math.floor(Math.random() * (width - 32)); + goal.y = 16 + Math.floor(Math.random() * (height - 32)); + } + + function goToSleep() { + neko.state = "SLEEPING"; + } + + Connections { + target: watch + onActiveChanged: { + if (watch.active) { + goToSleep(); + } + } + + onButtonPressed : { + switch (button) { + case 1: + case 2: + goToRandomPosition(); + break; + } + } + } +} diff --git a/nekowatchlet/nekowatchlet.pro b/nekowatchlet/nekowatchlet.pro index b45979a..fd9321a 100644 --- a/nekowatchlet/nekowatchlet.pro +++ b/nekowatchlet/nekowatchlet.pro @@ -24,3 +24,6 @@ unix:!symbian { } INSTALLS += target qml_files } + +OTHER_FILES += \ + liveview.qml diff --git a/qmapwatchlet/compassview.cpp b/qmapwatchlet/compassview.cpp index 7ee2853..ae3147b 100644 --- a/qmapwatchlet/compassview.cpp +++ b/qmapwatchlet/compassview.cpp @@ -75,7 +75,9 @@ qreal CompassView::currentAltitude() const void CompassView::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { + Q_UNUSED(option); Q_UNUSED(widget); + // Now render the arrow indicator const int centerX = _size.width() / 2, centerY = _size.height() / 2; |