Debian Codegraph @

kysdk-qtwidgets/src/kradiobuttonframe.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 RADIOBUTTONWIDGET_H
23 #define RADIOBUTTONWIDGET_H
24
25 #include <QButtonGroup>
26 #include <QHBoxLayout>
27 #include <QRadioButton>
28
29 #include "kbaseframe.h"
30 #include "klabel.h"
31
32 /**
33 * @defgroup ContainerModules
34 * @brief 创建一个带 QButtonGroup 的 Frame
35 * @since 3.0.1.0
36 * {
37 */
38
39 namespace kdk
40 {
41
42 class KRadioButtonFramePrivate;
43
44 class KRadioButtonFrame : public KBaseFrame
45 {
46 Q_OBJECT
47
48 public:
49 /**
50 * @brief 创建一个带 QButtonGroup 的 Frame
51 *
52 * @param title: text of m_settingName
53 * @param style: 设置圆角(None:无圆角,Top:上圆角,Bottom:下圆角,Around:四圆角)
54 * @param parent
55 */
56 explicit KRadioButtonFrame(const QString title, QWidget *parent = nullptr, BorderRadiusStyle style = BorderRadiusStyle::None);
57
58 /**
59 * @brief
60 *
61 */
62 ~KRadioButtonFrame();
63
64 /**
65 * @brief 添加一个 id = id 的 QRadioButton 到 m_buttonGroup,并放到 radioLayout 中
66 *
67 * @param button: 需要添加的 QRadioButton
68 * @param id: 用于 buttonClicked 信号传递的参数
69 * @param addStretch: 是否 addStretch
70 */
71 void addButton(QRadioButton *button, int id = -1, bool addStretch = false);
72
73 /**
74 * @brief layout of radiobutton
75 *
76 * @return QHBoxLayout
77 */
78 QHBoxLayout *radioHLayout();
79
80 /**
81 * @brief 获取 m_buttonGroup
82 *
83 * @return QButtonGroup
84 */
85 QButtonGroup *buttonGroup();
86
87 /**
88 * @brief 获取label
89 *
90 * @return QLabel
91 */
92 KLabel *titleLabel();
93
94 /**
95 * @brief 获取layout
96 *
97 * @return QHBoxLayout
98 */
99 QHBoxLayout *mainHLayout();
100
101 private:
102 Q_DECLARE_PRIVATE(KRadioButtonFrame)
103 KRadioButtonFramePrivate *const d_ptr;
104 };
105 }
106
107 #endif // RADIOBUTTONWIDGET_H