Debian Codegraph @

kysdk-qtwidgets/src/kcolorbutton.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 KCOLORBUTTON_H
24 #define KCOLORBUTTON_H
25
26 #include "gui_g.h"
27 #include <QPushButton>
28
29 namespace kdk
30 {
31 /**
32 * @defgroup PushbuttonModule
33 */
34 class KColorButtonPrivate;
35
36 /**
37 * @brief 提供用于设置颜色和样式的按钮,以适用于不同的场景。
38 * @since 2.0.2.1
39 */
40 class GUI_EXPORT KColorButton : public QPushButton
41 {
42 Q_OBJECT
43 public:
44 /**
45 * @brief KColorButton提供三种不同的样式
46 */
47 enum ButtonType {
48 Circle,
49 RoundedRect,
50 CheckedRect
51 };
52
53 KColorButton(QWidget *parent = nullptr);
54
55 /**
56 * @brief 设置colorButton背景色
57 * @param color
58 */
59 void setBackgroundColor(QColor color);
60
61 /**
62 * @brief 返回colorButton背景色
63 * @return
64 */
65 QColor backgroundColor();
66
67 /**
68 * @brief 设置圆角(RoundedRect,CheckedRect类型生效)
69 * @param radious
70 */
71 void setBorderRadius(int radious);
72
73 /**
74 * @brief 返回圆角
75 * @return
76 */
77 int borderRadius();
78
79 /**
80 * @brief 设置colorButton类型
81 * @param type
82 */
83 void setButtonType(KColorButton::ButtonType type);
84
85 /**
86 * @brief 返回colorButton类型
87 * @return
88 */
89 KColorButton::ButtonType buttonType();
90
91 protected:
92 void paintEvent(QPaintEvent *) override;
93 QSize sizeHint() const override;
94
95 private:
96 Q_DECLARE_PRIVATE(KColorButton)
97 KColorButtonPrivate *const d_ptr;
98 };
99
100 }
101
102 #endif // KCOLORBUTTON_H