Browse Source

Added "Show System Tray indicator on unread messages" preference

Fixes #147
pull/291/merge
Ramiro Saenz 9 years ago
parent
commit
28f5730344
  1. 25
      app/view/preferences/Preferences.js
  2. 9
      electron/main.js
  3. 10
      electron/tray.js

25
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 (<code>Alt</code> 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'

9
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

10
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}`);

Loading…
Cancel
Save