Debian Codegraph @

kysdk-qtwidgets/src/kballontip.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 KBALLONTIP_H
24 #define KBALLONTIP_H
25
26 #include "gui_g.h"
27 #include <QHBoxLayout>
28 #include <QWidget>
29
30 namespace kdk
31 {
32 /** @defgroup MessageAlertModule
33 * @{
34 */
35
36 /**
37 * @brief 支持五种样式
38 * @since 1.0.0
39 */
40 enum TipType {
41 Nothing,
42 Normal,
43 Info,
44 Warning,
45 Error,
46 Variable,
47 Loading
48 };
49
50 class KBallonTipPrivate;
51 /**
52 * @brief 消息提示框,支持五种样式
53 */
54 class GUI_EXPORT KBallonTip : public QWidget
55 {
56 Q_OBJECT
57
58 public:
59 explicit KBallonTip(QWidget *parent = nullptr);
60 explicit KBallonTip(const QString &content, const TipType &type, QWidget *parent = nullptr);
61
62 /**
63 * @brief 显示时间完毕后消失
64 * @since 1.2.0
65 */
66 void showInfo();
67 /**
68 * @brief 设置类型
69 * @param type
70 */
71 void setTipType(const TipType &type);
72
73 /**
74 * @brief 返回类型
75 * @return
76 */
77 TipType tipType();
78
79 /**
80 * @brief 设置文本内容
81 * @param text
82 */
83 void setText(const QString &text);
84
85 /**
86 * @brief text
87 * @return
88 */
89 QString text();
90
91 /**
92 * @brief 设置内容边距
93 * @param left
94 * @param top
95 * @param right
96 * @param bottom
97 */
98 void setContentsMargins(int left, int top, int right, int bottom);
99
100 /**
101 * @brief 设置内容边距
102 * @param margins
103 */
104 void setContentsMargins(const QMargins &margins);
105
106 /**
107 * @brief 设置持续时间
108 * @since 1.2.0
109 */
110 void setTipTime(int my_time);
111
112 /**
113 * @brief 获取kballontip的水平布局
114 * @return
115 * @since 2.4.1.0
116 */
117 QHBoxLayout *hBoxLayout();
118
119 /**
120 * @brief 设置可变类型的icon
121 * @param icon
122 * @since 2.5.2.0
123 */
124 void setVariableIcon(QIcon icon);
125
126 /**
127 * @brief 获取可变类型的icon
128 * @return
129 * @since 2.5.2.0
130 */
131 QPixmap variableIcon();
132
133 private Q_SLOTS:
134 void onTimeupDestroy();
135
136 protected:
137 void paintEvent(QPaintEvent *event) override;
138
139 private:
140 Q_DECLARE_PRIVATE(KBallonTip)
141 KBallonTipPrivate *const d_ptr;
142 };
143 }
144 /**
145 * @example testballontip/widget.h
146 * @example testballontip/widget.cpp
147 * @}
148 */
149 #endif // KBALLONTIP_H