Debian Codegraph @

kysdk-qtwidgets/src/knativetabbar.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 KNAVETABBAR_H
24 #define KNAVETABBAR_H
25
26 #include "gui_g.h"
27 #include "kcustomtabbar.h"
28 #include <QIcon>
29 #include <QTabBar>
30
31 namespace kdk
32 {
33
34 /** @defgroup BarModule
35 * @brief 支持三种样式
36 * @since 2.5.2.0
37 * {
38 */
39
40 enum KNativeTabbarStyle {
41 SegmentDark,
42 SegmentLight,
43 Sliding
44 };
45
46 class KNativeTabbarPrivate;
47
48 class GUI_EXPORT KNativeTabbar : public KCustomTabBar
49 {
50 Q_OBJECT
51
52 public:
53 KNativeTabbar(KNativeTabbarStyle barStyle = SegmentLight, QWidget *parent = nullptr);
54 ~KNativeTabbar();
55
56 /**
57 * @brief 设置TabBar样式
58 * @param barStyle
59 */
60 void setTabbarStyle(KNativeTabbarStyle barStyle);
61
62 /**
63 * @brief 返回TabBar样式
64 * @return
65 */
66 KNativeTabbarStyle barStyle();
67
68 /**
69 * @brief 设置圆角半径,只对SegmentDark,SegmentLight样式生效
70 * @param radius
71 */
72 void setBorderRadius(int radius);
73
74 /**
75 * @brief 获取圆角半径
76 * @return
77 */
78 int borderRadius();
79
80 /**
81 * @brief 设置背景色
82 * @param color
83 */
84 void setBackgroundColor(const QColor &color);
85 Q_SIGNALS:
86 /**
87 * @brief 鼠标右键信号
88 * @param point
89 */
90 void rightlicked(QPoint point);
91
92 protected:
93 QSize sizeHint() const;
94 QSize minimumTabSizeHint(int index) const;
95 QSize tabSizeHint(int index) const;
96 void paintEvent(QPaintEvent *event);
97
98 private:
99 Q_DECLARE_PRIVATE(KNativeTabbar)
100 KNativeTabbarPrivate *const d_ptr;
101 };
102 }
103 /**
104 * @example testtabbar/widget.h
105 * @example testtabbar/widget.cpp
106 * @}
107 */
108 #endif // KNAVETABBAR_H