lbry-desktop/app/menu/main-menu.js

137 lines
2.3 KiB
JavaScript
Raw Normal View History

const { app, shell, Menu } = require('electron');
const { safeQuit } = require('../main.js');
const baseTemplate = [
{
label: 'File',
submenu: [
{
label: 'Quit',
accelerator: "CommandOrControl+Q",
click: () => safeQuit(),
},
]
},
{
label: 'Edit',
submenu: [
{
role: 'undo',
},
{
role: 'redo',
},
{
type: 'separator',
},
{
role: 'cut',
},
{
role: 'copy',
},
{
role: 'paste',
},
2017-05-02 09:47:41 +02:00
{
role: 'selectall',
},
]
},
{
label: 'View',
submenu: [
{
role: 'reload'
},
{
label: 'Developer',
submenu: [
{
role: 'forcereload'
},
{
role: 'toggledevtools'
},
]
},
{
type: 'separator'
},
{
role: 'togglefullscreen'
}
]
},
{
role: 'help',
submenu: [
{
label: 'Learn More',
click(item, focusedWindow) {
if (focusedWindow) {
focusedWindow.webContents.send('open-menu', '/help');
}
}
},
{
label: 'Frequently Asked Questions',
click(item, focusedWindow){
shell.openExternal('https://lbry.io/faq')
}
},
{
type: 'separator'
},
{
label: 'Report Issue',
click(item, focusedWindow){
shell.openExternal('https://lbry.io/faq/contributing#report-a-bug');
}
},
{
type: 'separator'
},
{
2017-10-27 21:11:03 +02:00
label: 'Developer API Guide',
click(item, focusedWindow){
shell.openExternal('https://lbry.io/quickstart')
}
},
]
}
];
const macOSAppMenuTemplate = {
label: app.getName(),
submenu: [
{
role: 'about',
},
{
type: 'separator',
},
{
role: 'hide',
},
{
role: 'hideothers',
},
{
role: 'unhide',
},
{
type: 'separator',
},
{
role: 'quit',
},
]
};
module.exports = () => {
let template = baseTemplate.slice();
(process.platform === 'darwin') && template.unshift(macOSAppMenuTemplate);
Menu.setApplicationMenu(Menu.buildFromTemplate(template));
};