Fusion: Don't add unnecessarily extra padding for a groupbox

If there is not a title or an indicator for a groupbox, then there is no
reason to add extra padding for it when placing the contents of the
groupbox. So this accounts for when one or the other is not set so that
the space is used more evenly.

Fixes: QTBUG-86411
Change-Id: I536798b57e1195c5a13218f1f82431c4e91f6852
Pick-to: 5.15
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
Andy Shaw 2020-09-22 10:43:32 +02:00
parent 34b4dc11d9
commit 31a1b3280c

View File

@ -3437,7 +3437,12 @@ QRect QFusionStyle::subControlRect(ComplexControl control, const QStyleOptionCom
QRect frameRect = option->rect.adjusted(0, 0, 0, -groupBoxBottomMargin);
int margin = 3;
int leftMarginExtension = 0;
int topMargin = qMax(pixelMetric(PM_ExclusiveIndicatorHeight), option->fontMetrics.height()) + groupBoxTopMargin;
const int exclusiveIndicatorHeight = option->subControls.testFlag(SC_GroupBoxCheckBox) ?
pixelMetric(PM_ExclusiveIndicatorHeight) : 0;
const int fontMetricsHeight = groupBox->text.isEmpty() ? 0 :
groupBox->fontMetrics.height();
const int topMargin = qMax(exclusiveIndicatorHeight, fontMetricsHeight) +
groupBoxTopMargin;
return frameRect.adjusted(leftMarginExtension + margin, margin + topMargin, -margin, -margin - groupBoxBottomMargin);
}