diff options
author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2024-01-14 17:50:39 +0100 |
---|---|---|
committer | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2024-01-16 00:01:43 +0100 |
commit | 43ce457cbd093fc06d99b5ac833c789ef7c893d5 (patch) | |
tree | 3cc4e2c5e6df2f1b7877124786e7db38cd90e85f /src/widgets/styles/qfusionstyle.cpp | |
parent | 72ee1df260d728a1e699bd4c6e03bf202c929cbd (diff) |
Widgets: pass widget to QStyle::pixelMetric()
Make sure to pass the widget to QStyle::pixelMetric() as some styles
might use this (e.g. the new windows styles) to determine the correct
pixel metric.
Pick-to: 6.7 6.6 6.5 6.2
Task-number: QTBUG-1857
Change-Id: I5c32f5af8b284749732b610e56b4e3d8c8ed1946
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src/widgets/styles/qfusionstyle.cpp')
-rw-r--r-- | src/widgets/styles/qfusionstyle.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 7b0d391c89..9a42ac579e 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -352,7 +352,7 @@ void QFusionStyle::drawPrimitive(PrimitiveElement elem, // Shrinking the topMargin if Not checkable AND title is empty topMargin = groupBoxTopMargin; } else { - topMargin = qMax(pixelMetric(PM_ExclusiveIndicatorHeight), option->fontMetrics.height()) + groupBoxTopMargin; + topMargin = qMax(pixelMetric(PM_ExclusiveIndicatorHeight, option, widget), option->fontMetrics.height()) + groupBoxTopMargin; } QRect frame = option->rect.adjusted(0, topMargin, 0, 0); qDrawBorderPixmap(painter, frame, QMargins(6, 6, 6, 6), pixmap); @@ -3032,7 +3032,7 @@ QSize QFusionStyle::sizeFromContents(ContentsType type, const QStyleOption *opti break; case CT_GroupBox: if (option) { - int topMargin = qMax(pixelMetric(PM_ExclusiveIndicatorHeight), option->fontMetrics.height()) + groupBoxTopMargin; + int topMargin = qMax(pixelMetric(PM_ExclusiveIndicatorHeight, option, widget), option->fontMetrics.height()) + groupBoxTopMargin; newSize += QSize(10, topMargin); // Add some space below the groupbox } break; @@ -3216,8 +3216,8 @@ QRect QFusionStyle::subControlRect(ComplexControl control, const QStyleOptionCom case SC_SliderHandle: { const bool bothTicks = (slider->tickPosition & QSlider::TicksBothSides) == QSlider::TicksBothSides; if (slider->orientation == Qt::Horizontal) { - rect.setHeight(proxy()->pixelMetric(PM_SliderThickness, option)); - rect.setWidth(proxy()->pixelMetric(PM_SliderLength, option)); + rect.setHeight(proxy()->pixelMetric(PM_SliderThickness, option, widget)); + rect.setWidth(proxy()->pixelMetric(PM_SliderLength, option, widget)); int centerY = slider->rect.center().y() - rect.height() / 2; if (!bothTicks) { if (slider->tickPosition & QSlider::TicksAbove) @@ -3227,8 +3227,8 @@ QRect QFusionStyle::subControlRect(ComplexControl control, const QStyleOptionCom } rect.moveTop(centerY); } else { - rect.setWidth(proxy()->pixelMetric(PM_SliderThickness, option)); - rect.setHeight(proxy()->pixelMetric(PM_SliderLength, option)); + rect.setWidth(proxy()->pixelMetric(PM_SliderThickness, option, widget)); + rect.setHeight(proxy()->pixelMetric(PM_SliderLength, option, widget)); int centerX = slider->rect.center().x() - rect.width() / 2; if (!bothTicks) { if (slider->tickPosition & QSlider::TicksAbove) @@ -3325,7 +3325,7 @@ QRect QFusionStyle::subControlRect(ComplexControl control, const QStyleOptionCom int margin = 3; int leftMarginExtension = 0; const int exclusiveIndicatorHeight = option->subControls.testFlag(SC_GroupBoxCheckBox) ? - pixelMetric(PM_ExclusiveIndicatorHeight) : 0; + pixelMetric(PM_ExclusiveIndicatorHeight, option, widget) : 0; const int topMargin = qMax(exclusiveIndicatorHeight, fontMetricsHeight) + groupBoxTopMargin; return frameRect.adjusted(leftMarginExtension + margin, margin + topMargin, -margin, -margin - groupBoxBottomMargin); |