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 Change-Id: Ifb479a7056e0841215d525c2346938bda31fc1c6 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> (cherry picked from commit 92a14cdc36c4b2c30e4c7dfe7568b1835cb63093) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
0159e662ee
commit
5641db1f9f
@ -3500,9 +3500,8 @@ void QWindowsWindow::updateCustomTitlebar()
|
|||||||
p.setPen(Qt::NoPen);
|
p.setPen(Qt::NoPen);
|
||||||
if (!wnd->flags().testFlags(Qt::NoTitleBarBackgroundHint)) {
|
if (!wnd->flags().testFlags(Qt::NoTitleBarBackgroundHint)) {
|
||||||
QRect titleRect;
|
QRect titleRect;
|
||||||
titleRect.setY(1);
|
|
||||||
titleRect.setX(2);
|
titleRect.setX(2);
|
||||||
titleRect.setWidth(windowWidth - 2);
|
titleRect.setWidth(windowWidth);
|
||||||
titleRect.setHeight(titleBarHeight);
|
titleRect.setHeight(titleBarHeight);
|
||||||
|
|
||||||
if (isWindows11orAbove) {
|
if (isWindows11orAbove) {
|
||||||
@ -3529,13 +3528,19 @@ void QWindowsWindow::updateCustomTitlebar()
|
|||||||
titleRect.setWidth(windowWidth);
|
titleRect.setWidth(windowWidth);
|
||||||
titleRect.setHeight(titleBarHeight);
|
titleRect.setHeight(titleBarHeight);
|
||||||
|
|
||||||
const QIcon icon = wnd->icon();
|
titleRect.adjust(factor * 4, 0, 0, 0);
|
||||||
if (!icon.isNull()) {
|
QRect iconRect(titleRect.x(), titleRect.y() + factor * 8, factor * 16, factor * 16);
|
||||||
titleRect.adjust(factor * 4, 0, 0, 0);
|
if (wnd->icon().isNull()) {
|
||||||
QRect iconRect(titleRect.x(), titleRect.y() + factor * 8, factor * 16, factor * 16);
|
static QIcon defaultIcon;
|
||||||
icon.paint(&p, iconRect);
|
if (defaultIcon.isNull()) {
|
||||||
titleRect.adjust(factor * 24, 0, 0, 0);
|
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);
|
p.setPen(textPen);
|
||||||
QFont titleFont = QWindowsIntegration::instance()->fontDatabase()->defaultFont();
|
QFont titleFont = QWindowsIntegration::instance()->fontDatabase()->defaultFont();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user