QFusionStyle/CC_Slider: consistently turn anti-aliasing on

Amends e5f9738385d8fc49492bc759472a571e241a5501, which removed the
turning on of anti-aliasing, under the assumption that QCachedPainter
always turns on anti-aliasing (which was initially the case, but then
reverted in 1ad9330a9c56a59d407f5644fe547ba69c1a205b). On the other
hand, the later QCachedPainter instances still turned on anti-aliasing
explicitly.

Now we do so again consistently, but setting it on the painter we get;
QCachedPainter will then use the same render hints.

As a drive-by, constify the variables with the old painter states
consistently.

Change-Id: I2ed31ae42c77f07d8496dcb16b767def29203973
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
This commit is contained in:
Volker Hilsheimer 2024-11-18 11:47:29 +01:00
parent e9cabe22c1
commit 032db29bbc

View File

@ -2598,17 +2598,16 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption
bool ticksAbove = slider->tickPosition & QSlider::TicksAbove;
bool ticksBelow = slider->tickPosition & QSlider::TicksBelow;
const QColor activeHighlight = d->highlight(option->palette);
QBrush oldBrush = painter->brush();
QPen oldPen = painter->pen();
QColor shadowAlpha(Qt::black);
shadowAlpha.setAlpha(10);
QColor outline;
if (option->state & State_HasFocus && option->state & State_KeyboardFocusChange)
outline = d->highlightedOutline(option->palette);
else
outline = d->outline(option->palette);
const QBrush oldBrush = painter->brush();
const QPen oldPen = painter->pen();
const auto oldRenderHints = painter->renderHints();
const QColor shadowAlpha(0, 0, 0, 10); // Qt::black with 4% opacity
const QColor outline = (option->state & State_HasFocus
&& option->state & State_KeyboardFocusChange)
? d->highlightedOutline(option->palette)
: d->outline(option->palette);
painter->setRenderHint(QPainter::Antialiasing, true);
if ((option->subControls & SC_SliderGroove) && groove.isValid()) {
// draw background groove
QCachedPainter cp(painter, "slider_groove"_L1, option, groove.size(), groove);
@ -2671,7 +2670,6 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption
if (qGray(grooveOutline.rgb()) > qGray(highlightedoutline.rgb()))
grooveOutline = highlightedoutline;
cpBlue->setRenderHint(QPainter::Antialiasing, true);
cpBlue->translate(0.5, 0.5);
cpBlue->setPen(QPen(grooveOutline));
gradient.setColorAt(0, activeHighlight);
@ -2757,7 +2755,6 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption
QRect r = pixmapRect.adjusted(1, 1, -2, -2);
QLinearGradient gradient = qt_fusion_gradient(gradRect, d->buttonColor(option->palette),horizontal ? TopDown : FromLeft);
cp->setRenderHint(QPainter::Antialiasing, true);
cp->translate(0.5, 0.5);
cp->setPen(Qt::NoPen);
@ -2783,6 +2780,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption
}
painter->setBrush(oldBrush);
painter->setPen(oldPen);
painter->setRenderHints(oldRenderHints);
}
break;
#endif // QT_CONFIG(slider)