Debian Codegraph @

kysdk-qtwidgets/src/kiconbar.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 KICONBAR_H
24 #define KICONBAR_H
25
26 #include "gui_g.h"
27 #include <QFrame>
28 #include <QIcon>
29 #include <QLabel>
30 #include <QString>
31
32 namespace kdk
33 {
34
35 /** @defgroup BarModule
36 * @{
37 */
38
39 class KIconBarPrivate;
40
41 /**
42 * @brief 图标和标题组合控件
43 * @since 1.0.0
44 */
45 class GUI_EXPORT KIconBar : public QFrame
46 {
47 Q_OBJECT
48 public:
49 KIconBar(QWidget *parent = nullptr);
50 KIconBar(const QString &iconName, const QString &text, QWidget *parent = nullptr);
51 ~KIconBar();
52
53 /**
54 * @brief 设置图标
55 * @param iconName
56 */
57 void setIcon(const QString &iconName);
58
59 /**
60 * @brief 设置图标
61 * @param icon
62 */
63 void setIcon(const QIcon &icon);
64
65 /**
66 * @brief 设置标题
67 * @param widgetName
68 */
69 void setWidgetName(const QString &widgetName);
70
71 /**
72 * @brief 获取标题label
73 * @return
74 */
75 QLabel *nameLabel();
76
77 /**
78 * @brief 获取图标label
79 * @return
80 */
81 QLabel *iconLabel();
82
83 Q_SIGNALS:
84 /**
85 * @brief 双击会发出双击信号,父widget可以绑定相应槽函数
86 */
87 void doubleClick();
88
89 protected:
90 void mouseDoubleClickEvent(QMouseEvent *event);
91 void resizeEvent(QResizeEvent *event);
92 QSize sizeHint() const override;
93
94 private:
95 Q_DECLARE_PRIVATE(KIconBar)
96 KIconBarPrivate *const d_ptr;
97 };
98 }
99 /**
100 * @example testWidget/testwidget.h
101 * @example testWidget/testwidget.cpp
102 * @}
103 */
104 #endif // KICONBAR_H