diff --git a/app/tray_icon.js b/app/tray_icon.js index d32ff7652..b3fe18cf0 100644 --- a/app/tray_icon.js +++ b/app/tray_icon.js @@ -11,11 +11,10 @@ let tray = null; function createTrayIcon(getMainWindow, messages) { // A smaller icon is needed on macOS - tray = new Tray( - process.platform === 'darwin' ? - path.join(__dirname, '..', 'images', 'icon_16.png') : - path.join(__dirname, '..', 'images', 'icon_256.png') - ); + const iconSize = process.platform === 'darwin' ? '16' : '256'; + const iconNoNewMessages = path.join(__dirname, '..', 'images', `icon_${iconSize}.png`); + + tray = new Tray(iconNoNewMessages); tray.toggleWindowVisibility = () => { const mainWindow = getMainWindow(); @@ -57,6 +56,15 @@ function createTrayIcon(getMainWindow, messages) { tray.setContextMenu(trayContextMenu); }; + tray.updateIcon = (unreadCount) => { + if (unreadCount > 0) { + const filename = `${String(unreadCount >= 10 ? 10 : unreadCount)}.png`; + tray.setImage(path.join(__dirname, '..', 'images', 'alert', iconSize, filename)); + } else { + tray.setImage(iconNoNewMessages); + } + }; + tray.on('click', tray.toggleWindowVisibility); tray.setToolTip(messages.trayTooltip.message); diff --git a/images/alert/16/1.png b/images/alert/16/1.png new file mode 100644 index 000000000..04231cdb5 Binary files /dev/null and b/images/alert/16/1.png differ diff --git a/images/alert/16/10.png b/images/alert/16/10.png new file mode 100644 index 000000000..7f786f012 Binary files /dev/null and b/images/alert/16/10.png differ diff --git a/images/alert/16/2.png b/images/alert/16/2.png new file mode 100644 index 000000000..d6fe9228e Binary files /dev/null and b/images/alert/16/2.png differ diff --git a/images/alert/16/3.png b/images/alert/16/3.png new file mode 100644 index 000000000..1492c4d29 Binary files /dev/null and b/images/alert/16/3.png differ diff --git a/images/alert/16/4.png b/images/alert/16/4.png new file mode 100644 index 000000000..61c027541 Binary files /dev/null and b/images/alert/16/4.png differ diff --git a/images/alert/16/5.png b/images/alert/16/5.png new file mode 100644 index 000000000..d88eb9329 Binary files /dev/null and b/images/alert/16/5.png differ diff --git a/images/alert/16/6.png b/images/alert/16/6.png new file mode 100644 index 000000000..62efd99a4 Binary files /dev/null and b/images/alert/16/6.png differ diff --git a/images/alert/16/7.png b/images/alert/16/7.png new file mode 100644 index 000000000..e1cd7aca6 Binary files /dev/null and b/images/alert/16/7.png differ diff --git a/images/alert/16/8.png b/images/alert/16/8.png new file mode 100644 index 000000000..9db9e4f3c Binary files /dev/null and b/images/alert/16/8.png differ diff --git a/images/alert/16/9.png b/images/alert/16/9.png new file mode 100644 index 000000000..aff6ae80b Binary files /dev/null and b/images/alert/16/9.png differ diff --git a/images/alert/256/1.png b/images/alert/256/1.png new file mode 100644 index 000000000..7b90f9ae5 Binary files /dev/null and b/images/alert/256/1.png differ diff --git a/images/alert/256/10.png b/images/alert/256/10.png new file mode 100644 index 000000000..f7cd406ba Binary files /dev/null and b/images/alert/256/10.png differ diff --git a/images/alert/256/2.png b/images/alert/256/2.png new file mode 100644 index 000000000..ca6006875 Binary files /dev/null and b/images/alert/256/2.png differ diff --git a/images/alert/256/3.png b/images/alert/256/3.png new file mode 100644 index 000000000..1583f59b8 Binary files /dev/null and b/images/alert/256/3.png differ diff --git a/images/alert/256/4.png b/images/alert/256/4.png new file mode 100644 index 000000000..74a0a887c Binary files /dev/null and b/images/alert/256/4.png differ diff --git a/images/alert/256/5.png b/images/alert/256/5.png new file mode 100644 index 000000000..45f054df9 Binary files /dev/null and b/images/alert/256/5.png differ diff --git a/images/alert/256/6.png b/images/alert/256/6.png new file mode 100644 index 000000000..81a680c04 Binary files /dev/null and b/images/alert/256/6.png differ diff --git a/images/alert/256/7.png b/images/alert/256/7.png new file mode 100644 index 000000000..03d07c7fe Binary files /dev/null and b/images/alert/256/7.png differ diff --git a/images/alert/256/8.png b/images/alert/256/8.png new file mode 100644 index 000000000..434e86ec0 Binary files /dev/null and b/images/alert/256/8.png differ diff --git a/images/alert/256/9.png b/images/alert/256/9.png new file mode 100644 index 000000000..3aae1842d Binary files /dev/null and b/images/alert/256/9.png differ diff --git a/js/conversation_controller.js b/js/conversation_controller.js index 9171a3925..043f5aa5a 100644 --- a/js/conversation_controller.js +++ b/js/conversation_controller.js @@ -64,6 +64,7 @@ window.setBadgeCount(0); window.document.title = window.config.title; } + window.updateTrayIcon(newUnreadCount); }, startPruning: function() { var halfHour = 30 * 60 * 1000; diff --git a/main.js b/main.js index e164f42ef..f154bad46 100644 --- a/main.js +++ b/main.js @@ -483,3 +483,8 @@ ipc.on('close-about', () => { } }); +ipc.on('update-tray-icon', (event, unreadCount) => { + if (tray) { + tray.updateIcon(unreadCount); + } +}); diff --git a/preload.js b/preload.js index 217e06a91..03423c389 100644 --- a/preload.js +++ b/preload.js @@ -34,6 +34,9 @@ window.closeAbout = function() { ipc.send('close-about'); }; + window.updateTrayIcon = function(unreadCount) { + ipc.send('update-tray-icon', unreadCount); + }; ipc.on('debug-log', function() { Whisper.events.trigger('showDebugLog');