Debian Codegraph @

kysdk-qtwidgets/src/kbackgroundgroup.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 KBACKGROUNDGROUP_H
24 #define KBACKGROUNDGROUP_H
25
26 #include "gui_g.h"
27 #include <QFrame>
28 #include <QWidget>
29 namespace kdk
30 {
31
32 /**
33 * @defgroup ContainerModule
34 * {
35 */
36 class KBackgroundGroupPrivate;
37
38 /**
39 * @brief 提供了一个用于存储部件的容器
40 * @since 2.0.2.1
41 */
42
43 class GUI_EXPORT KBackgroundGroup : public QFrame
44 {
45 Q_OBJECT
46
47 public:
48 KBackgroundGroup(QWidget *parent = nullptr);
49
50 /**
51 * @brief 添加一个widget控件
52 * @param widget
53 */
54 void addWidget(QWidget *widget);
55
56 /**
57 * @brief 添加一个widget list
58 * @param list
59 */
60 void addWidgetList(QList<QWidget *> list);
61
62 /**
63 * @brief 删除一个指定index的widget
64 * @param i
65 */
66 void removeWidgetAt(int i);
67
68 /**
69 * @brief 删除一个widget
70 * @param widget
71 */
72 void removeWidget(QWidget *widget);
73
74 /**
75 * @brief 删除一个widget list
76 * @param list
77 */
78 void removeWidgetList(QList<QWidget *> list);
79
80 /**
81 * @brief 指定位置插入一个widget
82 * @param index
83 * @param widget
84 */
85 void insertWidgetAt(int index, QWidget *widget);
86
87 /**
88 * @brief 指定位置插入一个widget list
89 * @param index
90 * @param list
91 */
92 void insertWidgetList(int index, QList<QWidget *> list);
93
94 /**
95 * @brief 设置KBackgroundGroup的圆角
96 * @param radius
97 */
98 void setBorderRadius(int radius);
99
100 /**
101 * @brief 返回KBackgroundGroup的圆角
102 * @return
103 */
104 int borderRadius();
105
106 /**
107 * @brief 设置背景颜色
108 * @param role
109 */
110 void setBackgroundRole(QPalette::ColorRole role);
111
112 /**
113 * @brief 返回背景颜色
114 * @return
115 */
116 QPalette::ColorRole backgroundRole() const;
117
118 /**
119 * @brief 设置窗体是否可以响应三态
120 * @param flag
121 * @param widget
122 */
123 void setStateEnable(QWidget *widget, bool flag);
124
125 /**
126 * @brief 返回widget列表
127 * @return
128 */
129 QList<QWidget *> widgetList();
130
131 /**
132 * @brief 设置边框是否可见
133 * @param flag
134 * @since 3.0.1.0
135 */
136 void setBorderVisible(bool flag);
137
138 Q_SIGNALS:
139 /**
140 * @brief 点击会发出信号
141 */
142 void clicked(QWidget *);
143
144 protected:
145 void paintEvent(QPaintEvent *event);
146 bool eventFilter(QObject *watched, QEvent *event);
147
148 private:
149 Q_DECLARE_PRIVATE(KBackgroundGroup)
150 KBackgroundGroupPrivate *const d_ptr;
151 };
152
153 }
154 #endif // KBACKGROUNDGROUP_H