-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
NotificationList.hxx
82 lines (61 loc) · 1.97 KB
/
NotificationList.hxx
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
/*
This file is part of liquidshell.
SPDX-FileCopyrightText: 2017 - 2024 Martin Koller <kollix@aon.at>
SPDX-License-Identifier: GPL-3.0-or-later
*/
#ifndef _NotificationList_H_
#define _NotificationList_H_
#include <QScrollArea>
#include <QFrame>
#include <QLabel>
#include <QIcon>
#include <QMap>
class QVBoxLayout;
class QProgressBar;
class NotificationServer;
class NotifyItem : public QFrame
{
Q_OBJECT
public:
NotifyItem(QWidget *parent, NotificationServer *server, uint theid, const QString &app,
const QString &summary, const QString &body, const QIcon &icon,
const QStringList &actions, bool isResident);
void destroySysResources();
void setTimeout(int milliSecs);
uint id;
QString appName, summary, body;
QStringList actions;
QLabel *timeLabel, *iconLabel, *textLabel;
QProgressBar *timeoutBar;
bool resident = false; // keep after clicking an action
};
//--------------------------------------------------------------------------------
class NotificationList : public QWidget
{
Q_OBJECT
public:
NotificationList(NotificationServer *parent);
~NotificationList() override;
void addItem(uint id, const QString &appName, const QString &summary, const QString &body,
const QIcon &icon, const QStringList &actions, const QVariantMap &hints, int timeout);
void closeItem(uint id);
int itemCount() const { return items.count(); }
QVector<NotifyItem *> getItems() const { return items; }
void setAvoidPopup(bool on);
bool getAvoidPopup() const { return avoidPopup; }
Q_SIGNALS:
void itemsCountChanged();
void listNowEmpty();
private Q_SLOTS:
void itemDestroyed(QObject *item);
private:
void placeItems();
private:
QScrollArea *scrollArea;
QVBoxLayout *listVbox;
QMap<QString, int> appTimeouts; // appName, timeout (minutes)
QVector<NotifyItem *> items;
NotificationServer *server;
bool avoidPopup = false;
};
#endif