summaryrefslogtreecommitdiff
path: root/saltoqd/notificationmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'saltoqd/notificationmanager.cpp')
-rw-r--r--saltoqd/notificationmanager.cpp25
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());