Browse Source

Added new preference "Display behaviour"

To select Show in Taskbar, Show Tray Icon or both.
Fixes #646
v0.5.8
Ramiro Saenz 8 years ago
parent
commit
d611050d46
  1. 68
      app/view/preferences/Preferences.js
  2. 23
      electron/main.js
  3. 9
      electron/tray.js

68
app/view/preferences/Preferences.js

@ -15,12 +15,13 @@ Ext.define('Rambox.view.preferences.Preferences',{
} }
,title: 'Preferences' ,title: 'Preferences'
,width: 400 ,width: 420
,modal: true ,modal: true
,closable: true ,closable: true
,minimizable: false ,minimizable: false
,maximizable: false ,maximizable: false
,draggable: true ,draggable: true
,resizable: false
,buttons: [ ,buttons: [
{ {
text: 'Cancel' text: 'Cancel'
@ -62,33 +63,48 @@ Ext.define('Rambox.view.preferences.Preferences',{
,hidden: process.platform !== 'win32' ,hidden: process.platform !== 'win32'
} }
,{ ,{
xtype: 'checkbox' xtype: 'combo'
,name: 'skip_taskbar' ,name: 'window_display_behavior'
,boxLabel: 'Show in Taskbar' ,fieldLabel: 'Display behaviour'
,value: config.skip_taskbar ,labelAlign: 'left'
,reference: 'skipTaskbar' ,width: 380
,labelWidth: 105
,value: config.window_display_behavior
,displayField: 'label'
,valueField: 'value'
,editable: false
,store: Ext.create('Ext.data.Store', {
fields: ['value', 'label']
,data: [
{ 'value': 'show_taskbar', 'label': 'Show in Taskbar' }
,{ 'value': 'show_trayIcon', 'label': 'Show Tray Icon' }
,{ 'value': 'taskbar_tray', 'label': 'Show in Taskbar and Tray Icon' }
]
})
,hidden: process.platform === 'darwin' ,hidden: process.platform === 'darwin'
}, }
{ ,{
xtype: 'combo', xtype: 'combo'
name: 'window_close_behavior', ,name: 'window_close_behavior'
fieldLabel: 'When closing the main window', ,fieldLabel: 'When closing the main window'
labelAlign: 'top', ,labelAlign: 'left'
value: config.window_close_behavior, ,width: 380
displayField: 'label', ,labelWidth: 180
valueField: 'value', ,value: config.window_close_behavior
editable: false, ,displayField: 'label'
store: Ext.create('Ext.data.Store', { ,valueField: 'value'
fields: ['value', 'label'], ,editable: false
data : [ ,store: Ext.create('Ext.data.Store', {
{ 'value': 'keep_in_tray', 'label': 'Keep in tray' }, fields: ['value', 'label']
{ 'value': 'keep_in_tray_and_taskbar', 'label': 'Keep in tray and taskbar' }, ,data: [
{ 'value': 'quit', 'label': 'Quit' } { 'value': 'keep_in_tray', 'label': 'Keep in tray' }
,{ 'value': 'keep_in_tray_and_taskbar', 'label': 'Keep in tray and taskbar' }
,{ 'value': 'quit', 'label': 'Quit' }
] ]
}), })
hidden: process.platform === 'darwin' ,hidden: process.platform === 'darwin'
}, }
{ ,{
xtype: 'checkbox' xtype: 'checkbox'
,name: 'always_on_top' ,name: 'always_on_top'
,boxLabel: 'Always on top' ,boxLabel: 'Always on top'

23
electron/main.js

@ -22,7 +22,7 @@ const config = new Config({
defaults: { defaults: {
always_on_top: false always_on_top: false
,hide_menu_bar: false ,hide_menu_bar: false
,skip_taskbar: true ,window_display_behavior: 'taskbar_tray'
,auto_launch: !isDev ,auto_launch: !isDev
,window_close_behavior: 'keep_in_tray' ,window_close_behavior: 'keep_in_tray'
,start_minimized: false ,start_minimized: false
@ -132,7 +132,7 @@ function createWindow () {
,height: config.get('height') ,height: config.get('height')
,alwaysOnTop: config.get('always_on_top') ,alwaysOnTop: config.get('always_on_top')
,autoHideMenuBar: config.get('hide_menu_bar') ,autoHideMenuBar: config.get('hide_menu_bar')
,skipTaskbar: !config.get('skip_taskbar') ,skipTaskbar: config.get('window_display_behavior') === 'show_trayIcon'
,show: !config.get('start_minimized') ,show: !config.get('start_minimized')
,webPreferences: { ,webPreferences: {
webSecurity: false webSecurity: false
@ -262,14 +262,29 @@ ipcMain.on('setConfig', function(event, values) {
// hide_menu_bar // hide_menu_bar
mainWindow.setAutoHideMenuBar(values.hide_menu_bar); mainWindow.setAutoHideMenuBar(values.hide_menu_bar);
if ( !values.hide_menu_bar ) mainWindow.setMenuBarVisibility(true); if ( !values.hide_menu_bar ) mainWindow.setMenuBarVisibility(true);
// skip_taskbar
mainWindow.setSkipTaskbar(!values.skip_taskbar);
// always_on_top // always_on_top
mainWindow.setAlwaysOnTop(values.always_on_top); mainWindow.setAlwaysOnTop(values.always_on_top);
// auto_launch // auto_launch
values.auto_launch ? appLauncher.enable() : appLauncher.disable(); values.auto_launch ? appLauncher.enable() : appLauncher.disable();
// systemtray_indicator // systemtray_indicator
updateBadge(mainWindow.getTitle()); updateBadge(mainWindow.getTitle());
switch ( values.window_display_behavior ) {
case 'show_taskbar':
mainWindow.setSkipTaskbar(false);
tray.destroy();
break;
case 'show_trayIcon':
mainWindow.setSkipTaskbar(true);
tray.create(mainWindow, config);
break;
case 'taskbar_tray':
mainWindow.setSkipTaskbar(false);
tray.create(mainWindow, config);
break;
default:
break;
}
}); });
ipcMain.on('validateMasterPassword', function(event, pass) { ipcMain.on('validateMasterPassword', function(event, pass) {

9
electron/tray.js

@ -8,9 +8,7 @@ const MenuItem = electron.MenuItem;
var appIcon = null; var appIcon = null;
exports.create = function(win, config) { exports.create = function(win, config) {
if (process.platform === 'darwin' || appIcon) { if (process.platform === 'darwin' || appIcon || config.get('window_display_behavior') === 'show_taskbar' ) return;
return;
}
const icon = process.platform === 'linux' || process.platform === 'darwin' ? 'IconTray.png' : 'Icon.ico'; const icon = process.platform === 'linux' || process.platform === 'darwin' ? 'IconTray.png' : 'Icon.ico';
const iconPath = path.join(__dirname, `../resources/${icon}`); const iconPath = path.join(__dirname, `../resources/${icon}`);
@ -41,6 +39,11 @@ exports.create = function(win, config) {
}); });
}; };
exports.destroy = function() {
appIcon.destroy();
appIcon = null;
};
exports.setBadge = function(messageCount, showUnreadTray) { exports.setBadge = function(messageCount, showUnreadTray) {
if (process.platform === 'darwin' || !appIcon) return; if (process.platform === 'darwin' || !appIcon) return;

Loading…
Cancel
Save