blob: fa0742449ab3e2c01a976b0e7addaf1c3dacf50f (
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
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
// Copyright (C) 2021 The Qt Company Ltd.
// Copyright (C) 2019 Luxoft Sweden AB
// Copyright (C) 2018 Pelagicore AG
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef NOTIFICATION_H
#define NOTIFICATION_H
#include <QtCore/QObject>
#include <QtCore/QUrl>
#include <QtCore/QVariantMap>
#include <QtQml/QQmlParserStatus>
#include <QtAppManCommon/global.h>
QT_BEGIN_NAMESPACE_AM
class NotificationImpl;
class Notification : public QObject, public QQmlParserStatus
{
Q_OBJECT
Q_INTERFACES(QQmlParserStatus)
Q_PROPERTY(uint notificationId READ notificationId NOTIFY notificationIdChanged FINAL)
Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL)
Q_PROPERTY(QString summary READ summary WRITE setSummary NOTIFY summaryChanged FINAL)
Q_PROPERTY(QString body READ body WRITE setBody NOTIFY bodyChanged FINAL)
Q_PROPERTY(QUrl icon READ icon WRITE setIcon NOTIFY iconChanged FINAL)
Q_PROPERTY(QUrl image READ image WRITE setImage NOTIFY imageChanged FINAL)
Q_PROPERTY(QString category READ category WRITE setCategory NOTIFY categoryChanged FINAL)
Q_PROPERTY(int priority READ priority WRITE setPriority NOTIFY priorityChanged FINAL)
Q_PROPERTY(bool acknowledgeable READ isAcknowledgeable WRITE setAcknowledgeable NOTIFY acknowledgeableChanged FINAL)
Q_PROPERTY(int timeout READ timeout WRITE setTimeout NOTIFY timeoutChanged FINAL)
Q_PROPERTY(bool sticky READ isSticky WRITE setSticky NOTIFY stickyChanged FINAL)
Q_PROPERTY(bool showProgress READ isShowingProgress WRITE setShowProgress NOTIFY showProgressChanged FINAL)
Q_PROPERTY(qreal progress READ progress WRITE setProgress NOTIFY progressChanged FINAL)
Q_PROPERTY(QVariantList actions READ actions WRITE setActions NOTIFY actionsChanged FINAL)
Q_PROPERTY(bool showActionsAsIcons READ showActionsAsIcons WRITE setShowActionsAsIcons NOTIFY showActionsAsIconsChanged FINAL)
Q_PROPERTY(bool dismissOnAction READ dismissOnAction WRITE setDismissOnAction NOTIFY dismissOnActionChanged FINAL)
Q_PROPERTY(QVariantMap extended READ extended WRITE setExtended NOTIFY extendedChanged FINAL)
public:
enum Priority { Low, Normal, Critical };
Q_ENUM(Priority)
Notification(QObject *parent = nullptr, const QString &applicationId = { });
~Notification() override;
uint notificationId() const;
QString summary() const;
QString body() const;
QUrl icon() const;
QUrl image() const;
QString category() const;
int priority() const;
bool isAcknowledgeable() const;
int timeout() const;
bool isSticky() const;
bool isShowingProgress() const;
qreal progress() const;
QVariantList actions() const;
bool showActionsAsIcons() const;
bool dismissOnAction() const;
QVariantMap extended() const;
bool isVisible() const;
Q_INVOKABLE void show();
Q_INVOKABLE void update();
Q_INVOKABLE void hide();
public Q_SLOTS:
void setSummary(const QString &summary);
void setBody(const QString &boy);
void setIcon(const QUrl &icon);
void setImage(const QUrl &image);
void setCategory(const QString &category);
void setPriority(int priority);
void setAcknowledgeable(bool acknowledgeable);
void setTimeout(int timeout);
void setSticky(bool sticky);
void setShowProgress(bool showProgress);
void setProgress(qreal progress);
void setActions(const QVariantList &actions);
void setShowActionsAsIcons(bool showActionsAsIcons);
void setDismissOnAction(bool dismissOnAction);
void setExtended(const QVariantMap &extended);
void setVisible(bool visible);
Q_SIGNALS:
void notificationIdChanged(uint notificationId);
void summaryChanged(const QString &summary);
void bodyChanged(const QString &body);
void iconChanged(const QUrl &icon);
void imageChanged(const QUrl &image);
void categoryChanged(const QString &category);
void priorityChanged(int priority);
void acknowledgeableChanged(bool acknowledgeable);
void timeoutChanged(int timeout);
void stickyChanged(bool sticky);
void showProgressChanged(bool showProgress);
void progressChanged(qreal progress);
void actionsChanged(const QVariantList &actions);
void showActionsAsIconsChanged(bool showActionsAsIcons);
void dismissOnActionChanged(bool dismissOnAction);
void extendedChanged(QVariantMap extended);
void visibleChanged(bool visible);
void acknowledged();
void actionTriggered(const QString &actionId);
public:
// not public API, but QQmlParserStatus pure-virtual overrides
void classBegin() override;
void componentComplete() override;
void setId(uint notificationId);
void close();
void triggerAction(const QString &actionId);
QVariantMap libnotifyHints() const;
QStringList libnotifyActionList() const;
private:
void updateNotification();
private:
uint m_id = 0;
QString m_summary;
QString m_body;
QUrl m_icon;
QUrl m_image;
QString m_category;
int m_priority = Normal;
bool m_acknowledgeable = false;
int m_timeout = defaultTimeout;
bool m_showProgress = false;
qreal m_progress = -1;
QVariantList m_actions;
bool m_showActionsAsIcons = false;
bool m_dismissOnAction = false;
QVariantMap m_extended;
bool m_visible = false;
bool m_usedByQml = false;
bool m_componentComplete = false;
static const int defaultTimeout = 2000;
private:
Q_DISABLE_COPY_MOVE(Notification)
std::unique_ptr<NotificationImpl> m_impl;
friend class NotificationImpl;
friend class ApplicationMain;
};
QT_END_NAMESPACE_AM
#endif // NOTIFICATION_H
|