From d9f140ec45f91a8567b6d8e2ce69fe853ae8b3a9 Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Mon, 15 Sep 2014 01:53:44 +0200 Subject: minimal notifications --- src/controller.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/controller.cpp') diff --git a/src/controller.cpp b/src/controller.cpp index f4a2b09..bd2b68b 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -1,5 +1,8 @@ #include #include +#include + +#include #include "controller.h" @@ -25,6 +28,7 @@ Controller::Controller(const QString &settingsPrefix, QQuickView *view, QObject _curPage = _settings->value(setting_cur_page).toInt(); connect(_settings, &MDConfGroup::valueChanged, this, &Controller::handleSettingChanged); + connect(_monitor, &NotificationMonitor::incomingNotification, this, &Controller::handleIncomingNotification); connect(_widgets, &QAbstractItemModel::dataChanged, this, &Controller::handleWidgetChanged); connectToAddress(_settings->value(setting_address).toString()); @@ -189,6 +193,23 @@ void Controller::handleMetaWatchBatteryStatus(bool charging, int charge) } } +void Controller::handleIncomingNotification(const QString &sender, const QIcon &icon, const QString &summary, const QString &body) +{ + QImage image(96, 96, QImage::Format_MonoLSB); + QPainter p(&image); + + p.drawImage(0, 0, QImage(SailfishApp::pathTo("qml/watch/notification.png").toLocalFile())); + icon.paint(&p, 0, 96 - 24, 24, 24, Qt::AlignLeft | Qt::AlignBottom); + + p.drawText(QRect(2, 26, 92, 55), Qt::AlignLeft | Qt::AlignTop, body); + + image.invertPixels(); + + _metawatch->sendModeImage(MetaWatch::WatchModeNotification, image); + _metawatch->updateLcdDisplayMode(MetaWatch::WatchModeNotification); + _metawatch->setVibrateMode(true, 500, 500, 2); +} + void Controller::handleWidgetChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector &roles) { if (roles.indexOf(WidgetInfoModel::UrlRole) >= 0) { -- cgit v1.2.3