From fd3918bcaa7c78d9daf6388b3c607d03f8e84ca4 Mon Sep 17 00:00:00 2001 From: Wladimir Leuschner Date: Thu, 29 Aug 2024 14:07:25 +0200 Subject: [PATCH] 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 Change-Id: Iac977f83f09c2e4d12d1e0ed5f0eab3120c07b96 Reviewed-by: Oliver Wolff (cherry picked from commit 564633f9d4e4cc8fa361de8165a9dfb203b7248e) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 4488dfcbf68163f4aee7575254c6c880c7e69ab1) --- src/plugins/styles/modernwindows/qwindows11style.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/plugins/styles/modernwindows/qwindows11style.cpp b/src/plugins/styles/modernwindows/qwindows11style.cpp index a433d9d7ac..81a5b50d4b 100644 --- a/src/plugins/styles/modernwindows/qwindows11style.cpp +++ b/src/plugins/styles/modernwindows/qwindows11style.cpp @@ -1343,7 +1343,7 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op if (const QStyleOptionProgressBar* progbaropt = qstyleoption_cast(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: @@ -1815,6 +1815,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(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);