diff options
author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2024-02-02 16:35:29 +0100 |
---|---|---|
committer | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2024-02-13 00:53:25 +0100 |
commit | 5a032f0b3fcfb7dbd63e784dedaa8e27fc34ce3d (patch) | |
tree | 1c56dbf77df9b4523e45509f7fd86fb06bac0f42 /src/widgets/styles/qfusionstyle.cpp | |
parent | fc23fa459c5924bf1cc4564c7bce1fd59d7c972b (diff) |
QFusionStyle: Pass handling of FrameGroupBox to base style
The fusion style had an own handling for
PE_FrameGroupBox/SC_GroupBoxFrame but failed to handle all cases (e.g.
with checkbox, text and horizontal alignment) correct. In contrast, the
base class (QCommonStyle) is properly handling all those attributes and
returns a correct subControlRect(). Therefore remove the special
handling, let styleHint() return the correct value for
SH_GroupBox_TextLabelVerticalAlginment based on the groupBox's text
alignment and rely on QCommonStyle ability to calculate the correct
values.
Pick-to: 6.7 6.6
Fixes: QTBUG-85425
Fixes: QTBUG-95472
Change-Id: I98ccf861274026a8fd4a2ef436efc3bb009be056
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
Diffstat (limited to 'src/widgets/styles/qfusionstyle.cpp')
-rw-r--r-- | src/widgets/styles/qfusionstyle.cpp | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index a671be4d50..1682ebcfd3 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -346,16 +346,7 @@ void QFusionStyle::drawPrimitive(PrimitiveElement elem, case PE_FrameGroupBox: { QPixmap pixmap(":/qt-project.org/styles/commonstyle/images/fusion_groupbox.png"_L1); - int topMargin = 0; - auto control = qobject_cast<const QGroupBox *>(widget); - if (control && !control->isCheckable() && control->title().isEmpty()) { - // Shrinking the topMargin if Not checkable AND title is empty - topMargin = groupBoxTopMargin; - } else { - topMargin = qMax(pixelMetric(PM_IndicatorHeight, option, widget), option->fontMetrics.height()) + groupBoxTopMargin; - } - QRect frame = option->rect.adjusted(0, topMargin, 0, 0); - qDrawBorderPixmap(painter, frame, QMargins(6, 6, 6, 6), pixmap); + qDrawBorderPixmap(painter, option->rect, QMargins(6, 6, 6, 6), pixmap); break; } #endif // QT_CONFIG(groupbox) @@ -3333,12 +3324,8 @@ QRect QFusionStyle::subControlRect(ComplexControl control, const QStyleOptionCom const bool hasVerticalAlignment = (groupBoxTextAlignment & Qt::AlignVertical_Mask) == Qt::AlignVCenter; const int fontMetricsHeight = groupBox->text.isEmpty() ? 0 : groupBox->fontMetrics.height(); - rect = option->rect; if (subControl == SC_GroupBoxFrame) - if (hasVerticalAlignment) - return rect.adjusted(0, -(fontMetricsHeight + 4) / 2, 0, 0); - else - return rect; + return rect; else if (subControl == SC_GroupBoxContents) { QRect frameRect = option->rect.adjusted(0, 0, 0, -groupBoxBottomMargin); int margin = 3; @@ -3622,6 +3609,17 @@ int QFusionStyle::styleHint(StyleHint hint, const QStyleOption *option, const QW mask->region -= QRect(option->rect.right() , option->rect.top() + 3, 1, 2); return 1; } + break; + case SH_GroupBox_TextLabelVerticalAlignment: { + if (const auto *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) { + if (groupBox) { + const auto vAlign = groupBox->textAlignment & Qt::AlignVertical_Mask; + // default fusion style is AlignTop + return vAlign == 0 ? Qt::AlignTop : vAlign; + } + } + break; + } default: break; } |