diff options
author | Javier <dev.git@javispedro.com> | 2015-04-21 00:47:30 +0200 |
---|---|---|
committer | Javier <dev.git@javispedro.com> | 2015-04-21 00:47:30 +0200 |
commit | 6662f40aff76e0700d82237261774758981bf784 (patch) | |
tree | 45617cf6b00b9e7e84da685abd216bd4278513f0 /saltoqd/notificationmanager.cpp | |
parent | e9628b70189b9acb84705693e155e10700f21177 (diff) | |
download | saltoq-6662f40aff76e0700d82237261774758981bf784.tar.gz saltoq-6662f40aff76e0700d82237261774758981bf784.zip |
forward some types of notification icons
Diffstat (limited to 'saltoqd/notificationmanager.cpp')
-rw-r--r-- | saltoqd/notificationmanager.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/saltoqd/notificationmanager.cpp b/saltoqd/notificationmanager.cpp index 30414ce..35b5c00 100644 --- a/saltoqd/notificationmanager.cpp +++ b/saltoqd/notificationmanager.cpp @@ -1,3 +1,4 @@ +#include <QtCore/QFileInfo> #include "notificationmanager.h" #include "notificationmonitor.h" @@ -29,6 +30,18 @@ void NotificationManager::handleNotification(MonitoredNotification *n) card->setDateTime(n->timestamp()); card->setVibrate(true); + if (!n->icon().isEmpty()) { + QFileInfo imgFile(n->icon()); + QImage img(imgFile.absoluteFilePath()); + if (!img.isNull()) { + card->setIcon(_card->sendImage(_deck, imgFile.completeBaseName(), img.scaled(48, 48, Qt::KeepAspectRatio))); + } else { + qDebug() << "Could not read icon from notification: " << imgFile.absoluteFilePath(); + } + } + + connect(n, &MonitoredNotification::bodyChanged, + this, &NotificationManager::handleNotificationBodyChanged); connect(n, &MonitoredNotification::closed, this, &NotificationManager::handleClosedNotification); @@ -36,6 +49,18 @@ void NotificationManager::handleNotification(MonitoredNotification *n) _deck->insertCard(0, card); } +void NotificationManager::handleNotificationBodyChanged() +{ + MonitoredNotification *n = static_cast<MonitoredNotification*>(sender()); + uint notificationId = n->id(); + Card *card = _cards.take(notificationId); + if (card) { + card->setText(n->body()); + } else { + qDebug() << "Notification" << notificationId << "does not have an attached card"; + } +} + void NotificationManager::handleClosedNotification() { MonitoredNotification *n = static_cast<MonitoredNotification*>(sender()); |