Browse Source

Improved Menu using roles and add new options

Fixes #188
Fixes #161
pull/291/merge
Ramiro Saenz 9 years ago
parent
commit
b5a00c08fa
  1. 69
      electron/menu.js

69
electron/menu.js

@ -98,38 +98,32 @@ let tpl = [
label: 'Edit', label: 'Edit',
submenu: [ submenu: [
{ {
label: 'Undo',
accelerator: 'CmdOrCtrl+Z',
role: 'undo' role: 'undo'
}, },
{ {
label: 'Redo',
accelerator: 'Shift+CmdOrCtrl+Z',
role: 'redo' role: 'redo'
}, },
{ {
type: 'separator' type: 'separator'
}, },
{ {
label: 'Cut',
accelerator: 'CmdOrCtrl+X',
role: 'cut' role: 'cut'
}, },
{ {
label: 'Copy',
accelerator: 'CmdOrCtrl+C',
role: 'copy' role: 'copy'
}, },
{ {
label: 'Paste',
accelerator: 'CmdOrCtrl+V',
role: 'paste' role: 'paste'
}, },
{ {
label: 'Select All', role: 'pasteandmatchstyle'
accelerator: 'CmdOrCtrl+A', },
{
role: 'selectall' role: 'selectall'
}, },
{
role: 'delete'
}
] ]
}, },
{ {
@ -143,21 +137,17 @@ let tpl = [
} }
}, },
{ {
label: 'Toggle Full Screen', type: 'separator'
accelerator: process.platform === 'darwin' ? 'Ctrl+Command+F' : 'F11',
click(item, focusedWindow) {
if (focusedWindow)
focusedWindow.setFullScreen(!focusedWindow.isFullScreen());
}
}, },
{ {
label: 'Toggle Developer Tools', role: 'zoomin'
accelerator: process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I', },
click(item, focusedWindow) { {
if (focusedWindow) role: 'zoomout'
focusedWindow.webContents.toggleDevTools();
}
}, },
{
role: 'resetzoom'
}
] ]
}, },
{ {
@ -178,18 +168,13 @@ let tpl = [
type: 'separator' type: 'separator'
}, },
{ {
label: 'Always on top', role: 'togglefullscreen'
type: 'checkbox', },
checked: parseInt(globalSettings.get('always_on_top')) ? true : false, {
click: function(item, mainWindow) { label: 'Toggle Developer Tools',
if ( item.checked ) { accelerator: process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I',
globalSettings.set('always_on_top', 1); click(item, focusedWindow) {
if (mainWindow) mainWindow.setAlwaysOnTop(true); if (focusedWindow) focusedWindow.webContents.toggleDevTools();
} else {
globalSettings.set('always_on_top', 0);
mainWindow.setAlwaysOnTop(false);
}
globalSettings.save();
} }
} }
] ]
@ -359,11 +344,7 @@ if (process.platform === 'darwin') {
type: 'separator' type: 'separator'
}, },
{ {
label: `Quit ${appName}`, role: 'quit'
accelerator: 'Cmd+Q',
click() {
app.quit();
}
} }
] ]
}); });
@ -379,11 +360,7 @@ if (process.platform === 'darwin') {
type: 'separator' type: 'separator'
}, },
{ {
label: `Quit ${appName}`, role: 'quit'
accelerator: 'Cmd+Q',
click() {
app.quit();
}
} }
] ]
}); });

Loading…
Cancel
Save