Debian Codegraph @

kysdk-qtwidgets/src/kbaseframe.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 KBASEFRAME_H
23 #define KBASEFRAME_H
24
25 #include <QFrame>
26 #include <QHBoxLayout>
27
28 #include "klabel.h"
29
30 #define RADIUS_VALUE 6 /**< 圆角数值 */
31 #define PC_HEIGHT 60 /**< pc模式下高度 */
32 #define TABLET_HEIGHT 64 /**< 平板模式下高度 */
33 #define SETTING_LABEL_WIDTH 214 /**< label 宽度*/
34
35 namespace kdk
36 {
37
38 /**
39 * @defgroup ContainerModule
40 * @brief 支持圆角四种类型的容器
41 * @since 3.0.1.0
42 * {
43 */
44
45 class KBaseFramePrivate;
46
47 class KBaseFrame : public QFrame
48 {
49 Q_OBJECT
50 public:
51 enum BorderRadiusStyle {
52 Top, /**< 顶部有圆角 */
53 None, /**< 没有圆角 */
54 Bottom, /**< 底部有圆角 */
55 Around /**< 四周都有圆角 */
56 };
57
58 /**
59 * @brief 构造函数
60 *
61 * @param parent 父对象
62 * @param style 圆角风格枚举值
63 * @param heightAdaptive 是否自动调整高度,默认PC下60,平板模式64
64 */
65 explicit KBaseFrame(QWidget *parent = nullptr, BorderRadiusStyle style = Around, bool heightAdaptive = false);
66 ~KBaseFrame();
67
68 /**
69 * @brief 设置圆角风格
70 *
71 * @param style 圆角风格枚举值
72 */
73 void setRadiusType(BorderRadiusStyle style);
74
75 /**
76 * @brief 获取平板模式
77 *
78 * @return bool 是否是平板模式
79 */
80 bool getTabletMode();
81
82 /**
83 * @brief 获取是否是一个容器frame,此时settinggroup需要设置的是其子frame的圆角
84 *
85 * @return bool 是/不是
86 */
87 bool isContainer();
88
89 /**
90 * @brief 设置该frame是否是一个容器frame,如果是同时setFrameShape(NoFrame);
91 *
92 * @param b 是/不是
93 */
94 void setContainer(bool b = false);
95
96 Q_SIGNALS:
97 void tabletModeChanged(bool b);
98
99 protected:
100 void paintEvent(QPaintEvent *e);
101
102 private:
103 Q_DECLARE_PRIVATE(KBaseFrame)
104 KBaseFramePrivate *const d_ptr;
105 };
106
107 }
108
109 #endif // KBASEFRAME_H