lbry-desktop/app/menu/main-menu.js
hackrush 7a0a0c468e Rudimentary implementation of tray minimization(WIP)
Minimize app to tray

@kauffj I was not sure about which icon to use so I used a 96x96 png as
a placeholder. The feature is working well.

Fixes #374

3 small changes

Broken Minimization

Fixed App-minization finally

Bug fix and compatibility check

Added Alt+F4 accelerator to quit the app

Small features and fixes

Homerun: Added Quit to Menu

Fixes and changes
2017-11-08 17:27:17 -05:00

137 lines
2.3 KiB
JavaScript

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',
},
{
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'
},
{
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));
};