diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-04-17 16:23:29 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-04-18 13:23:48 +0200 |
commit | ca978e2c123aee991ee584cdd58edb338c25440b (patch) | |
tree | b8b49bb699fde8c98a2aa807cc09527e67016de3 /src/widgets | |
parent | cb30e45b9a800c6ad9cdfb446a20b6a6e8efbe71 (diff) |
QStyleSheet: rotate QSizeGrip image around center
Depending on the corner that the size grip lives in, the style sheet
style rotates the painter before rendering the drawable. However, that
needs to be done around the center of the size grip, not around the
origin, as otherwise the image rotates out of the rect.
Use a static array to map the corner to the rotation value, and
translate/rotate/translate back only if there is a rotation.
Pick-to: 6.5
Fixes: QTBUG-112252
Change-Id: I59f69385bd6699ecc8db46390c5f7cc933574ce8
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/styles/qstylesheetstyle.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 86a174a342..8e18c7245d 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -4254,12 +4254,11 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q if (rule.hasDrawable()) { rule.drawFrame(p, opt->rect); p->save(); - switch (sgOpt->corner) { - case Qt::BottomRightCorner: break; - case Qt::BottomLeftCorner: p->rotate(90); break; - case Qt::TopLeftCorner: p->rotate(180); break; - case Qt::TopRightCorner: p->rotate(270); break; - default: break; + static constexpr int rotation[] = { 180, 270, 90, 0 }; + if (rotation[sgOpt->corner]) { + p->translate(opt->rect.center()); + p->rotate(rotation[sgOpt->corner]); + p->translate(-opt->rect.center()); } rule.drawImage(p, opt->rect); p->restore(); |