Debian Codegraph @

kysdk-qtwidgets/src/kcomboboxwidget.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: Zhenyu Wang <[email protected]>
20 *
21 */
22
23 #ifndef KCOMBOBOXWIDGET_H
24 #define KCOMBOBOXWIDGET_H
25
26 #include "gui_g.h"
27 #include <QLabel>
28 #include <QToolButton>
29 #include <QWidget>
30
31 namespace kdk
32 {
33
34 /**
35 * @brief 可选择多个或者单个选项
36 * @since 2.5.2.0
37 */
38 class KComboBoxWidgetPrivate;
39 class KComboBoxWidget : public QWidget
40 {
41 Q_OBJECT
42 public:
43 KComboBoxWidget(QWidget *parent = nullptr);
44
45 /**
46 * @brief 设置combobox的选项列表
47 * @param list
48 */
49 void setStringList(QStringList list);
50
51 /**
52 * @brief 获取选中的列表
53 * @return
54 */
55 QStringList getChosenList();
56
57 /**
58 * @brief 设置主文本
59 * @param text
60 */
61 void setMainText(QString text);
62
63 /**
64 * @brief 获取弹出菜单
65 * @return
66 */
67 QMenu *menu();
68
69 protected:
70 void mouseReleaseEvent(QMouseEvent *event);
71 void mousePressEvent(QMouseEvent *event);
72 void leaveEvent(QEvent *e);
73 void enterEvent(QEvent *e);
74 void paintEvent(QPaintEvent *event);
75 signals:
76 void comBoxWidgetClicked();
77
78 private:
79 KComboBoxWidgetPrivate *const d_ptr;
80 Q_DECLARE_PRIVATE(KComboBoxWidget)
81 };
82 }
83
84 #endif // KCOMBOBOXWIDGET_H