diff options
author | Javier S. Pedro <dev.git@javispedro.com> | 2014-09-20 19:40:53 +0200 |
---|---|---|
committer | Javier S. Pedro <dev.git@javispedro.com> | 2014-09-20 19:40:53 +0200 |
commit | 874f27626dc91cd4bd01db680cdd5a0d15d3bf76 (patch) | |
tree | 86945f05ac35da0cb05b9a4f7aab2932173a827a /src | |
parent | 4a79b503f107632dd1b2204499a31e91b86dd0e4 (diff) | |
download | salmeta-874f27626dc91cd4bd01db680cdd5a0d15d3bf76.tar.gz salmeta-874f27626dc91cd4bd01db680cdd5a0d15d3bf76.zip |
add count of emails,etc. to title of notification
Diffstat (limited to 'src')
-rw-r--r-- | src/controller.cpp | 21 | ||||
-rw-r--r-- | src/controller.h | 2 | ||||
-rw-r--r-- | src/notificationmonitor.cpp | 5 | ||||
-rw-r--r-- | src/notificationmonitor.h | 3 |
4 files changed, 20 insertions, 11 deletions
diff --git a/src/controller.cpp b/src/controller.cpp index e15a54a..ad85183 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -214,7 +214,7 @@ void Controller::handleMetaWatchBatteryStatus(bool charging, int charge) } } -void Controller::handleIncomingNotification(const QString &sender, const QIcon &icon, const QString &summary, const QString &body) +void Controller::handleIncomingNotification(const QString &sender, const QIcon &icon, const QString &summary, int count, const QString &body, const QDateTime &dateTime) { if (!isWatchConnected()) { return; // Ignoring notification if metawatch is not connected. @@ -231,16 +231,21 @@ void Controller::handleIncomingNotification(const QString &sender, const QIcon & p.drawImage(0, 0, QImage(SailfishApp::pathTo("qml/watch/notification.png").toLocalFile())); icon.paint(&p, 0, 96 - 24, 24, 24, Qt::AlignLeft | Qt::AlignBottom); - bool drawn_summary = false; + QString title = summary; + bool title_drawn_fully = false; + if (count > 0) { + title = QString("%1 %2").arg(count).arg(summary); + } + p.setFont(large); - if (!summary.isEmpty()) { - QRect area(2, 2, 96 - 20, 18); + if (!title.isEmpty()) { + QRect area(2, 2, 96 - 18, 18); QRect r; p.drawText(area, Qt::AlignLeft | Qt::AlignTop | Qt::TextSingleLine, - summary, &r); + title, &r); if (area.contains(r)) { - drawn_summary = true; + title_drawn_fully = true; } } @@ -249,11 +254,11 @@ void Controller::handleIncomingNotification(const QString &sender, const QIcon & int y = 26; p.setFont(small); - if (!drawn_summary && !summary.isEmpty()) { + if (!title_drawn_fully && !title.isEmpty()) { QRect r; p.drawText(QRect(x, y, max_x - x, max_y - y), Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, - summary, &r); + title, &r); y = r.bottom() + 1; } if (!body.isEmpty() && y < max_y) { diff --git a/src/controller.h b/src/controller.h index 900f763..4b6faf1 100644 --- a/src/controller.h +++ b/src/controller.h @@ -48,7 +48,7 @@ private slots: void handleMetaWatchConnected(); void handleMetaWatchModeChange(MetaWatch::WatchMode mode, int page); void handleMetaWatchBatteryStatus(bool charging, int charge); - void handleIncomingNotification(const QString &sender, const QIcon &icon, const QString &summary, const QString &body); + void handleIncomingNotification(const QString &sender, const QIcon &icon, const QString &summary, int count, const QString &body, const QDateTime &dateTime); void handleWidgetChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles); private: diff --git a/src/notificationmonitor.cpp b/src/notificationmonitor.cpp index 566143f..ef64ea1 100644 --- a/src/notificationmonitor.cpp +++ b/src/notificationmonitor.cpp @@ -55,7 +55,10 @@ uint NotificationMonitor::Notify(const QString &app_name, uint replaces_id, cons icon = QIcon::fromTheme(app_icon); } - emit incomingNotification(app_name, icon, summary, body); + int count = hints.value("x-nemo-item-count").toInt(); + QDateTime dateTime = hints.value("x-nemo-timestamp").toDateTime(); + + emit incomingNotification(app_name, icon, summary, count, body, dateTime); return 0; } diff --git a/src/notificationmonitor.h b/src/notificationmonitor.h index 84f237a..c0f7691 100644 --- a/src/notificationmonitor.h +++ b/src/notificationmonitor.h @@ -2,6 +2,7 @@ #define NOTIFICATIONMONITOR_H #include <QtCore/QObject> +#include <QtCore/QDateTime> #include <QtDBus/QDBusContext> class NotificationMonitor : public QObject, protected QDBusContext @@ -14,7 +15,7 @@ public: static NotificationMonitor *instance(); signals: - void incomingNotification(const QString &sender, const QIcon &icon, const QString &summary, const QString &body); + void incomingNotification(const QString &sender, const QIcon &icon, const QString &summary, int count, const QString &body, const QDateTime &dateTime); private: explicit NotificationMonitor(QObject *parent = 0); |