-
Notifications
You must be signed in to change notification settings - Fork 7
/
notifymanager.h
66 lines (51 loc) · 1.44 KB
/
notifymanager.h
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
/**
* Notify Manager
* @brief 右下角提示窗管理器
* @anchor Ho229<2189684957@qq.com>
* @date 2021/2/1
*/
#ifndef NOTIFYMANAGER_H
#define NOTIFYMANAGER_H
#include <QIcon>
#include <QObject>
#include "notifywidget.h"
typedef QPair<NotifyWidget *, // Notify Widget
int> // Show Time
NotifyItem;
class NotifyManager Q_DECL_FINAL : public QObject
{
Q_OBJECT
public:
explicit NotifyManager(QObject *parent = nullptr);
~NotifyManager() Q_DECL_OVERRIDE;
/**
* @brief 设置最大弹窗数
*/
void setMaximum(int value){ m_maximum = qMax(1, value); }
int maximum() const { return m_maximum; }
/**
* @return 当前弹窗数
*/
int showCount() const { return m_showCount; }
public slots:
/**
* @brief 弹出提示窗
* @param parent 父对象
* @param title 提示窗标题
* @param message 提示消息
* @param showTime 展示时间 ( 为 -1 时永久展示 )
*/
NotifyWidget* notify(QWidget *parent, const QString& title, const QString& message,
const QIcon& icon = QIcon(), int showTime = 5000);
signals:
void windowClosed();
private slots:
void onNotifyClosed();
private:
QList<NotifyItem> m_list;
int m_maximum = 5;
int m_showCount = 0;
const QSize m_desktopSize;
void updateNotifys();
};
#endif // NOTIFYMANAGER_H