| 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 KPROGRESSBAR_H |
| 24 |
#define KPROGRESSBAR_H |
| 25 |
|
| 26 |
#include "gui_g.h" |
| 27 |
#include <QProgressBar> |
| 28 |
|
| 29 |
namespace kdk |
| 30 |
{ |
| 31 |
|
| 32 |
/** @defgroup BarModule |
| 33 |
* @{ |
| 34 |
*/ |
| 35 |
|
| 36 |
/** |
| 37 |
* @brief 支持三种状态 |
| 38 |
* @since 1.0.0 |
| 39 |
*/ |
| 40 |
enum ProgressBarState { |
| 41 |
NormalProgress, |
| 42 |
FailedProgress, |
| 43 |
SuccessProgress |
| 44 |
}; |
| 45 |
class KProgressBarPrivate; |
| 46 |
|
| 47 |
/** |
| 48 |
* @brief 进度条,支持三种状态显示 |
| 49 |
*/ |
| 50 |
class GUI_EXPORT KProgressBar : public QProgressBar |
| 51 |
{ |
| 52 |
Q_OBJECT |
| 53 |
|
| 54 |
public: |
| 55 |
KProgressBar(QWidget *parent); |
| 56 |
|
| 57 |
/** |
| 58 |
* @brief 获取状态 |
| 59 |
* @return |
| 60 |
*/ |
| 61 |
ProgressBarState state(); |
| 62 |
|
| 63 |
/** |
| 64 |
* @brief 设置状态 |
| 65 |
* @param state |
| 66 |
*/ |
| 67 |
void setState(ProgressBarState state); |
| 68 |
|
| 69 |
/** |
| 70 |
* @brief 获取文本 |
| 71 |
* @return |
| 72 |
*/ |
| 73 |
QString text() const override; |
| 74 |
|
| 75 |
/** |
| 76 |
* @brief 设置方向 |
| 77 |
*/ |
| 78 |
void setOrientation(Qt::Orientation); |
| 79 |
|
| 80 |
/** |
| 81 |
* @brief 设置进度条宽度 |
| 82 |
* @param width |
| 83 |
* @since 1.2.0 |
| 84 |
*/ |
| 85 |
void setBodyWidth(int width); |
| 86 |
|
| 87 |
/** |
| 88 |
* @brief 设置首尾位置的渐变颜色 |
| 89 |
* @since 2.5.2.0 |
| 90 |
* @param color1 |
| 91 |
* @param color2 |
| 92 |
*/ |
| 93 |
void setGradationColor(QColor color1, QColor color2); |
| 94 |
|
| 95 |
/** |
| 96 |
* @brief 设置背景色 |
| 97 |
* @since 2.5.2.0 |
| 98 |
* @param color |
| 99 |
*/ |
| 100 |
void setBackgroundColor(QColor color); |
| 101 |
|
| 102 |
/** |
| 103 |
* @brief 设置填充色 |
| 104 |
* @since 2.5.2.0 |
| 105 |
* @param color |
| 106 |
*/ |
| 107 |
void setFillColor(QColor color); |
| 108 |
|
| 109 |
/** |
| 110 |
* @brief 是否启用自定义渐变色 |
| 111 |
* @since 2.5.2.0 |
| 112 |
* @param flag |
| 113 |
*/ |
| 114 |
void setGradation(bool flag); |
| 115 |
|
| 116 |
/** |
| 117 |
* @brief 获取是否启用自定义渐变色 |
| 118 |
* @since 2.5.2.0 |
| 119 |
* @return |
| 120 |
*/ |
| 121 |
bool gradation(); |
| 122 |
|
| 123 |
/** |
| 124 |
* @brief 是否启用动画 |
| 125 |
* @since 2.5.2.0 |
| 126 |
* @param flag |
| 127 |
*/ |
| 128 |
void setAnimation(bool flag); |
| 129 |
|
| 130 |
/** |
| 131 |
* @brief 获取是否启用动画 |
| 132 |
* @since 2.5.2.0 |
| 133 |
* @return |
| 134 |
*/ |
| 135 |
bool animation(); |
| 136 |
|
| 137 |
protected: |
| 138 |
void paintEvent(QPaintEvent *event) override; |
| 139 |
QSize sizeHint() const; |
| 140 |
|
| 141 |
private: |
| 142 |
Q_DECLARE_PRIVATE(KProgressBar) |
| 143 |
KProgressBarPrivate *const d_ptr; |
| 144 |
}; |
| 145 |
} |
| 146 |
/** |
| 147 |
* @example testprogressbar/widget.h |
| 148 |
* @example testprogressbar/widget.cpp |
| 149 |
* @} |
| 150 |
*/ |
| 151 |
#endif // KPROGRESSBAR_H |