Debian Codegraph @

kysdk-qtwidgets/src/kcolorcombobox.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 KCOLORCOMBOBOX_H
24 #define KCOLORCOMBOBOX_H
25
26 #include "gui_g.h"
27 #include <QColor>
28 #include <QComboBox>
29 #include <QList>
30
31 namespace kdk
32 {
33
34 /**
35 * @defgroup ContainerModule
36 */
37 class KColorComboBoxPrivate;
38
39 /**
40 * @brief 颜色选择框
41 * @since 2.0.2.1
42 */
43 class GUI_EXPORT KColorComboBox : public QComboBox
44 {
45 Q_OBJECT
46
47 public:
48 /**
49 * @brief 指定显示样式,圆形或者圆角矩形
50 */
51 enum ComboType {
52 Circle,
53 RoundedRect
54 };
55
56 explicit KColorComboBox(QWidget *parent = nullptr);
57
58 /**
59 * @brief 以列表形式添加颜色选项
60 * @param list
61 */
62 void setColorList(const QList<QColor> &list);
63
64 /**
65 * @brief 获取颜色列表
66 * @return
67 */
68 QList<QColor> colorList();
69
70 /**
71 * @brief 添加颜色选项
72 * @param color
73 */
74 void addColor(const QColor &color);
75
76 /**
77 * @brief 设置显示样式
78 * @param type
79 */
80 void setComboType(const ComboType &type);
81
82 /**
83 * @brief 获取显示样式
84 * @return
85 */
86 ComboType comboType();
87
88 /**
89 * @brief 设置item尺寸
90 * @param size
91 */
92 void setPopupItemSize(const QSize &size);
93
94 /**
95 * @brief 返回item尺寸
96 * @return
97 */
98 QSize popupItemSzie();
99
100 Q_SIGNALS:
101
102 void activated(const QColor &color);
103 void currentColorChanged(const QColor &color);
104 void highlighted(const QColor &color);
105
106 protected:
107 void paintEvent(QPaintEvent *event) override;
108 void resizeEvent(QResizeEvent *event) override;
109
110 private:
111 Q_DECLARE_PRIVATE(KColorComboBox)
112 KColorComboBoxPrivate *const d_ptr;
113 };
114 }
115 #endif // KCOLORCOMBOBOX_H