diff --git a/app/view/preferences/Preferences.js b/app/view/preferences/Preferences.js index 280c5eb6..da2cf920 100644 --- a/app/view/preferences/Preferences.js +++ b/app/view/preferences/Preferences.js @@ -44,6 +44,18 @@ Ext.define('Rambox.view.preferences.Preferences',{ ,items: [ { xtype: 'checkbox' + ,name: 'auto_launch' + ,boxLabel: 'Start automatically on system startup' + ,value: config.auto_launch + } + ,{ + xtype: 'checkbox' + ,name: 'start_minimized' + ,boxLabel: 'Start minimized' + ,value: config.start_minimized + } + ,{ + xtype: 'checkbox' ,name: 'hide_menu_bar' ,boxLabel: 'Auto-hide Menu bar (Alt key to display)' ,value: config.hide_menu_bar @@ -73,15 +85,10 @@ Ext.define('Rambox.view.preferences.Preferences',{ } ,{ xtype: 'checkbox' - ,name: 'start_minimized' - ,boxLabel: 'Start minimized' - ,value: config.start_minimized - } - ,{ - xtype: 'checkbox' - ,name: 'auto_launch' - ,boxLabel: 'Start automatically on system startup' - ,value: config.auto_launch + ,name: 'systemtray_indicator' + ,boxLabel: 'Show System Tray indicator on unread messages' + ,value: config.systemtray_indicator + ,hidden: Ext.os.is.MacOS } ,{ xtype: 'fieldset' diff --git a/electron/main.js b/electron/main.js index fbc80ebf..292e2543 100644 --- a/electron/main.js +++ b/electron/main.js @@ -23,6 +23,7 @@ const config = new Config({ ,auto_launch: !isDev ,keep_in_taskbar_on_close: true ,start_minimized: false + ,systemtray_indicator: true ,proxy: false ,proxyHost: '' ,proxyPort: '' @@ -203,16 +204,16 @@ function createWindow () { function updateBadge(title) { var messageCount = title.match(/\d+/g) ? parseInt(title.match(/\d+/g).join("")) : 0; - if (process.platform === 'win32') { // Windows - tray.setBadge(messageCount); + tray.setBadge(messageCount, config.get('systemtray_indicator')); + if (process.platform === 'win32') { // Windows if (messageCount === 0) { mainWindow.setOverlayIcon(null, ""); return; } mainWindow.webContents.send('setBadge', messageCount); - } else { // Linux and macOS + } else { // macOS app.setBadgeCount(messageCount); } } @@ -238,6 +239,8 @@ ipcMain.on('setConfig', function(event, values) { mainWindow.setAlwaysOnTop(values.always_on_top); // auto_launch values.auto_launch ? appLauncher.enable() : appLauncher.disable(); + // systemtray_indicator + updateBadge(mainWindow.getTitle()); }); // Handle Service Notifications diff --git a/electron/tray.js b/electron/tray.js index ec4e31cf..78547dc7 100644 --- a/electron/tray.js +++ b/electron/tray.js @@ -55,16 +55,14 @@ exports.create = function(win, config) { }); }; -exports.setBadge = shouldDisplayUnread => { - if (process.platform === 'darwin' || !appIcon) { - return; - } +exports.setBadge = function(messageCount, showUnreadTray) { + if (process.platform === 'darwin' || !appIcon) return; let icon; if (process.platform === 'linux') { - icon = shouldDisplayUnread ? 'IconTrayUnread.png' : 'IconTray.png'; + icon = messageCount && showUnreadTray ? 'IconTrayUnread.png' : 'IconTray.png'; } else { - icon = shouldDisplayUnread ? 'IconTrayUnread.ico' : 'Icon.ico'; + icon = messageCount && showUnreadTray ? 'IconTrayUnread.ico' : 'Icon.ico'; } const iconPath = path.join(__dirname, `../resources/${icon}`);