summaryrefslogtreecommitdiffstats
path: root/src/widgets/util
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2016-05-30 10:21:54 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2016-06-10 21:49:45 +0000
commitb465fe759695bb7e1de693c3d4d20acfd2c49779 (patch)
tree991a351977b65d1c985e467544d62ba61f4f9e6c /src/widgets/util
parentcaa4e449379bad1bd58332bce878f03aee6a4d36 (diff)
QSystemTrayIcon/Windows: Use large icon for balloon message.
Use larger system metric SM_CXICON instead of SM_CXSMICON and set NIIF_LARGE_ICON in the NOTIFYICONDATA. De-inline function iconFlag() and set NIIF_USER for user icons for NIIF_LARGE_ICON to take effect. Task-number: QTBUG-53591 Change-Id: I47c8e0a020ef94241403b1fbae76d5ef2e074301 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/widgets/util')
-rw-r--r--src/widgets/util/qsystemtrayicon_win.cpp43
1 files changed, 23 insertions, 20 deletions
diff --git a/src/widgets/util/qsystemtrayicon_win.cpp b/src/widgets/util/qsystemtrayicon_win.cpp
index 7e0212a233..221d040599 100644
--- a/src/widgets/util/qsystemtrayicon_win.cpp
+++ b/src/widgets/util/qsystemtrayicon_win.cpp
@@ -230,22 +230,9 @@ void QSystemTrayIconSys::setIconContents(NOTIFYICONDATA &tnd)
qStringToLimitedWCharArray(tip, tnd.szTip, sizeof(tnd.szTip)/sizeof(wchar_t));
}
-static int iconFlag( QSystemTrayIcon::MessageIcon icon )
-{
- switch (icon) {
- case QSystemTrayIcon::Information:
- return NIIF_INFO;
- case QSystemTrayIcon::Warning:
- return NIIF_WARNING;
- case QSystemTrayIcon::Critical:
- return NIIF_ERROR;
- case QSystemTrayIcon::NoIcon:
- return NIIF_NONE;
- default:
- Q_ASSERT_X(false, "QSystemTrayIconSys::showMessage", "Invalid QSystemTrayIcon::MessageIcon value");
- return NIIF_NONE;
- }
-}
+#ifndef NIIF_LARGE_ICON
+# define NIIF_LARGE_ICON 0x00000020
+#endif
bool QSystemTrayIconSys::showMessage(const QString &title, const QString &message, QSystemTrayIcon::MessageIcon type, uint uSecs)
{
@@ -255,7 +242,22 @@ bool QSystemTrayIconSys::showMessage(const QString &title, const QString &messag
qStringToLimitedWCharArray(title, tnd.szInfoTitle, 64);
tnd.uID = q_uNOTIFYICONID;
- tnd.dwInfoFlags = iconFlag(type);
+ switch (type) {
+ case QSystemTrayIcon::Information:
+ tnd.dwInfoFlags = NIIF_INFO;
+ break;
+ case QSystemTrayIcon::Warning:
+ tnd.dwInfoFlags = NIIF_WARNING;
+ break;
+ case QSystemTrayIcon::Critical:
+ tnd.dwInfoFlags = NIIF_ERROR;
+ break;
+ case QSystemTrayIcon::NoIcon:
+ tnd.dwInfoFlags = hIcon ? NIIF_USER : NIIF_NONE;
+ break;
+ }
+ if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA)
+ tnd.dwInfoFlags |= NIIF_LARGE_ICON;
tnd.cbSize = notifyIconSize;
tnd.hWnd = m_hwnd;
tnd.uTimeout = uSecs;
@@ -296,9 +298,10 @@ HICON QSystemTrayIconSys::createIcon()
const QIcon icon = q->icon();
if (icon.isNull())
return oldIcon;
- const int iconSizeX = GetSystemMetrics(SM_CXSMICON);
- const int iconSizeY = GetSystemMetrics(SM_CYSMICON);
- const QSize size = icon.actualSize(QSize(iconSizeX, iconSizeY));
+ const QSize requestedSize = QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA
+ ? QSize(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON))
+ : QSize(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON));
+ const QSize size = icon.actualSize(requestedSize);
const QPixmap pm = icon.pixmap(size);
if (pm.isNull())
return oldIcon;