summaryrefslogtreecommitdiff
path: root/src/controller.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/controller.cpp')
-rw-r--r--src/controller.cpp40
1 files changed, 38 insertions, 2 deletions
diff --git a/src/controller.cpp b/src/controller.cpp
index bd2b68b..70be33a 100644
--- a/src/controller.cpp
+++ b/src/controller.cpp
@@ -198,13 +198,49 @@ void Controller::handleIncomingNotification(const QString &sender, const QIcon &
QImage image(96, 96, QImage::Format_MonoLSB);
QPainter p(&image);
+ QFont small("MetaWatch Small caps 8pt");
+ small.setPixelSize(8);
+ QFont large("MetaWatch Large 16pt");
+ large.setPixelSize(16);
+
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);
+ bool drawn_summary = false;
+ p.setFont(large);
+ if (!summary.isEmpty()) {
+ QRect area(2, 2, 96 - 20, 18);
+ QRect r;
+ p.drawText(area,
+ Qt::AlignLeft | Qt::AlignTop | Qt::TextSingleLine,
+ summary, &r);
+ if (area.contains(r)) {
+ drawn_summary = true;
+ }
+ }
- image.invertPixels();
+ const int x = 2, max_x = 96;
+ const int max_y = 96 - 24;
+ int y = 26;
+
+ p.setFont(small);
+ if (!drawn_summary && !summary.isEmpty()) {
+ QRect r;
+ p.drawText(QRect(x, y, max_x - x, max_y - y),
+ Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap,
+ summary, &r);
+ y = r.bottom() + 1;
+ }
+ if (!body.isEmpty() && y < max_y) {
+ QRect r;
+ p.drawText(QRect(x, y, max_x - x, max_y - y),
+ Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap,
+ body, &r);
+ y = r.bottom() + 1;
+ }
+ image.invertPixels();
+ _metawatch->clearModeImage(MetaWatch::WatchModeNotification);
_metawatch->sendModeImage(MetaWatch::WatchModeNotification, image);
_metawatch->updateLcdDisplayMode(MetaWatch::WatchModeNotification);
_metawatch->setVibrateMode(true, 500, 500, 2);