From b24b9bba68821d4abb905d434e4b9442c65ff0c6 Mon Sep 17 00:00:00 2001 From: Wladimir Leuschner Date: Tue, 11 Mar 2025 15:48:13 +0100 Subject: [PATCH] WindowsQPA: Adjust close button and hover color for custom titlebar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adjust toe color of the close button to match the native color. Adjust the hover text color for the close in light mode to match the native behavior. Fixes: QTBUG-133945 Pick-to: 6.9 Change-Id: I2c9fafba9fee65f45f3878168b67b0d0a4b2a54c Reviewed-by: Tor Arne Vestbø Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowswindow.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 449036fd37f..fba0c620745 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -3500,7 +3500,7 @@ void QWindowsWindow::updateCustomTitlebar() qApp->styleHints()->colorScheme() == Qt::ColorScheme::Dark; const bool isWindows11orAbove = QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows11; - const QBrush closeButtonBrush(QColor(0xC4, 0x2B, 0x1C, 255)); + const QBrush closeButtonBrush(QColor(0xC4, 0x2C, 0x1E, 255)); const QBrush minMaxButtonBrush = QBrush(isDarkmode ? QColor(0xFF, 0xFF, 0xFF, 0x40) : QColor(0x00, 0x00, 0x00, 0x20)); const QBrush titleBarBackgroundColor = QBrush(isDarkmode ? QColor(0x1F, 0x1F, 0x1F, 0xFF) : QColor(0xF3, 0xF3, 0xF3, 0xFF)); const QPen textPen = QPen(isDarkmode ? QColor(0xFF, 0xFF, 0xFD, 0xFF) : QColor(0x00, 0x00, 0x00, 0xFF)); @@ -3584,9 +3584,12 @@ void QWindowsWindow::updateCustomTitlebar() _q_drawCustomTitleBarButton(p, rect); else p.drawRect(rect); + const QPen closeButtonHoveredPen = QPen(QColor(0xFF, 0xFF, 0xFD, 0xFF)); + p.setPen(closeButtonHoveredPen); + } else { + p.setPen(textPen); } - p.setPen(textPen); - p.drawText(rect,QStringLiteral("\uE8BB"), QTextOption(Qt::AlignVCenter | Qt::AlignHCenter)); + p.drawText(rect, QStringLiteral("\uE8BB"), QTextOption(Qt::AlignVCenter | Qt::AlignHCenter)); buttons++; }