lbry-desktop/electron/menu/setupBarMenu.js

95 lines
2.2 KiB
JavaScript
Raw Normal View History

2018-01-18 03:13:08 +01:00
import { app, Menu, shell } from 'electron';
export default () => {
const template = [
{
label: 'File',
submenu: [{ role: 'quit', accelerator: 'CmdOrCtrl+Q' }],
},
2018-01-18 03:13:08 +01:00
{
label: 'Edit',
submenu: [
{ role: 'undo' },
{ role: 'redo' },
{ type: 'separator' },
{ role: 'cut' },
{ role: 'copy' },
{ role: 'paste' },
{ role: 'selectAll' },
2018-01-18 03:13:08 +01:00
],
},
{
label: 'View',
submenu: [
{ role: 'reload' },
{
label: 'Developer',
submenu: [{ role: 'forcereload' }, { role: 'toggledevtools' }],
},
{ type: 'separator' },
{ role: 'togglefullscreen' },
],
},
{
role: 'window',
submenu: [{ role: 'minimize' }, { role: 'close' }],
},
{
role: 'help',
submenu: [
{
label: 'Learn More',
click: (menuItem, browserWindow) => {
if (browserWindow) {
browserWindow.webContents.send('open-menu', '/help');
} else {
2019-03-20 22:43:00 +01:00
shell.openExternal('https://lbry.com/faq');
2018-01-18 03:13:08 +01:00
}
},
},
{
label: 'Frequently Asked Questions',
click: () => {
2019-03-20 22:43:00 +01:00
shell.openExternal('https://lbry.com/faq');
2018-01-18 03:13:08 +01:00
},
},
{ type: 'separator' },
{
label: 'Report Issue',
click: () => {
shell.openExternal('https://github.com/lbryio/lbry-desktop/issues/new');
2018-01-18 03:13:08 +01:00
},
},
{ type: 'separator' },
{
label: 'Developer API Guide',
click: () => {
2018-11-15 20:27:19 +01:00
shell.openExternal('https://lbry.tech/playground');
2018-01-18 03:13:08 +01:00
},
},
],
},
];
const darwinTemplateAddition = {
label: app.name,
2018-01-18 03:13:08 +01:00
submenu: [
{ role: 'about' },
{ type: 'separator' },
{ role: 'services', submenu: [] },
{ type: 'separator' },
{ role: 'hide' },
{ role: 'hideothers' },
{ type: 'separator' },
{ role: 'quit' },
],
};
if (process.platform === 'darwin') {
template.unshift(darwinTemplateAddition);
}
const menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);
};