-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathnotifywidget.h
85 lines (65 loc) · 1.84 KB
/
notifywidget.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**
* Notify Widget
* @brief 右下角提示窗
* @anchor Ho229<[email protected]>
* @date 2021/2/1
*/
#ifndef NOTIFYWIDGET_H
#define NOTIFYWIDGET_H
#include <QIcon>
#include <QWidget>
class QLabel;
class QHBoxLayout;
class QVBoxLayout;
class QSpacerItem;
class CountdownButton;
class QPropertyAnimation;
#define DEFULT_NOTIFY_STYLE "\
NotifyWidget\
{\
background:rgb(46, 47, 48);\
border-style:none;\
}\
QLabel\
{\
color:white;\
}"
class NotifyWidget Q_DECL_FINAL : public QWidget
{
Q_OBJECT
public:
explicit NotifyWidget(QWidget *parent = nullptr, const QString& title = "",
const QString& message = "", const QIcon& icon = QIcon(),
const QString& style = DEFULT_NOTIFY_STYLE);
~NotifyWidget() Q_DECL_OVERRIDE;
void setCloseCountdown(int ms);
int closeCountdown() const;
void animatMove(int x, int y);
bool isClosing() const { return m_isClosing; }
QIcon icon() const { return m_icon; }
/**
* @return 剩余时间
*/
int leftTime() const;
signals:
void closed();
void clicked();
private slots:
void closeAnimation();
private:
QLabel *m_iconLabel = nullptr;
QLabel *m_titleLabel = nullptr;
QLabel *m_messageLabel = nullptr;
QHBoxLayout *m_hLayout = nullptr;
QHBoxLayout *m_mLayout = nullptr;
QVBoxLayout *m_vLayout = nullptr;
QSpacerItem *m_hSpacer = nullptr;
QIcon m_icon;
CountdownButton *m_closeButton = nullptr;
QPropertyAnimation *m_animation = nullptr;
bool m_isClosing = false;
void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
};
#endif // NOTIFYWIDGET_H