Skip to content

Commit

Permalink
doc: update docs for dcoloredprogressbar
Browse files Browse the repository at this point in the history
更新dcoloredprogressbar的文档

Log: update docs

Issue: linuxdeepin/dtk#94
  • Loading branch information
homehomehu authored and kegechen committed Jul 11, 2023
1 parent 454855b commit 54a0f1e
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 16 deletions.
Binary file added docs/images/dcoloredprogressbar1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/dcoloredprogressbar2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 43 additions & 2 deletions docs/widgets/dcoloredprogressbar.zh_CN.dox
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,47 @@

@class Dtk::Widget::DColoredProgressBar
@brief `DColoredProgressBar`和`QProgressBar`功能差不多一样,只是它可以根据显示的值更改其外观
@details
### 示例代码
#### main.cpp
```cpp
#include <DApplication>
#include <DMainWindow>
#include <DWidgetUtil>
#include <DColoredProgressBar>
#include <QVBoxLayout>

DWIDGET_USE_NAMESPACE

int main(int argc, char *argv[])
{
DApplication a(argc, argv);
DMainWindow w;
w.setMinimumSize(QSize(400, 200));

QWidget *progressWidget = new QWidget();

// 创建动态控件并添加到布局中
QVBoxLayout *progressLayout = new QVBoxLayout(progressWidget);
DColoredProgressBar *coloredProgressBar = new DColoredProgressBar();
coloredProgressBar->setRange(0, 100);
coloredProgressBar->setValue(90);
coloredProgressBar->addThreshold(30, QBrush(Qt::blue)); // 根据当前值的不同,使用不同的颜色显示进度
coloredProgressBar->addThreshold(90, QBrush(Qt::red));
progressLayout->addWidget(coloredProgressBar);

w.setCentralWidget(progressWidget);
w.show();
Dtk::Widget::moveToCenter(&w);

return a.exec();
}
```
### demo示例图片
#### 1. 当进度为 20% , 进度条颜色为蓝色:
@image html dcoloredprogressbar1.png
#### 2. 当进度为 90% , 意味着任务快要进行完成 , 进度条颜色为红色:
@image html dcoloredprogressbar2.png

@fn void DColoredProgressBar::addThreshold(int threshold, QBrush brush)
@brief `DColoredProgressBar::addThreshold `添加一个新的阈值,并指定达到该值后要使用的画笔。如果一个相同值的阈值已经存在,它将被覆盖。
Expand All @@ -17,6 +58,6 @@

@fn QList<int> DColoredProgressBar::thresholds() const
@brief `DColoredProgressBar::thresholds` 获取所有的thresholds值
@return 返回一个 threshold值的列表

@return 返回一个 threshold 值的列表
*/

28 changes: 14 additions & 14 deletions src/widgets/dcoloredprogressbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ DColoredProgressBarPrivate::DColoredProgressBarPrivate(DColoredProgressBar *q)
}

/*!
\class Dtk::Widget::DColoredProgressBar
\inmodule dtkwidget
\brief DColoredProgressBar is the same as QProgressBar, except it can change its appearance depending on the value displayed.
@~english
@class Dtk::Widget::DColoredProgressBar
@ingroup dtkwidget
@brief DColoredProgressBar is the same as QProgressBar, except it can change its appearance depending on the value displayed.
*/
DColoredProgressBar::DColoredProgressBar(QWidget *parent)
: QProgressBar(parent)
Expand All @@ -43,11 +43,11 @@ DColoredProgressBar::DColoredProgressBar(QWidget *parent)
}

/*!
\brief DColoredProgressBar::addThreshold adds a new threshold value and specifies the brush to use once that value is reached.
@~english
@brief DColoredProgressBar::addThreshold adds a new threshold value and specifies the brush to use once that value is reached.
If a threshold of the same value already exists, it will be overwritten.
\a brush The brush to use when the currently displayed value is no less than and less than the next threshold value.
\a threshold Minimum value for this brush to be used.
@param[in] brush The brush to use when the currently displayed value is no less than and less than the next threshold value.
@param[in] threshold Minimum value for this brush to be used.
*/
void DColoredProgressBar::addThreshold(int threshold, QBrush brush)
{
Expand All @@ -56,9 +56,9 @@ void DColoredProgressBar::addThreshold(int threshold, QBrush brush)
}

/*!
\brief DColoredProgressBar::removeThreshold removes a threshold.
\a threshold The threshold value to remove.
@~english
@brief DColoredProgressBar::removeThreshold removes a threshold.
@param[in] threshold The threshold value to remove.
*/
void DColoredProgressBar::removeThreshold(int threshold)
{
Expand All @@ -69,9 +69,9 @@ void DColoredProgressBar::removeThreshold(int threshold)
}

/*!
\brief DColoredProgressBar::threadsholds gets all threshold values.
\return A list of threshold values.
@~english
@brief DColoredProgressBar::threadsholds gets all threshold values.
@return A list of threshold values.
*/
QList<int> DColoredProgressBar::thresholds() const
{
Expand Down

0 comments on commit 54a0f1e

Please sign in to comment.