did a minor reorganization of the menu

This commit is contained in:
tigerbot 2017-04-24 16:31:17 -06:00
parent 8f2912225b
commit af3adf660e
1 changed files with 62 additions and 107 deletions

169
menu.js
View File

@ -65,63 +65,41 @@ function init(window) {
win = window; win = window;
var template = [ var template = [
{
label: 'File',
submenu: [
{
role: 'close'
}
]
},
{ {
label: 'Edit', label: 'Edit',
submenu: [ submenu: [
{ { role: 'undo' },
role: 'undo' { role: 'redo' },
}, { type: 'separator' },
{
role: 'redo' { role: 'cut' },
}, { role: 'copy' },
{ { role: 'paste' },
type: 'separator' { role: 'pasteandmatchstyle' },
}, { role: 'delete' },
{ { role: 'selectall' }
role: 'cut'
},
{
role: 'copy'
},
{
role: 'paste'
},
{
role: 'delete'
},
{
role: 'selectall'
}
] ]
}, },
{ {
label: 'View', label: 'View',
submenu: [ submenu: [
{ { role: 'reload' },
label: 'Full Screen', { role: 'forcereload' },
type: 'checkbox', { type: 'separator' },
accelerator: process.platform === 'darwin' ? 'Ctrl+Command+F' : 'F11',
click: toggleFullScreen, { role: 'resetzoom' },
}, { role: 'zoomin' },
{ role: 'zoomout' },
{ type: 'separator' },
{ role: 'togglefullscreen' },
{ {
label: 'Float on Top', label: 'Float on Top',
type: 'checkbox', type: 'checkbox',
click: toggleAlwaysOnTop, click: toggleAlwaysOnTop,
}, },
{ { type: 'separator' },
type: 'separator'
},
{
type: 'separator'
},
{ {
label: 'Developer', label: 'Developer',
submenu: [ submenu: [
@ -141,76 +119,49 @@ function init(window) {
template.unshift({ template.unshift({
label: 'Electron Demo', label: 'Electron Demo',
submenu: [ submenu: [
{ { role: 'about' },
role: 'about' { type: 'separator' },
},
{
type: 'separator'
},
{ {
label: 'Preferences', label: 'Preferences',
accelerator: 'Cmd+,', accelerator: 'Cmd+,',
click: function () { console.log('TODO: implement preferences'); } click: function () { console.log('TODO: implement preferences'); }
}, },
{ { type: 'separator' },
type: 'separator'
}, { role: 'services', submenu: [] },
{ { type: 'separator' },
role: 'services', { role: 'hide' },
submenu: [] { role: 'hideothers' },
}, { role: 'unhide' },
{ { type: 'separator' },
type: 'separator'
}, { role: 'quit' }
{
role: 'hide'
},
{
role: 'hideothers'
},
{
role: 'unhide'
},
{
type: 'separator'
},
{
role: 'quit'
}
] ]
}); });
// Edit menu (Mac) // Edit menu (Mac)
template[2].submenu.push( template[2].submenu.push(
{ { type: 'separator' },
type: 'separator'
},
{ {
label: 'Speech', label: 'Speech',
submenu: [ submenu: [
{ { role: 'startspeaking' },
role: 'startspeaking' { role: 'stopspeaking' }
},
{
role: 'stopspeaking'
}
] ]
} }
); );
// Window menu (Mac) // Window menu (Mac)
template.push({ template.push({
role: 'window', role: 'Window',
submenu: [ submenu: [
{ { role: 'close' },
role: 'minimize' { role: 'minimize' },
}, { role: 'zoom' },
{ { type: 'separator' },
type: 'separator'
}, { role: 'front' }
{
role: 'front'
}
] ]
}); });
} }
@ -218,11 +169,16 @@ function init(window) {
// On Windows and Linux, open dialogs do not support selecting both files and // On Windows and Linux, open dialogs do not support selecting both files and
// folders and files, so add an extra menu item so there is one for each type. // folders and files, so add an extra menu item so there is one for each type.
if (process.platform === 'linux' || process.platform === 'win32') { if (process.platform === 'linux' || process.platform === 'win32') {
template.unshift({
label: 'File',
submenu: [
{ role: 'quit' },
]
});
// Edit menu (Windows, Linux) // Edit menu (Windows, Linux)
template[1].submenu.push( template[1].submenu.push(
{ { type: 'separator' },
type: 'separator'
},
{ {
label: 'Preferences', label: 'Preferences',
accelerator: 'CmdOrCtrl+,', accelerator: 'CmdOrCtrl+,',
@ -230,6 +186,15 @@ function init(window) {
} }
); );
// Window menu (Windows, Linux)
template.push({
role: 'Qindow',
submenu: [
{ role: 'minimize' },
{ role: 'close' },
]
});
// Add an help.about option // Add an help.about option
template.push({ template.push({
label: 'Help', label: 'Help',
@ -241,16 +206,6 @@ function init(window) {
], ],
}); });
} }
// Add "File > Quit" menu item so Linux distros where the system tray icon is
// missing will have a way to quit the app.
if (process.platform === 'linux') {
// File menu (Linux)
template[0].submenu.push({
label: 'Quit',
accelerator: 'CmdOrCtrl+Q',
click: function () { return app.quit(); }
});
}
menu = electron.Menu.buildFromTemplate(template); menu = electron.Menu.buildFromTemplate(template);
electron.Menu.setApplicationMenu(menu); electron.Menu.setApplicationMenu(menu);