From a3fb8e9abcb006d0e924276261b9749eed42c516 Mon Sep 17 00:00:00 2001 From: Wladimir Leuschner Date: Tue, 11 Mar 2025 15:43:25 +0100 Subject: [PATCH] WindowsQPA: Add default window title to custom titlebar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In case that no window title was provided use the QCoreApplication::applicationName when Qt::WindowTitleHint was provided. Fixes: QTBUG-133942 Change-Id: Ieeff0ba97bd996225c6f83f691fc1c149e3d7172 Reviewed-by: Tor Arne Vestbø (cherry picked from commit 5d8c3a598588a950aa8dbab7a72cc5e6de7bd3a3) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/platforms/windows/qwindowswindow.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 0dc295cc8ce..84dfeb0dcd5 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -3487,7 +3487,7 @@ void QWindowsWindow::updateCustomTitlebar() const QBrush closeButtonBrush(QColor(0xC4, 0x2B, 0x1C, 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(255, 255, 255, 255) : QColor(0, 0, 0, 255)); + const QPen textPen = QPen(isDarkmode ? QColor(0xFF, 0xFF, 0xFD, 0xFF) : QColor(0x00, 0x00, 0x00, 0xFF)); QImage image(windowWidth, titleBarHeight, QImage::Format_ARGB32); QPainter p(&image); @@ -3543,7 +3543,8 @@ void QWindowsWindow::updateCustomTitlebar() titleFont.setWeight(QFont::Thin); titleFont.setHintingPreference(QFont::PreferFullHinting); p.setFont(titleFont); - p.drawText(titleRect, wnd->title(), QTextOption(Qt::AlignVCenter)); + const QString title = wnd->title().isEmpty() ? qApp->applicationName() : wnd->title(); + p.drawText(titleRect, title, QTextOption(Qt::AlignVCenter)); } int buttons = 1;