QFusionStyle: fix excessive top margin of groupbox

The users voted for smaller top margin while there was neither title
nor checkbox.

Task-number: QTBUG-44056
Change-Id: I5bd5cabb094c9cdec379f20e206196f1b5432182
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
Yulong Bai 2018-10-15 15:37:41 +02:00
parent 17ac9f8ced
commit 211830b233

View File

@ -469,7 +469,14 @@ void QFusionStyle::drawPrimitive(PrimitiveElement elem,
case PE_FrameGroupBox:
{
QPixmap pixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_groupbox.png"));
int topMargin = qMax(pixelMetric(PM_ExclusiveIndicatorHeight), option->fontMetrics.height()) + groupBoxTopMargin;
int topMargin = 0;
auto control = dynamic_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_ExclusiveIndicatorHeight), option->fontMetrics.height()) + groupBoxTopMargin;
}
QRect frame = option->rect.adjusted(0, topMargin, 0, 0);
qDrawBorderPixmap(painter, frame, QMargins(6, 6, 6, 6), pixmap);
break;