Debian Codegraph @

kysdk-qtwidgets/src/ksettinggroup.h

raw
1 /*
2 *
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: Sisheng He <[email protected]>
20 *
21 */
22 #ifndef SETTINGGROUP_H
23 #define SETTINGGROUP_H
24
25 #include "kbaseframe.h"
26 #include <QDebug>
27 #include <QEvent>
28 #include <QFrame>
29 #include <QVBoxLayout>
30 #include <QWidget>
31 #include <QtDBus/QDBusInterface>
32 #include <QtDBus/QDBusReply>
33
34 /**
35 * @defgroup ContainerModules
36 * @brief 创建一个 Spacing 为 1 的垂直布局 Frame
37 * @since 3.0.1.0
38 * {
39 */
40
41 namespace kdk
42 {
43
44 class KSettingGroupPrivate;
45
46 class KSettingGroup : public KBaseFrame
47 {
48 Q_OBJECT
49 public:
50 /**
51 * @brief 创建一个 Spacing 为 1 的垂直布局 Frame
52 *
53 * @param Shape: 设置frameShap
54 * @param style: 设置圆角(None:无圆角,Top:上圆角,Bottom:下圆角,Around:四圆角)
55 * @param parent
56 */
57 explicit KSettingGroup(QWidget *parent = nullptr, Shape shape = QFrame::NoFrame, BorderRadiusStyle style = BorderRadiusStyle::None);
58 ~KSettingGroup();
59
60 /**
61 * @brief 为 mainLayout 添加控件并更新圆角
62 *
63 * @param item: 需要添加的控件
64 * @param autoUpdateShape: 是否自动更新item圆角样式
65 * @param visible 实际未show控件时isVisible总是false,导致圆角无法正常,因此重新设置,应为Qt的BUG
66 */
67 void addWidget(QFrame *item, bool autoUpdateShape = true, bool visible = true);
68
69 /**
70 * @brief 为 mainLayout 添加控件并更新圆角
71 *
72 * @param index: 序号
73 * @param item: 需要添加的控件
74 * @param autoUpdateShape: 是否自动更新item圆角样式
75 * @param visible 实际未show控件时isVisible总是false,导致圆角无法正常,因此重新设置,应为Qt的BUG
76 */
77 void insertWidget(int index, QFrame *item, bool autoUpdateShape = true, bool visible = true);
78
79 /**
80 * @brief 为 mainLayout 移除控件并更新圆角
81 *
82 * @param w: 需要移除的控件
83 * @param autoUpdateShape: 是否自动更新item圆角样式
84 */
85 void removeWidget(QWidget *w, bool autoUpdateShape = true);
86
87 /**
88 * @brief 更新圆角
89 *
90 */
91 void updateShape();
92
93 /**
94 * @brief 获取 mainLayout
95 *
96 * @return QVBoxLayout mainLayout
97 */
98 QVBoxLayout *layout();
99
100 /**
101 * @brief 设置最后一个frame的圆角风格
102 *
103 * @param style 圆角风格
104 */
105 void setLastRadiusStyle(BorderRadiusStyle style);
106
107 /**
108 * @brief 设置仅一个frame时的圆角风格
109 *
110 * @param style
111 */
112 void setOneRadiusStyle(BorderRadiusStyle style);
113
114 /**
115 * @brief 获取显示的子控件个数
116 *
117 * @return int 显示的子控件个数
118 */
119 int showItemsCount();
120
121 /**
122 * @brief 移除并删除所有子控件
123 *
124 */
125 void removeAndDeleteAllWidget();
126
127 protected:
128 bool eventFilter(QObject *watched, QEvent *event);
129
130 private:
131 Q_DECLARE_PRIVATE(KSettingGroup)
132 KSettingGroupPrivate *const d_ptr;
133 };
134
135 }
136
137 #endif // SETTINGGROUP_H