From 7c22796a976e354357191f43fb21ae5b9239425b Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Thu, 14 Dec 2023 09:42:48 +0100 Subject: [PATCH] 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 (cherry picked from commit 94809cdec004611bdb8531304e6c74761014876b) Reviewed-by: Qt Cherry-pick Bot --- .../platforms/windows/qwindowssystemtrayicon.cpp | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp index d9e84c379e0..6c88c5008df 100644 --- a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp +++ b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp @@ -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;