QWindows11Style: Add horizontal offset for Qt::AlignVCenter Labels

The progressbar label overlaps with the progressbar grove, when
vertically centered aligned. This patch adds a y offset to the
label, in case it is vertically centered to avoid the overlap.

Fixes: QTBUG-128458
Pick-to: 6.9 6.8
Change-Id: Iac977f83f09c2e4d12d1e0ed5f0eab3120c07b96
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
This commit is contained in:
Wladimir Leuschner 2024-08-29 14:07:25 +02:00
parent 3070efb64a
commit 564633f9d4

View File

@ -1373,7 +1373,7 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op
if (const QStyleOptionProgressBar* progbaropt = qstyleoption_cast<const QStyleOptionProgressBar*>(option)) {
QRect rect = subElementRect(SE_ProgressBarLabel, progbaropt, widget);
painter->setPen(progbaropt->palette.text().color());
painter->drawText(rect, progbaropt->text,Qt::AlignVCenter|Qt::AlignLeft);
painter->drawText(rect, progbaropt->text,progbaropt->textAlignment);
}
break;
case CE_PushButtonLabel:
@ -1857,6 +1857,15 @@ QRect QWindows11Style::subElementRect(QStyle::SubElement element, const QStyleOp
ret = QWindowsVistaStyle::subElementRect(element, option, widget);
}
break;
case QStyle::SE_ProgressBarLabel:
if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
if (pb->textAlignment.testFlags(Qt::AlignVCenter)) {
ret = option->rect.adjusted(0, 6, 0, 0);
} else {
ret = QWindowsVistaStyle::subElementRect(element, option, widget);
}
}
break;
case QStyle::SE_HeaderLabel:
case QStyle::SE_HeaderArrow:
ret = QCommonStyle::subElementRect(element, option, widget);