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

23
electron/main.js

@ -22,7 +22,7 @@ const config = new Config({
defaults: {
always_on_top: false
,hide_menu_bar: false
,skip_taskbar: true
,window_display_behavior: 'taskbar_tray'
,auto_launch: !isDev
,window_close_behavior: 'keep_in_tray'
,start_minimized: false
@ -132,7 +132,7 @@ function createWindow () {
,height: config.get('height')
,alwaysOnTop: config.get('always_on_top')
,autoHideMenuBar: config.get('hide_menu_bar')
,skipTaskbar: !config.get('skip_taskbar')
,skipTaskbar: config.get('window_display_behavior') === 'show_trayIcon'
,show: !config.get('start_minimized')
,webPreferences: {
webSecurity: false
@ -262,14 +262,29 @@ ipcMain.on('setConfig', function(event, values) {
// hide_menu_bar
mainWindow.setAutoHideMenuBar(values.hide_menu_bar);
if ( !values.hide_menu_bar ) mainWindow.setMenuBarVisibility(true);
// skip_taskbar
mainWindow.setSkipTaskbar(!values.skip_taskbar);
// always_on_top
mainWindow.setAlwaysOnTop(values.always_on_top);
// auto_launch
values.auto_launch ? appLauncher.enable() : appLauncher.disable();
// systemtray_indicator
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) {

9
electron/tray.js

@ -8,9 +8,7 @@ const MenuItem = electron.MenuItem;
var appIcon = null;
exports.create = function(win, config) {
if (process.platform === 'darwin' || appIcon) {
return;
}
if (process.platform === 'darwin' || appIcon || config.get('window_display_behavior') === 'show_taskbar' ) return;
const icon = process.platform === 'linux' || process.platform === 'darwin' ? 'IconTray.png' : 'Icon.ico';
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) {
if (process.platform === 'darwin' || !appIcon) return;

Loading…
Cancel
Save