Debian Codegraph @

kysdk-qtwidgets/src/kbuttonbox.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 KBUTTONBOX_H
24 #define KBUTTONBOX_H
25
26 #include "gui_g.h"
27 #include "kpushbutton.h"
28 #include <QAbstractButton>
29 #include <QWidget>
30
31 namespace kdk
32 {
33
34 /**
35 * @defgroup ContainerModule
36 */
37 class KButtonBoxPrivate;
38
39 /**
40 * @brief 提供了一个按钮类容器
41 * @since 2.0.2.1
42 */
43 class GUI_EXPORT KButtonBox : public QWidget
44 {
45 Q_OBJECT
46
47 public:
48 explicit KButtonBox(QWidget *parent = nullptr);
49 ~KButtonBox();
50
51 /**
52 * @brief 获取KButtonBox的布局类型
53 * @return
54 */
55 Qt::Orientation orientation();
56
57 /**
58 * @brief 设置KButtonBox的布局类型,包括水平类型和垂直类型
59 * @param orientation
60 */
61 void setOrientation(Qt::Orientation orientation);
62
63 /**
64 * @brief 添加按钮
65 * @param button
66 */
67 void addButton(KPushButton *button, int i = -1);
68
69 /**
70 * @brief 删除按钮
71 * @param button
72 */
73 void removeButton(KPushButton *button);
74
75 /**
76 * @brief 按id删除指定按钮
77 * @param i
78 */
79 void removeButton(int i);
80
81 /**
82 * @brief 以列表形式向KButtonBox中添加按钮
83 * @param list
84 * @param checkable
85 */
86 void setButtonList(const QList<KPushButton *> &list);
87
88 /**
89 * @brief 获取KButtonBox中的按钮列表
90 * @return
91 */
92 QList<KPushButton *> buttonList();
93
94 /**
95 * @brief 设置KButtonBox首尾部分按钮的圆角
96 * @param radius
97 */
98 void setBorderRadius(int radius);
99
100 /**
101 * @brief 获取KButtonBox首尾部分按钮的圆角
102 * @return
103 */
104 int borderRadius();
105
106 /**
107 * @brief 设置按钮id
108 * @param button
109 * @param id
110 */
111 void setId(KPushButton *button, int id);
112
113 /**
114 * @brief 获取按钮id
115 * @param button
116 * @return
117 */
118 int id(KPushButton *button);
119
120 /**
121 * @brief 返回已选中的按钮
122 * @return
123 */
124 KPushButton *checkedButton();
125
126 /**
127 * @brief 通过按钮id获取按钮
128 * @param id
129 * @return
130 */
131 KPushButton *button(int id);
132
133 /**
134 * @brief 返回已选中按钮的id
135 * @return
136 */
137 int checkedId();
138
139 /**
140 * @brief 设置KButtonBox按钮间是否互斥
141 */
142 void setExclusive(bool);
143
144 /**
145 * @brief 返回KButtonBox按钮间是否互斥
146 * @return
147 */
148 bool exclusive();
149
150 /**
151 * @brief 设置KButtonBox中的按钮是否可选中
152 */
153 void setCheckable(bool flag);
154
155 /**
156 * @brief 返回KButtonBox中的按钮是否可选中
157 * @return
158 */
159 bool isCheckable();
160
161 /**
162 * @brief 设置是否启动阴影效果
163 * @param flag
164 * @since 2.4.1.0
165 */
166 void setShadow(bool flag);
167
168 /**
169 * @brief 获取是否启用阴影效果
170 * @return bool
171 * @since 2.4.1.0
172 */
173 bool shadow();
174
175 Q_SIGNALS:
176 void buttonClicked(QAbstractButton *);
177 void buttonPressed(QAbstractButton *);
178 void buttonReleased(QAbstractButton *);
179 void buttonToggled(QAbstractButton *, bool);
180
181 private:
182 Q_DECLARE_PRIVATE(KButtonBox)
183 KButtonBoxPrivate *const d_ptr;
184 };
185
186 }
187 #endif // KBUTTONBOX_H