| 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 KBREADCRUMB_H |
| 24 |
#define KBREADCRUMB_H |
| 25 |
|
| 26 |
#include <QTabBar> |
| 27 |
|
| 28 |
namespace kdk |
| 29 |
{ |
| 30 |
/** |
| 31 |
* @defgroup BreadCrumb |
| 32 |
*/ |
| 33 |
class KBreadCrumbPrivate; |
| 34 |
|
| 35 |
/** |
| 36 |
* @brief KBreadCrumbType,包括两种类型。 |
| 37 |
*/ |
| 38 |
enum KBreadCrumbType { |
| 39 |
FlatBreadCrumb, |
| 40 |
CubeBreadCrumb |
| 41 |
}; |
| 42 |
|
| 43 |
/** |
| 44 |
* @brief 面包屑控件 |
| 45 |
* @since 1.0.0 |
| 46 |
*/ |
| 47 |
class KBreadCrumb : public QTabBar |
| 48 |
{ |
| 49 |
Q_OBJECT |
| 50 |
|
| 51 |
public: |
| 52 |
explicit KBreadCrumb(QWidget *parent = nullptr); |
| 53 |
|
| 54 |
/** |
| 55 |
* @brief 设置图标 |
| 56 |
* @param icon |
| 57 |
*/ |
| 58 |
void setIcon(const QIcon &icon); |
| 59 |
|
| 60 |
/** |
| 61 |
* @brief 获取图标 |
| 62 |
* @return |
| 63 |
*/ |
| 64 |
QIcon icon() const; |
| 65 |
|
| 66 |
/** |
| 67 |
* @brief 返回按钮边框是否凸起 |
| 68 |
* @return |
| 69 |
*/ |
| 70 |
bool isFlat() const; |
| 71 |
|
| 72 |
/** |
| 73 |
* @brief 设置按钮边框是否凸起 |
| 74 |
* @param flat |
| 75 |
*/ |
| 76 |
void setFlat(bool flat); |
| 77 |
|
| 78 |
protected: |
| 79 |
QSize tabSizeHint(int index) const; |
| 80 |
void paintEvent(QPaintEvent *event); |
| 81 |
|
| 82 |
private: |
| 83 |
Q_DECLARE_PRIVATE(KBreadCrumb) |
| 84 |
KBreadCrumbPrivate *const d_ptr; |
| 85 |
}; |
| 86 |
} |
| 87 |
|
| 88 |
#endif // KBREADCRUMB_H |