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