Debian Codegraph @

kysdk-qtwidgets/src/kbadge.h

raw
1 /*
2 * libkysdk-qtwidgets's Library
3 *
4 * Copyright (C) 2023, KylinSoft Co., Ltd.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this library. If not, see <https://www.gnu.org/licenses/>.
18 *
19 * Authors: Zhen Sun <[email protected]>
20 *
21 */
22
23 #ifndef KBADGE_H
24 #define KBADGE_H
25
26 #include "gui_g.h"
27 #include <QColor>
28 #include <QPixmap>
29 #include <QWidget>
30
31 namespace kdk
32 {
33 class KBadgePrivate;
34 /**
35 * @defgroup MessageAlertModule
36 * @{
37 */
38
39 /**
40 * @brief 消息提醒气泡
41 * @since 1.0.0
42 */
43 class GUI_EXPORT KBadge : public QWidget
44 {
45 Q_OBJECT
46
47 public:
48 KBadge(QWidget *parent);
49
50 /**
51 * @brief 返回值
52 * @return
53 */
54 int value();
55
56 /**
57 * @brief 设置值,最大显示数值为999,大于999显示"..."
58 * @param value
59 */
60 void setValue(int value);
61
62 /**
63 * @brief 设置值是否可见
64 * @param flag
65 */
66 void setValueVisiable(bool flag);
67
68 /**
69 * @brief 获取值是否可见
70 */
71 bool isValueVisiable() const;
72
73 /**
74 * @brief 获取背景色
75 * @return
76 */
77 QColor color();
78
79 /**
80 * @brief 设置背景色
81 * @param color
82 */
83 void setColor(const QColor &color);
84
85 /**
86 * @brief 获取字体大小
87 * @return
88 */
89 int fontSize();
90
91 /**
92 * @brief 设置字体大小
93 * @param size
94 */
95 void setFontSize(int size);
96
97 protected:
98 void paintEvent(QPaintEvent *event);
99 void resizeEvent(QResizeEvent *event);
100
101 private:
102 Q_DECLARE_PRIVATE(KBadge)
103 KBadgePrivate *const d_ptr;
104 };
105 }
106 /**
107 * @example testbadge/widget.h
108 * @example testbadge/widget.cpp
109 * @}
110 */
111
112 #endif // KBADGE_H