blob: 8a71b0b31c52a5ee086a1c49769942a61aee22da (
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
#ifndef NOTIFICATIONMONITOR_H
#define NOTIFICATIONMONITOR_H
#include <QtCore/QObject>
#include <QtCore/QMap>
#include <QtCore/QDateTime>
#include <QtGui/QIcon>
class MonitoredNotification : public QObject
{
Q_OBJECT
Q_PROPERTY(uint id READ id CONSTANT)
Q_PROPERTY(QString sender READ sender)
Q_PROPERTY(QString summary READ summary NOTIFY summaryChanged)
Q_PROPERTY(QString body READ body NOTIFY bodyChanged)
Q_PROPERTY(QDateTime timestamp READ timestamp NOTIFY timestampChanged)
Q_PROPERTY(QString icon READ icon NOTIFY iconChanged)
explicit MonitoredNotification(QObject *parent = 0);
public:
inline uint id() const { return _id; }
inline QString sender() const { return _sender; }
inline QString summary() const { return _summary; }
inline QString body() const { return _body; }
inline QDateTime timestamp() const { return _timestamp; }
inline QString icon() const { return _icon; }
signals:
void summaryChanged();
void bodyChanged();
void timestampChanged();
void iconChanged();
void closed(int reason);
private:
friend class NotificationMonitor;
uint _id;
QString _sender;
QString _summary;
QString _body;
QDateTime _timestamp;
QString _icon;
};
class NotificationMonitor : public QObject
{
Q_OBJECT
public:
~NotificationMonitor();
static NotificationMonitor *instance();
void processIncomingNotification(quint32 id, const QVariantHash &content);
void processCloseNotification(quint32 id, quint32 reason);
signals:
void notification(MonitoredNotification *n);
private:
explicit NotificationMonitor(QObject *parent = 0);
QMap<quint32, MonitoredNotification*> _notifs;
};
#endif // NOTIFICATIONMONITOR_H
|