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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
/*
* Copyright (C) 2013 Canonical, Ltd.
*
* Authors:
* Jussi Pakkanen <jussi.pakkanen@canonical.com>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NOTIFICATION_HPP_
#define NOTIFICATION_HPP_
#include "ActionModel.h"
#include "notify-backend.h"
#include <QString>
#include <QObject>
#include <QScopedPointer>
#include <QImage>
#include <QStringList>
struct NotificationPrivate;
class NotificationServer;
class Notification : public QObject {
Q_OBJECT
Q_ENUMS(Urgency)
Q_ENUMS(Type)
Q_PROPERTY(QString summary READ getSummary WRITE setSummary NOTIFY summaryChanged)
Q_PROPERTY(QString body READ getBody WRITE setBody NOTIFY bodyChanged)
Q_PROPERTY(NotificationID id READ getID)
Q_PROPERTY(int value READ getValue WRITE setValue NOTIFY valueChanged)
Q_PROPERTY(QString icon READ getIcon WRITE setIcon NOTIFY iconChanged)
Q_PROPERTY(QString secondaryIcon READ getSecondaryIcon WRITE setSecondaryIcon NOTIFY secondaryIconChanged)
Q_PROPERTY(Urgency urgency READ getUrgency WRITE setUrgency NOTIFY urgencyChanged)
Q_PROPERTY(Type type READ getType WRITE setType NOTIFY typeChanged)
Q_PROPERTY(ActionModel* actions READ getActions NOTIFY actionsChanged)
Q_PROPERTY(QVariantMap hints READ getHints WRITE setHints NOTIFY hintsChanged)
private:
QScopedPointer<NotificationPrivate> p;
public:
enum Urgency { Low, Normal, Critical };
enum Type { PlaceHolder, Confirmation, Ephemeral, Interactive, SnapDecision };
Q_SIGNALS:
void bodyChanged(const QString &text);
void iconChanged(const QString &icon);
void secondaryIconChanged(const QString &secondaryIcon);
void summaryChanged(const QString &summary);
void valueChanged(int value);
void urgencyChanged(Urgency urg);
void typeChanged(Type type);
void actionsChanged(const QStringList &actions);
void hintsChanged(const QVariantMap& hints);
void dataChanged(unsigned int id);
void dismissed();
void completed(unsigned int id);
public Q_SLOTS:
void onHovered();
void onDisplayed();
public:
Notification(QObject *parent=nullptr);
Notification(NotificationID id,
int displayTime,
const Urgency ur,
const QString &text, Type type=Ephemeral,
NotificationServer *srv=nullptr,
QObject *parent=nullptr);
Notification(NotificationID id,
int displayTime,
const Urgency ur,
Type type=Ephemeral,
NotificationServer *srv=nullptr,
QObject *parent=nullptr);
virtual ~Notification();
NotificationID getID() const;
int getDisplayTime() const;
QString getIcon() const;
void setIcon(const QString &icon);
QString getSecondaryIcon() const;
void setSecondaryIcon(const QString &secondaryIcon);
QString getBody() const;
void setBody(const QString &text);
QString getSummary() const;
void setSummary(const QString &summary);
int getValue() const;
void setValue(int value);
Urgency getUrgency() const;
void setUrgency(Urgency urg);
Type getType() const;
void setType(Type type);
ActionModel* getActions() const;
void setActions(const QStringList &actions);
void detachFromServer();
QVariantMap getHints() const;
void setHints(const QVariantMap& hints);
Q_INVOKABLE void invokeAction(const QString &action);
bool operator<(const Notification &n) const; // Order by "interestingness".
};
#endif /* NOTIFICATION_HPP_ */
|