diff --git a/styleplugins/chameleon/chameleonstyle.cpp b/styleplugins/chameleon/chameleonstyle.cpp index 52789bfc..0c55512b 100644 --- a/styleplugins/chameleon/chameleonstyle.cpp +++ b/styleplugins/chameleon/chameleonstyle.cpp @@ -1412,11 +1412,25 @@ void ChameleonStyle::drawControl(QStyle::ControlElement element, const QStyleOpt } case CE_ProgressBarGroove: { //滑槽显示 if (const QStyleOptionProgressBar *progBar = qstyleoption_cast(opt)) { - int height = progBar->orientation == Qt::Horizontal ? opt->rect.height() : opt->rect.width(); + 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(); 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; } @@ -1430,7 +1444,12 @@ void ChameleonStyle::drawControl(QStyle::ControlElement element, const QStyleOpt int max = progBar->maximum; int val = progBar->progress; int drawWidth = 0; - int height = progBar->orientation == Qt::Horizontal ? rect.height() : rect.width(); + + 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(); int frameRadius = height / 2; if (horizontal) { @@ -1449,7 +1468,7 @@ 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; @@ -1457,7 +1476,25 @@ void ChameleonStyle::drawControl(QStyle::ControlElement element, const QStyleOpt 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 && @@ -1489,6 +1526,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); } } }