Debian Codegraph @

kysdk-qtwidgets/src/kcrumb.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 KCRUMB_H
24 #define KCRUMB_H
25
26 #include "kcustomtabbar.h"
27 #include <QTabBar>
28
29 namespace kdk
30 {
31 /**
32 * @defgroup KCrumb
33 * @since 2.5.2.0
34 */
35 class KCrumbPrivate;
36
37 /**
38 * @brief KCrumbType,包括两种类型。
39 */
40 enum KCrumbType {
41 FlatBreadCrumb,
42 CubeBreadCrumb
43 };
44
45 /**
46 * @brief 面包屑控件
47 */
48 class KCrumb : public KCustomTabBar
49 {
50 Q_OBJECT
51
52 public:
53 explicit KCrumb(QWidget *parent = nullptr);
54
55 /**
56 * @brief 添加tab
57 * @param text
58 * @return
59 */
60 int addTab(const QString &text);
61
62 /**
63 * @brief 添加tab
64 * @param icon
65 * @param text
66 * @return
67 */
68 int addTab(const QIcon &icon, const QString &text);
69
70 /**
71 * @brief 在index位置插入tab
72 * @param index
73 * @param text
74 * @return
75 */
76 int insertTab(int index, const QString &text);
77
78 /**
79 * @brief 在index位置插入tab
80 * @param index
81 * @param icon
82 * @param text
83 * @return
84 */
85 int insertTab(int index, const QIcon &icon, const QString &text);
86
87 /**
88 * @brief 删除index位置的tab
89 * @param index
90 */
91 void removeTab(int index);
92
93 /**
94 * @brief 将from位置tab移至to位置
95 * @param from
96 * @param to
97 */
98 void moveTab(int from, int to);
99
100 /**
101 * @brief 设置图标
102 * @param icon
103 */
104 void setIcon(const QIcon &icon);
105
106 /**
107 * @brief 获取图标
108 * @return
109 */
110 QIcon icon() const;
111
112 /**
113 * @brief 返回按钮边框是否凸起
114 * @return
115 */
116 bool isFlat() const;
117
118 /**
119 * @brief 设置按钮边框是否凸起
120 * @param flat
121 */
122 void setFlat(bool flat);
123
124 public slots:
125 void leftScroll();
126 void rightScroll();
127
128 protected:
129 QSize tabSizeHint(int index) const;
130 void paintEvent(QPaintEvent *event);
131
132 private:
133 Q_DECLARE_PRIVATE(KCrumb)
134 KCrumbPrivate *const d_ptr;
135 };
136 }
137
138 #endif // KCRUMB_H