blob: c78fffbad52cde14b0cc1a1ac9d18fbb078aa5cf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#include "notificationmanager.h"
#include "notificationmonitor.h"
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();
}
}
|