QWindowsSystemTrayIcon: use high-dpi icons for notifications

Do not downscale the icon used for QSystemTrayIcon even though the msdn
documentation states that SM_CXICON/SM_CYICON should be used as the
size to avoid blurry icons in the notification.

Pick-to: 6.7 6.6
Fixes: QTBUG-103825
Change-Id: I2d466e895254aa3c41682290cc7864632c57d5d7
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
bb10
Christian Ehrlicher 2023-12-14 09:42:48 +01:00
parent 5358d7a5fe
commit 94809cdec0
1 changed files with 2 additions and 13 deletions

View File

@ -217,24 +217,13 @@ void QWindowsSystemTrayIcon::showMessage(const QString &title, const QString &me
qStringToLimitedWCharArray(title, tnd.szInfoTitle, 64);
tnd.uID = q_uNOTIFYICONID;
tnd.dwInfoFlags = NIIF_USER;
QSize size(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON));
const QSize largeIcon(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON));
const QSize more = icon.actualSize(largeIcon);
if (more.height() > (largeIcon.height() * 3/4) || more.width() > (largeIcon.width() * 3/4)) {
tnd.dwInfoFlags |= NIIF_LARGE_ICON;
size = largeIcon;
}
const auto size = icon.actualSize(QSize(256, 256));
QPixmap pm = icon.pixmap(size);
if (pm.isNull()) {
tnd.dwInfoFlags = NIIF_INFO;
} else {
if (pm.size() != size) {
qWarning("QSystemTrayIcon::showMessage: Wrong icon size (%dx%d), please add standard one: %dx%d",
pm.size().width(), pm.size().height(), size.width(), size.height());
pm = pm.scaled(size, Qt::IgnoreAspectRatio);
}
tnd.dwInfoFlags = NIIF_USER | NIIF_LARGE_ICON;
tnd.hBalloonIcon = qt_pixmapToWinHICON(pm);
}
tnd.hWnd = m_hwnd;