mirror of
https://github.com/balena-io/etcher.git
synced 2025-04-20 05:17:18 +00:00

* fix(gui): Re-enable application menu This re-enables the application menu to allow for OS native shortcuts to work again (i.e. hide/minimize window), which also allows us to get rid of the global-shortcuts hack to prevent window reloads. Change-Type: patch Changelog-Entry: Fix disabled native OS window shortcuts * refactor(gui): Update kbd shortcut comment to be less specific
117 lines
2.5 KiB
JavaScript
117 lines
2.5 KiB
JavaScript
/*
|
|
* Copyright 2017 resin.io
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
'use strict'
|
|
|
|
const electron = require('electron')
|
|
|
|
const menuTemplate = [
|
|
{
|
|
role: 'editMenu'
|
|
},
|
|
{
|
|
label: 'View',
|
|
submenu: [
|
|
{
|
|
role: 'toggledevtools',
|
|
click () {
|
|
const window = electron.BrowserWindow.getFocusedWindow()
|
|
if (window) {
|
|
window.webContents.openDevTools({
|
|
mode: 'detach'
|
|
})
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
role: 'windowMenu'
|
|
},
|
|
{
|
|
role: 'help',
|
|
submenu: [
|
|
{
|
|
label: 'Etcher Pro',
|
|
click () {
|
|
electron.shell.openExternal('https://etcher.io/pro')
|
|
}
|
|
},
|
|
{
|
|
label: 'Etcher Website',
|
|
click () {
|
|
electron.shell.openExternal('https://etcher.io')
|
|
}
|
|
},
|
|
{
|
|
label: 'Report an issue',
|
|
click () {
|
|
electron.shell.openExternal('https://github.com/resin-io/etcher/issues')
|
|
}
|
|
}
|
|
]
|
|
}
|
|
]
|
|
|
|
if (process.platform === 'darwin') {
|
|
menuTemplate.unshift({
|
|
label: electron.app.getName(),
|
|
submenu: [ {
|
|
role: 'about'
|
|
}, {
|
|
type: 'separator'
|
|
}, {
|
|
label: 'Preferences',
|
|
accelerator: 'Command+,',
|
|
click () {
|
|
const window = electron.BrowserWindow.getFocusedWindow()
|
|
if (window) {
|
|
window.webContents.send('menu:preferences')
|
|
}
|
|
}
|
|
}, {
|
|
type: 'separator'
|
|
}, {
|
|
role: 'hide'
|
|
}, {
|
|
role: 'hideothers'
|
|
}, {
|
|
role: 'unhide'
|
|
}, {
|
|
type: 'separator'
|
|
}, {
|
|
role: 'quit'
|
|
} ]
|
|
})
|
|
} else {
|
|
menuTemplate.unshift({
|
|
label: electron.app.getName(),
|
|
submenu: [ {
|
|
label: 'Settings',
|
|
click () {
|
|
const window = electron.BrowserWindow.getFocusedWindow()
|
|
if (window) {
|
|
window.webContents.send('menu:preferences')
|
|
}
|
|
}
|
|
}, {
|
|
role: 'quit'
|
|
} ]
|
|
})
|
|
}
|
|
|
|
module.exports = electron.Menu.buildFromTemplate(menuTemplate)
|