Debian Codegraph @

kysdk-qtwidgets/src/kpixmapcontainer.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 KPIXMAPCONTAINER_H
24 #define KPIXMAPCONTAINER_H
25
26 #include "gui_g.h"
27 #include <QLabel>
28 #include <QWidget>
29
30 namespace kdk
31 {
32
33 /** @defgroup BarModule
34 * @{
35 */
36
37 class KPixmapContainerPrivate;
38
39 /**
40 * @brief 为指定的pixmap添加右上角消息提示气泡,样式类似微信头像的消息提示
41 * @since 1.0.0
42 */
43 class GUI_EXPORT KPixmapContainer : public QWidget
44 {
45 Q_OBJECT
46
47 public:
48 KPixmapContainer(QWidget *parent = nullptr);
49
50 /**
51 * @brief 获取值
52 */
53 int value() const;
54
55 /**
56 * @brief 设置值
57 * @param value
58 */
59 void setValue(int value);
60
61 /**
62 * @brief 设置值是否可见
63 * @param flag
64 */
65 void setValueVisiable(bool flag);
66
67 /**
68 * @brief 获取值是否可见
69 */
70 bool isValueVisiable() const;
71
72 /**
73 * @brief 设置pixmap
74 * @param pixmap
75 */
76 void setPixmap(const QPixmap &pixmap);
77
78 /**
79 * @brief 获取pixmap
80 */
81 QPixmap pixmap() const;
82
83 /**
84 * @brief 清除值
85 */
86 void clearValue();
87
88 /**
89 * @brief 返回背景色
90 * @return
91 */
92 QColor color();
93
94 /**
95 * @brief 设置背景色
96 * @param color
97 */
98 void setColor(const QColor &color);
99
100 /**
101 * @brief 返回字体大小
102 * @return
103 */
104 int fontSize();
105
106 /**
107 * @brief 设置字体大小
108 * @param size
109 */
110 void setFontSize(int size);
111
112 protected:
113 void paintEvent(QPaintEvent *event);
114
115 private:
116 Q_DECLARE_PRIVATE(KPixmapContainer)
117 KPixmapContainerPrivate *const d_ptr;
118 };
119 }
120 /**
121 * @example testbadge/widget.h
122 * @example testbadge/widget.cpp
123 * @}
124 */
125
126 #endif // KPIXMAPCONTAINER_H