diff options
author | Wladimir Leuschner <[email protected]> | 2025-02-24 15:25:40 +0100 |
---|---|---|
committer | Wladimir Leuschner <[email protected]> | 2025-03-17 17:03:22 +0100 |
commit | 92a14cdc36c4b2c30e4c7dfe7568b1835cb63093 (patch) | |
tree | e73020fb381e7cdfe0e1709074ad4a337dc8e248 | |
parent | b24b9bba68821d4abb905d434e4b9442c65ff0c6 (diff) |
WindowsQPA: Add default icon to custom titlebar
In case that no application icon was provided, use the IDI_APPLICATION
icon when Qt::WindowTitleHint was provided.
Fixes: QTBUG-133941
Pick-to: 6.9
Change-Id: Ifb479a7056e0841215d525c2346938bda31fc1c6
Reviewed-by: Tor Arne Vestbø <[email protected]>
Reviewed-by: Oliver Wolff <[email protected]>
-rw-r--r-- | src/plugins/platforms/windows/qwindowswindow.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index fba0c620745..77e0cbfcaa6 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -3516,9 +3516,8 @@ void QWindowsWindow::updateCustomTitlebar() p.setPen(Qt::NoPen); if (!wnd->flags().testFlags(Qt::NoTitleBarBackgroundHint)) { QRect titleRect; - titleRect.setY(1); titleRect.setX(2); - titleRect.setWidth(windowWidth - 2); + titleRect.setWidth(windowWidth); titleRect.setHeight(titleBarHeight); if (isWindows11orAbove) { @@ -3545,13 +3544,19 @@ void QWindowsWindow::updateCustomTitlebar() titleRect.setWidth(windowWidth); titleRect.setHeight(titleBarHeight); - const QIcon icon = wnd->icon(); - if (!icon.isNull()) { - titleRect.adjust(factor * 4, 0, 0, 0); - QRect iconRect(titleRect.x(), titleRect.y() + factor * 8, factor * 16, factor * 16); - icon.paint(&p, iconRect); - titleRect.adjust(factor * 24, 0, 0, 0); + titleRect.adjust(factor * 4, 0, 0, 0); + QRect iconRect(titleRect.x(), titleRect.y() + factor * 8, factor * 16, factor * 16); + if (wnd->icon().isNull()) { + static QIcon defaultIcon; + if (defaultIcon.isNull()) { + const QImage defaultIconImage = QImage::fromHICON(LoadIcon(0, IDI_APPLICATION)); + defaultIcon = QIcon(QPixmap::fromImage(defaultIconImage)); + } + defaultIcon.paint(&p, iconRect); + } else { + wnd->icon().paint(&p, iconRect); } + titleRect.adjust(factor * 24, 0, 0, 0); p.setPen(textPen); QFont titleFont = QWindowsIntegration::instance()->fontDatabase()->defaultFont(); |