Debian Codegraph @

kysdk-qtwidgets/src/kintrowidget.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 KINTROWIDGET_H
24 #define KINTROWIDGET_H
25
26 #include "gui_g.h"
27 #include <QWidget>
28
29 namespace kdk
30 {
31
32 enum ViewType {
33 IconView,
34 ListView
35 };
36
37 /**
38 * @defgroup FrameModule
39 * @since 2.5.2.0
40 */
41 class KIntroWidgetPrivate;
42
43 class GUI_EXPORT KIntroWidget : public QWidget
44 {
45 Q_OBJECT
46 public:
47 KIntroWidget(QWidget *parent = nullptr);
48
49 /**
50 * @brief 设置视图样式
51 * @param type
52 */
53 void setViewType(ViewType type);
54
55 /**
56 * @brief 设置主文本
57 * @param str
58 */
59 void setMainLabel(QString str);
60
61 /**
62 * @brief 设置次级文本
63 * @param str
64 */
65 void setSubLabel(QString str);
66
67 /**
68 * @brief 设置圆角
69 * @param radius
70 */
71 void setBorderRadius(int radius);
72
73 /**
74 * @brief 设置圆角
75 * @param bottomLeft
76 * @param topLeft
77 * @param topRight
78 * @param bottomRight
79 */
80 void setBorderRadius(int bottomLeft, int topLeft, int topRight, int bottomRight);
81
82 /**
83 * @brief 设置标题颜色
84 * @param color
85 */
86 void setTitleColor(QColor color);
87
88 Q_SIGNALS:
89 void rightClick(QPoint point);
90
91 protected:
92 void paintEvent(QPaintEvent *event);
93 bool eventFilter(QObject *watched, QEvent *event);
94 QSize sizeHint() const override;
95 void mousePressEvent(QMouseEvent *event);
96 void mouseReleaseEvent(QMouseEvent *event);
97
98 private:
99 Q_DECLARE_PRIVATE(KIntroWidget)
100 KIntroWidgetPrivate *const d_ptr;
101 };
102
103 }
104
105 #endif // KINTROWIDGET_H