refs #1348 Add a menu to hide menu bar

This commit is contained in:
AkiraFukushima 2020-06-07 00:19:41 +09:00
parent 2a974342c2
commit 8c68072686
2 changed files with 21 additions and 0 deletions

View File

@ -29,6 +29,7 @@
"toggle_full_screen": "Toggle Full Screen"
},
"window": {
"always_show_menu_bar": "Always Show Menu Bar",
"name": "Window",
"close": "Close Window",
"open": "Open Window",

View File

@ -1330,6 +1330,17 @@ const ApplicationMenu = (accountsChange: Array<MenuItemConstructorOptions>, i18n
{
label: i18n.t('main_menu.window.name'),
submenu: [
{
label: i18n.t('main_menu.window.always_show_menu_bar'),
type: 'checkbox',
checked: true,
click: item => {
changeMenuAutoHide(!item.checked)
}
},
{
type: 'separator'
},
{
label: i18n.t('main_menu.window.close'),
role: 'close'
@ -1392,6 +1403,15 @@ const TrayMenu = (accountsChange: Array<MenuItemConstructorOptions>, i18n: I18n)
return menu
}
async function changeMenuAutoHide(autoHide: boolean) {
if (mainWindow === null) {
return null
}
mainWindow.autoHideMenuBar = autoHide
mainWindow.setMenuBarVisibility(!autoHide)
return null
}
async function reopenWindow() {
if (mainWindow === null) {
await createWindow()