auto hide menubar

update menu

tidy up menu items

fix help label

improve help submenu
This commit is contained in:
Baltazar Gomez 2017-10-18 23:58:19 -06:00 committed by Jeremy Kauffman
parent c8cc05b685
commit 12f7d44c43
2 changed files with 68 additions and 40 deletions

View file

@ -1,6 +1,7 @@
const {app, BrowserWindow, ipcMain} = require('electron'); const {app, BrowserWindow, ipcMain} = require('electron');
const url = require('url'); const url = require('url');
const isDebug = process.env.NODE_ENV === 'development' const isDebug = process.env.NODE_ENV === 'development';
const setMenu = require('./menu/main-menu.js');
if (isDebug) { if (isDebug) {
try try
@ -169,6 +170,12 @@ function createWindow () {
win.on('closed', () => { win.on('closed', () => {
win = null win = null
}) })
// Menu bar
win.setAutoHideMenuBar(true);
win.setMenuBarVisibility(isDebug);
setMenu();
}; };
function handleOpenUriRequested(uri) { function handleOpenUriRequested(uri) {

View file

@ -1,6 +1,4 @@
const {Menu} = require('electron'); const { app, shell, Menu } = require('electron');
const electron = require('electron');
const app = electron.app;
const baseTemplate = [ const baseTemplate = [
{ {
@ -30,16 +28,71 @@ const baseTemplate = [
] ]
}, },
{ {
label: 'Help', label: 'View',
submenu: [ submenu: [
{ {
label: 'Help', role: 'reload'
},
{
label: 'Developer',
submenu: [
{
role: 'forcereload'
},
{
role: 'toggledevtools'
},
]
},
{
type: 'separator'
},
{
role: 'togglefullscreen'
}
]
},
{
role: 'help',
submenu: [
{
label: 'Learn More',
click(item, focusedWindow) { click(item, focusedWindow) {
if (focusedWindow) { if (focusedWindow) {
focusedWindow.webContents.send('open-menu', '/help'); 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');
}
},
{
label: 'Search Issues',
click(item, focusedWindow){
shell.openExternal('https://github.com/lbryio/lbry-app/issues')
}
},
{
type: 'separator'
},
{
label: 'Quickstart Guide',
click(item, focusedWindow){
shell.openExternal('https://lbry.io/quickstart')
}
},
] ]
} }
]; ];
@ -71,40 +124,8 @@ const macOSAppMenuTemplate = {
] ]
}; };
const developerMenuTemplate = { module.exports = () => {
label: 'Developer',
submenu: [
{
label: 'Reload',
accelerator: 'CmdOrCtrl+R',
click(item, focusedWindow) {
if (focusedWindow) {
focusedWindow.reload();
}
}
},
{
label: 'Toggle Developer Tools',
accelerator: process.platform == 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I',
click(item, focusedWindow) {
if (focusedWindow) {
focusedWindow.webContents.toggleDevTools();
}
}
},
]
};
module.exports = {
showMenubar(showDeveloperMenu) {
let template = baseTemplate.slice(); let template = baseTemplate.slice();
if (process.platform === 'darwin') { (process.platform === 'darwin') && template.unshift(macOSAppMenuTemplate);
template.unshift(macOSAppMenuTemplate);
}
if (showDeveloperMenu) {
template.push(developerMenuTemplate);
}
Menu.setApplicationMenu(Menu.buildFromTemplate(template)); Menu.setApplicationMenu(Menu.buildFromTemplate(template));
},
}; };