|
|
@ -5,6 +5,21 @@ const app = electron.app; |
|
|
|
const BrowserWindow = electron.BrowserWindow; |
|
|
|
const BrowserWindow = electron.BrowserWindow; |
|
|
|
const shell = electron.shell; |
|
|
|
const shell = electron.shell; |
|
|
|
const appName = app.getName(); |
|
|
|
const appName = app.getName(); |
|
|
|
|
|
|
|
// AutoLaunch
|
|
|
|
|
|
|
|
var AutoLaunch = require('auto-launch'); |
|
|
|
|
|
|
|
// Global Settings
|
|
|
|
|
|
|
|
var globalSettings = require('./global_settings.js'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Configure AutoLaunch
|
|
|
|
|
|
|
|
const appLauncher = new AutoLaunch({ |
|
|
|
|
|
|
|
name: 'Rambox' |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
appLauncher.isEnabled().then(function(enabled){ |
|
|
|
|
|
|
|
if(enabled) return; |
|
|
|
|
|
|
|
return appLauncher.enable(); |
|
|
|
|
|
|
|
}).then(function(err){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
function sendAction(action) { |
|
|
|
function sendAction(action) { |
|
|
|
const win = BrowserWindow.getAllWindows()[0]; |
|
|
|
const win = BrowserWindow.getAllWindows()[0]; |
|
|
@ -158,6 +173,24 @@ let tpl = [ |
|
|
|
label: 'Close', |
|
|
|
label: 'Close', |
|
|
|
accelerator: 'CmdOrCtrl+W', |
|
|
|
accelerator: 'CmdOrCtrl+W', |
|
|
|
role: 'close' |
|
|
|
role: 'close' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
type: 'separator' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
label: 'Always on top', |
|
|
|
|
|
|
|
type: 'checkbox', |
|
|
|
|
|
|
|
checked: parseInt(globalSettings.get('always_on_top')) ? true : false, |
|
|
|
|
|
|
|
click: function(item, mainWindow) { |
|
|
|
|
|
|
|
if ( item.checked ) { |
|
|
|
|
|
|
|
globalSettings.set('always_on_top', 1); |
|
|
|
|
|
|
|
if (mainWindow) mainWindow.setAlwaysOnTop(true); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
globalSettings.set('always_on_top', 0); |
|
|
|
|
|
|
|
mainWindow.setAlwaysOnTop(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
globalSettings.save(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
] |
|
|
|
] |
|
|
|
}, |
|
|
|
}, |
|
|
@ -167,6 +200,111 @@ let tpl = [ |
|
|
|
} |
|
|
|
} |
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let preferences = [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
label: 'Auto-hide Menu bar', |
|
|
|
|
|
|
|
visible: process.platform === 'win32', |
|
|
|
|
|
|
|
type: 'checkbox', |
|
|
|
|
|
|
|
checked: parseInt(globalSettings.get('hide_menu_bar')) ? true : false, |
|
|
|
|
|
|
|
click: function(item, mainWindow) { |
|
|
|
|
|
|
|
if ( item.checked ) { |
|
|
|
|
|
|
|
electron.dialog.showMessageBox(mainWindow, { |
|
|
|
|
|
|
|
title: 'Don\'t need to see the menu bar all the time?' |
|
|
|
|
|
|
|
,message: 'To temporarily show the menu bar, just press the Alt key.' |
|
|
|
|
|
|
|
,buttons: ['OK'] |
|
|
|
|
|
|
|
,type: 'info' |
|
|
|
|
|
|
|
}, function() { |
|
|
|
|
|
|
|
mainWindow.focus(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
globalSettings.set('hide_menu_bar', 1); |
|
|
|
|
|
|
|
if (mainWindow) mainWindow.setAutoHideMenuBar(true); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
globalSettings.set('hide_menu_bar', 0); |
|
|
|
|
|
|
|
mainWindow.setAutoHideMenuBar(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
globalSettings.save(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
label: 'Show in Taskbar', |
|
|
|
|
|
|
|
type: 'checkbox', |
|
|
|
|
|
|
|
checked: parseInt(globalSettings.get('skip_taskbar')) ? false : true, |
|
|
|
|
|
|
|
click: function(item, mainWindow) { |
|
|
|
|
|
|
|
if ( item.checked ) { |
|
|
|
|
|
|
|
globalSettings.set('skip_taskbar', 0); |
|
|
|
|
|
|
|
globalSettings.set('keep_in_taskbar_on_close', 1); |
|
|
|
|
|
|
|
menu.items[0].submenu.items[process.platform === 'darwin' ? 2 : 0].submenu.items[2].enabled = true; |
|
|
|
|
|
|
|
menu.items[0].submenu.items[process.platform === 'darwin' ? 2 : 0].submenu.items[2].checked = true; |
|
|
|
|
|
|
|
if (mainWindow) mainWindow.setSkipTaskbar(false); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
globalSettings.set('skip_taskbar', 1); |
|
|
|
|
|
|
|
globalSettings.set('keep_in_taskbar_on_close', 0); |
|
|
|
|
|
|
|
menu.items[0].submenu.items[process.platform === 'darwin' ? 2 : 0].submenu.items[2].enabled = false; |
|
|
|
|
|
|
|
menu.items[0].submenu.items[process.platform === 'darwin' ? 2 : 0].submenu.items[2].checked = false; |
|
|
|
|
|
|
|
mainWindow.setSkipTaskbar(true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
globalSettings.save(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
label: 'Keep Rambox in the taskbar when close it', |
|
|
|
|
|
|
|
type: 'checkbox', |
|
|
|
|
|
|
|
enabled: parseInt(globalSettings.get('skip_taskbar')) ? false : true, |
|
|
|
|
|
|
|
checked: parseInt(globalSettings.get('keep_in_taskbar_on_close')) ? true : false, |
|
|
|
|
|
|
|
click: function(item) { |
|
|
|
|
|
|
|
if ( item.checked ) { |
|
|
|
|
|
|
|
globalSettings.set('keep_in_taskbar_on_close', 1); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
globalSettings.set('keep_in_taskbar_on_close', 0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
globalSettings.save(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
label: 'Always on top', |
|
|
|
|
|
|
|
type: 'checkbox', |
|
|
|
|
|
|
|
checked: parseInt(globalSettings.get('always_on_top')) ? true : false, |
|
|
|
|
|
|
|
click: function(item, mainWindow) { |
|
|
|
|
|
|
|
if ( item.checked ) { |
|
|
|
|
|
|
|
globalSettings.set('always_on_top', 1); |
|
|
|
|
|
|
|
if (mainWindow) mainWindow.setAlwaysOnTop(true); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
globalSettings.set('always_on_top', 0); |
|
|
|
|
|
|
|
mainWindow.setAlwaysOnTop(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
globalSettings.save(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
label: 'Start minimized', |
|
|
|
|
|
|
|
type: 'checkbox', |
|
|
|
|
|
|
|
checked: parseInt(globalSettings.get('start_minimized')) ? true : false, |
|
|
|
|
|
|
|
click: function(item) { |
|
|
|
|
|
|
|
if ( item.checked ) { |
|
|
|
|
|
|
|
globalSettings.set('start_minimized', 1); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
globalSettings.set('start_minimized', 0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
globalSettings.save(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
label: 'Start automatically on system startup', |
|
|
|
|
|
|
|
type: 'checkbox', |
|
|
|
|
|
|
|
checked: parseInt(globalSettings.get('auto_launch')) ? true : false, |
|
|
|
|
|
|
|
click: function(item) { |
|
|
|
|
|
|
|
if ( item.checked ) { |
|
|
|
|
|
|
|
appLauncher.enable(); |
|
|
|
|
|
|
|
globalSettings.set('auto_launch', 1); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
appLauncher.disable(); |
|
|
|
|
|
|
|
globalSettings.set('auto_launch', 0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
globalSettings.save(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
if (process.platform === 'darwin') { |
|
|
|
if (process.platform === 'darwin') { |
|
|
|
tpl.unshift({ |
|
|
|
tpl.unshift({ |
|
|
|
label: appName, |
|
|
|
label: appName, |
|
|
@ -180,6 +318,13 @@ if (process.platform === 'darwin') { |
|
|
|
{ |
|
|
|
{ |
|
|
|
type: 'separator' |
|
|
|
type: 'separator' |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
label: 'Preferences', |
|
|
|
|
|
|
|
submenu: preferences |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
type: 'separator' |
|
|
|
|
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
label: 'Services', |
|
|
|
label: 'Services', |
|
|
|
role: 'services', |
|
|
|
role: 'services', |
|
|
@ -218,6 +363,13 @@ if (process.platform === 'darwin') { |
|
|
|
tpl.unshift({ |
|
|
|
tpl.unshift({ |
|
|
|
label: 'File', |
|
|
|
label: 'File', |
|
|
|
submenu: [ |
|
|
|
submenu: [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
label: 'Preferences', |
|
|
|
|
|
|
|
submenu: preferences |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
type: 'separator' |
|
|
|
|
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
label: `Quit ${appName}`, |
|
|
|
label: `Quit ${appName}`, |
|
|
|
accelerator: 'Cmd+Q', |
|
|
|
accelerator: 'Cmd+Q', |
|
|
@ -240,4 +392,5 @@ if (process.platform === 'darwin') { |
|
|
|
|
|
|
|
|
|
|
|
tpl[tpl.length - 1].submenu = helpSubmenu; |
|
|
|
tpl[tpl.length - 1].submenu = helpSubmenu; |
|
|
|
|
|
|
|
|
|
|
|
module.exports = electron.Menu.buildFromTemplate(tpl); |
|
|
|
var menu = electron.Menu.buildFromTemplate(tpl); |
|
|
|
|
|
|
|
module.exports = menu; |
|
|
|