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.6
Fixes: QTBUG-103825
Change-Id: I2d466e895254aa3c41682290cc7864632c57d5d7
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 94809cdec004611bdb8531304e6c74761014876b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Christian Ehrlicher 2023-12-14 09:42:48 +01:00 committed by Qt Cherry-pick Bot
parent ac04f0397b
commit 7c22796a97

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;