Skip to content

Commit

Permalink
fix: 进度条圆角问题以及当进度为1时进度滑块未在进度槽中的问题
Browse files Browse the repository at this point in the history
进度条圆角问题以及当进度为1时进度滑块未在进度槽中的问题

Log: 进度条圆角问题以及当进度为1时进度滑块未在进度槽中的问题
Bug: https://pms.uniontech.com/bug-view-230475.html
Influence: DTK进度条
  • Loading branch information
Whale107 committed Jul 19, 2024
1 parent cc748a7 commit d4ae010
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions styleplugins/chameleon/chameleonstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1412,15 +1412,9 @@ void ChameleonStyle::drawControl(QStyle::ControlElement element, const QStyleOpt
}
case CE_ProgressBarGroove: { //滑槽显示
if (const QStyleOptionProgressBar *progBar = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
int frameRadius = DStyle::pixelMetric(PM_FrameRadius, opt, w);
bool horizontal = progBar->state & State_Horizontal;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
horizontal |= progBar->orientation == Qt::Horizontal;
#endif
int height = horizontal ? opt->rect.height() : opt->rect.width();
if (frameRadius * 2 >= height) {
frameRadius = qMin(height / 2, 4);
}
int height = progBar->orientation == Qt::Horizontal ? opt->rect.height() : opt->rect.width();
int frameRadius = height / 2;

p->setBrush(getColor(opt, DPalette::ObviousBackground, w));
p->drawRoundedRect(opt->rect, frameRadius, frameRadius);
}
Expand All @@ -1436,15 +1430,8 @@ void ChameleonStyle::drawControl(QStyle::ControlElement element, const QStyleOpt
int max = progBar->maximum;
int val = progBar->progress;
int drawWidth = 0;
int frameRadius = DStyle::pixelMetric(PM_FrameRadius, opt, w);
bool horizontal = progBar->state & State_Horizontal;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
horizontal |= progBar->orientation == Qt::Horizontal;
#endif
int height = horizontal ? rect.height() : rect.width();
if (frameRadius * 2 >= height) {
frameRadius = qMin(height / 2, 4);
}
int height = progBar->orientation == Qt::Horizontal ? rect.height() : rect.width();
int frameRadius = height / 2;

if (horizontal) {
drawWidth = (val * 1.0 / (max - min)) * rect.width();
Expand Down Expand Up @@ -1496,8 +1483,13 @@ void ChameleonStyle::drawControl(QStyle::ControlElement element, const QStyleOpt
path2.arcTo(endRect, 90, -180);
p->drawPath(path2);
}
} else
} else {
QPainterPath clipPath;
clipPath.addRoundedRect(opt->rect, frameRadius, frameRadius);
p->setClipPath(clipPath);
p->setClipping(true);
p->drawRoundedRect(rect, frameRadius, frameRadius);
}
}
}
return;
Expand Down

0 comments on commit d4ae010

Please sign in to comment.