Skip to content

Commit

Permalink
chore: 更新滚动条样式,适配动画
Browse files Browse the repository at this point in the history
更新滚动条样式,适配动画

Log:
  • Loading branch information
Whale107 committed Jul 19, 2024
1 parent d4ae010 commit 87ff1d5
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion styleplugins/chameleon/chameleonstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,17 @@ void ChameleonStyle::drawControl(QStyle::ControlElement element, const QStyleOpt
int frameRadius = height / 2;

p->setBrush(getColor(opt, DPalette::ObviousBackground, w));
p->setPen(Qt::NoPen);
p->drawRoundedRect(opt->rect, frameRadius, frameRadius);

QPen pen;
pen.setColor(DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::DarkType
? QColor(255, 255, 255, 0.15 * 255)
: QColor(0, 0, 0, 0.15 * 255));
pen.setWidth(2);
p->setPen(pen);
p->setBrush(Qt::NoBrush);
p->drawRoundedRect(opt->rect.marginsRemoved(QMargins(1, 1, 1, 1)), frameRadius, frameRadius);
}
return;
}
Expand Down Expand Up @@ -1449,15 +1459,33 @@ void ChameleonStyle::drawControl(QStyle::ControlElement element, const QStyleOpt
linear.setColorAt(0, startColor);
linear.setColorAt(1, endColor);
linear.setSpread(QGradient::PadSpread);
p->setBrush(QBrush(linear));
p->setBrush(startColor);

if (progBar->textVisible) {
QPainterPath pathRect;
pathRect.addRect(rect);
QPainterPath pathRoundRect;
pathRoundRect.addRoundedRect(opt->rect, frameRadius, frameRadius);
QPainterPath inter = pathRoundRect.intersected(pathRect);

QPainterPath clipPath;
clipPath.addRoundedRect(rect, frameRadius, frameRadius);
p->setClipPath(clipPath);
p->setClipping(true);
p->drawPath(inter);
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.setWidth(2);
p->setPen(pen);
p->setBrush(Qt::NoBrush);
p->setClipping(true);
p->drawRoundedRect(rect.marginsRemoved(QMargins(1, 1, 1, 1)), frameRadius, frameRadius);
p->setClipping(false);

} else {
//进度条高度 <= 8px && 进度条宽度 <= 8px && value有效
if (rect.height() <= ProgressBar_MinimumStyleHeight &&
Expand Down Expand Up @@ -1489,6 +1517,16 @@ void ChameleonStyle::drawControl(QStyle::ControlElement element, const QStyleOpt
p->setClipPath(clipPath);
p->setClipping(true);
p->drawRoundedRect(rect, frameRadius, frameRadius);
p->setClipping(false);

QPen pen;
pen.setColor(QColor(0, 0, 0, 0.3 * 255));
pen.setWidth(2);
p->setPen(pen);
p->setBrush(Qt::NoBrush);
p->setClipping(true);
p->drawRoundedRect(rect.marginsRemoved(QMargins(1, 1, 1, 1)), frameRadius, frameRadius);
p->setClipping(false);
}
}
}
Expand Down

0 comments on commit 87ff1d5

Please sign in to comment.