summaryrefslogtreecommitdiff
path: root/saltoqd/notificationmanager.cpp
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2015-03-31 01:27:32 +0200
committerJavier <dev.git@javispedro.com>2015-03-31 01:27:32 +0200
commit459da42728aa88dfcd0128319984de567384d65e (patch)
tree0cd2db265ef87b6e2723447e9c930a9d19c7a86c /saltoqd/notificationmanager.cpp
parentefe35bf6c6ca8cce73e97f303963a51862778600 (diff)
downloadsaltoq-459da42728aa88dfcd0128319984de567384d65e.tar.gz
saltoq-459da42728aa88dfcd0128319984de567384d65e.zip
notifications partially working
Diffstat (limited to 'saltoqd/notificationmanager.cpp')
-rw-r--r--saltoqd/notificationmanager.cpp36
1 files changed, 34 insertions, 2 deletions
diff --git a/saltoqd/notificationmanager.cpp b/saltoqd/notificationmanager.cpp
index a2142fc..c78fffb 100644
--- a/saltoqd/notificationmanager.cpp
+++ b/saltoqd/notificationmanager.cpp
@@ -1,7 +1,39 @@
#include "notificationmanager.h"
#include "notificationmonitor.h"
-NotificationManager::NotificationManager(ToqManager *toq) :
- QObject(toq), _toq(toq), _monitor(NotificationMonitor::instance())
+NotificationManager::NotificationManager(CardManager *card, ToqManager *toq) :
+ QObject(toq), _toq(toq), _monitor(NotificationMonitor::instance()),
+ _card(card),
+ _deck(new CardDeck("com.qualcomm.qce.androidnotifications", "Notifications", this))
{
+ _card->installDeck(_deck);
+
+ connect(_monitor, &NotificationMonitor::notification,
+ this, &NotificationManager::handleNotification);
+}
+
+void NotificationManager::handleNotification(MonitoredNotification *n)
+{
+ Card *card = new Card(QString::number(qint64(n->id())));
+
+ card->setHeader(n->sender());
+ card->setTitle(n->summary());
+ card->setText(n->body());
+ card->setDateTime(n->timestamp());
+ card->setVibrate(true);
+
+ connect(n, &MonitoredNotification::closed,
+ this, &NotificationManager::handleClosedNotification);
+
+ _deck->appendCard(card);
+}
+
+void NotificationManager::handleClosedNotification()
+{
+ MonitoredNotification *n = static_cast<MonitoredNotification*>(sender());
+ Card *card = _cards.take(n);
+ if (card) {
+ _deck->removeCard(card);
+ card->deleteLater();
+ }
}