Skip to content

Commit

Permalink
fix: adjust progressbar color
Browse files Browse the repository at this point in the history
adjust progressbar color

Log:
  • Loading branch information
Whale107 committed Aug 14, 2024
1 parent 43c5515 commit 81b6066
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions styleplugins/chameleon/chameleonstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1402,8 +1402,8 @@ void ChameleonStyle::drawControl(QStyle::ControlElement element, const QStyleOpt

QPen pen;
pen.setColor(DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::DarkType
? QColor(255, 255, 255, 0.15 * 255)
: QColor(0, 0, 0, 0.15 * 255));
? QColor(255, 255, 255, 0.1 * 255)
: QColor(0, 0, 0, 0.1 * 255));
pen.setWidth(1);
p->setPen(pen);
p->setBrush(Qt::NoBrush);
Expand Down Expand Up @@ -1449,6 +1449,9 @@ void ChameleonStyle::drawControl(QStyle::ControlElement element, const QStyleOpt
linear.setSpread(QGradient::PadSpread);
p->setBrush(startColor);

QColor borderColor = DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::DarkType
? DGuiApplicationHelper::adjustColor(getColor(opt, QPalette::Highlight), 0, 0, +10, 0, 0, 0, 0)
: DGuiApplicationHelper::adjustColor(getColor(opt, QPalette::Highlight), 0, 0, -20, 0, 0, 0, -20);
if (progBar->textVisible) {
QPainterPath pathRect;
pathRect.addRect(rect);
Expand All @@ -1464,9 +1467,7 @@ void ChameleonStyle::drawControl(QStyle::ControlElement element, const QStyleOpt
p->setClipping(false);

QPen pen;
pen.setColor(DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::DarkType
? QColor(255, 255, 255, 0.3 * 255)
: QColor(0, 0, 0, 0.3 * 255));
pen.setColor(borderColor);
pen.setWidth(1);
p->setPen(pen);
p->setBrush(Qt::NoBrush);
Expand Down Expand Up @@ -1506,7 +1507,7 @@ void ChameleonStyle::drawControl(QStyle::ControlElement element, const QStyleOpt
p->setClipping(false);

QPen pen;
pen.setColor(QColor(0, 0, 0, 0.3 * 255));
pen.setColor(borderColor);
pen.setWidth(1);
p->setPen(pen);
p->setBrush(Qt::NoBrush);
Expand All @@ -1526,7 +1527,7 @@ void ChameleonStyle::drawControl(QStyle::ControlElement element, const QStyleOpt

bool isHorizontal = (progressbar->orientation() == Qt::Horizontal);

constexpr int spotWidth = 200;
constexpr int spotWidth = 100;
if (isHorizontal ? rect.width() >= spotWidth : rect.height() >= spotWidth) {
p->setPen(Qt::NoPen);

Expand All @@ -1539,9 +1540,8 @@ void ChameleonStyle::drawControl(QStyle::ControlElement element, const QStyleOpt
progressAnimation->setObjectName("_d_progress_spot_animation");
}

QColor shadowColor(0, 0, 0, int(0.15 * 255));
QColor spotColor(255, 255, 255, int(0.5 * 255));
QColor highLightColor(getColor(opt, DPalette::Highlight));
QColor spotColor = DGuiApplicationHelper::adjustColor(highLightColor, 0, 0, +30, 0, 0, 0, 0);

QPointF pointStart, pointEnd;
if (isHorizontal) {
Expand All @@ -1553,18 +1553,17 @@ void ChameleonStyle::drawControl(QStyle::ControlElement element, const QStyleOpt
}
QLinearGradient linear(pointStart, pointEnd);
linear.setColorAt(0, highLightColor);
linear.setColorAt(0.35, shadowColor);
linear.setColorAt(0.5, spotColor);
linear.setColorAt(0.65, shadowColor);
linear.setColorAt(1, highLightColor);
linear.setSpread(QGradient::PadSpread);
linear.setInterpolationMode(QLinearGradient::InterpolationMode::ColorInterpolation);
p->setBrush(linear);

QPainterPath clipPath;
clipPath.addRoundedRect(rect, frameRadius, frameRadius);
clipPath.addRoundedRect(rect.marginsRemoved(QMargins(2, 2, 2, 2)), frameRadius, frameRadius);
p->setClipPath(clipPath);
p->setClipping(true);
p->drawRect(progressAnimation->currentValue().toRect().marginsRemoved(QMargins(1, 1, 1, 1)));
p->drawRect(progressAnimation->currentValue().toRect());
p->setClipping(false);

if (progressAnimation->state() == QVariantAnimation::Running) {
Expand Down

0 comments on commit 81b6066

Please sign in to comment.