lbry-desktop/electron/menu/setupBarMenu.js

128 lines
3.2 KiB
JavaScript
Raw Permalink Normal View History

2018-01-18 03:13:08 +01:00
import { app, Menu, shell } from 'electron';
2020-12-01 18:56:59 +01:00
import { ZOOM } from 'util/zoomWindow';
2018-01-18 03:13:08 +01:00
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: 'Zoom',
submenu: [
{
label: 'Zoom In',
accelerator: 'CmdOrCtrl+=',
click: (menuItem, browserWindow) => {
if (browserWindow) {
browserWindow.webContents.send('zoom-window', ZOOM.INCREMENT);
}
},
},
{
label: 'Zoom Out',
accelerator: 'CmdOrCtrl+-',
click: (menuItem, browserWindow) => {
if (browserWindow) {
browserWindow.webContents.send('zoom-window', ZOOM.DECREMENT);
}
},
},
{
label: 'Reset Zoom',
accelerator: 'CmdOrCtrl+0',
click: (menuItem, browserWindow) => {
if (browserWindow) {
browserWindow.webContents.send('zoom-window', ZOOM.RESET);
}
},
},
],
},
2018-01-18 03:13:08 +01:00
{
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);
};