summaryrefslogtreecommitdiffstats
path: root/src/plugins/styles/modernwindows/qwindows11style.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/styles/modernwindows/qwindows11style.cpp')
-rw-r--r--src/plugins/styles/modernwindows/qwindows11style.cpp28
1 files changed, 10 insertions, 18 deletions
diff --git a/src/plugins/styles/modernwindows/qwindows11style.cpp b/src/plugins/styles/modernwindows/qwindows11style.cpp
index b37140cba5e..bf4b3c6a9bc 100644
--- a/src/plugins/styles/modernwindows/qwindows11style.cpp
+++ b/src/plugins/styles/modernwindows/qwindows11style.cpp
@@ -236,7 +236,7 @@ static void drawArrow(const QStyle *style, const QStyleOptionToolButton *toolbut
}
#endif // QT_CONFIG(toolbutton)
-static qreal radioButtonInnerRadius(int state)
+static qreal radioButtonInnerRadius(QStyle::State state)
{
qreal radius = 7.0;
if (state & QStyle::State_Sunken)
@@ -353,7 +353,7 @@ void QWindows11Style::drawComplexControl(ComplexControl control, const QStyleOpt
if (widget && widget->testAttribute(Qt::WA_UnderMouse) && widget->isActiveWindow())
flags |= State_MouseOver;
- painter->save();
+ QPainterStateGuard psg(painter);
painter->setRenderHint(QPainter::Antialiasing);
if (d->transitionsEnabled() && option->styleObject) {
if (control == CC_Slider) {
@@ -536,10 +536,9 @@ void QWindows11Style::drawComplexControl(ComplexControl control, const QStyleOpt
v = nextInterval;
}
if (!lines.isEmpty()) {
- painter->save();
+ QPainterStateGuard psg(painter);
painter->translate(slrect.topLeft());
painter->drawLines(lines.constData(), lines.size());
- painter->restore();
}
}
if (sub & SC_SliderHandle) {
@@ -765,7 +764,6 @@ void QWindows11Style::drawComplexControl(ComplexControl control, const QStyleOpt
default:
QWindowsVistaStyle::drawComplexControl(control, option, painter, widget);
}
- painter->restore();
}
void QWindows11Style::drawPrimitive(PrimitiveElement element, const QStyleOption *option,
@@ -773,8 +771,8 @@ void QWindows11Style::drawPrimitive(PrimitiveElement element, const QStyleOption
const QWidget *widget) const {
QWindows11StylePrivate *d = const_cast<QWindows11StylePrivate*>(d_func());
- int state = option->state;
- painter->save();
+ const State state = option->state;
+ QPainterStateGuard psg(painter);
painter->setRenderHint(QPainter::Antialiasing);
if (d->transitionsEnabled() && option->styleObject && (element == PE_IndicatorCheckBox || element == PE_IndicatorRadioButton)) {
QObject *styleObject = option->styleObject; // Can be widget or qquickitem
@@ -1095,17 +1093,15 @@ void QWindows11Style::drawPrimitive(PrimitiveElement element, const QStyleOption
painter->setBrush(view->alternatingRowColors() ? vopt->palette.highlight() : WINUI3Colors[colorSchemeIndex][subtleHighlightColor]);
painter->setPen(Qt::NoPen);
if (isFirst) {
- painter->save();
+ QPainterStateGuard psg(painter);
painter->setClipRect(rect);
painter->drawRoundedRect(rect.marginsRemoved(QMargins(2, 2, -secondLevelRoundingRadius, 2)),
secondLevelRoundingRadius, secondLevelRoundingRadius);
- painter->restore();
} else if (isLast) {
- painter->save();
+ QPainterStateGuard psg(painter);
painter->setClipRect(rect);
painter->drawRoundedRect(rect.marginsRemoved(QMargins(-secondLevelRoundingRadius, 2, 2, 2)),
secondLevelRoundingRadius, secondLevelRoundingRadius);
- painter->restore();
} else {
painter->drawRect(vopt->rect.marginsRemoved(QMargins(0, 2, 0, 2)));
}
@@ -1185,7 +1181,6 @@ void QWindows11Style::drawPrimitive(PrimitiveElement element, const QStyleOption
default:
QWindowsVistaStyle::drawPrimitive(element, option, painter, widget);
}
- painter->restore();
}
/*!
@@ -1197,7 +1192,7 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op
Q_D(const QWindows11Style);
State flags = option->state;
- painter->save();
+ QPainterStateGuard psg(painter);
painter->setRenderHint(QPainter::Antialiasing);
switch (element) {
case QStyle::CE_ComboBoxLabel:
@@ -1794,17 +1789,15 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op
painter->drawRoundedRect(rect.marginsRemoved(QMargins(2, 2, 2, 2)),
secondLevelRoundingRadius, secondLevelRoundingRadius);
} else if (isFirst) {
- painter->save();
+ QPainterStateGuard psg(painter);
painter->setClipRect(rect);
painter->drawRoundedRect(rect.marginsRemoved(QMargins(2, 2, -secondLevelRoundingRadius, 2)),
secondLevelRoundingRadius, secondLevelRoundingRadius);
- painter->restore();
} else if (isLast) {
- painter->save();
+ QPainterStateGuard psg(painter);
painter->setClipRect(rect);
painter->drawRoundedRect(rect.marginsRemoved(QMargins(-secondLevelRoundingRadius, 2, 2, 2)),
secondLevelRoundingRadius, secondLevelRoundingRadius);
- painter->restore();
} else {
painter->drawRect(rect.marginsRemoved(QMargins(0, 2, 0, 2)));
}
@@ -1864,7 +1857,6 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op
default:
QWindowsVistaStyle::drawControl(element, option, painter, widget);
}
- painter->restore();
}
int QWindows11Style::styleHint(StyleHint hint, const QStyleOption *opt,