Merge pull request #200 from aaronraimist/macos-preferences

This commit is contained in:
Michael Telatynski 2021-06-04 09:53:30 +01:00 committed by GitHub
commit 330e230f2c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -17,6 +17,8 @@ limitations under the License.
const { app, shell, Menu } = require('electron');
const { _t } = require('./language-helper');
const isMac = process.platform === 'darwin';
function buildMenuTemplate() {
// Menu template from http://electron.atom.io/docs/api/menu/, edited
const template = [
@ -77,11 +79,11 @@ function buildMenuTemplate() {
label: _t('Zoom Out'),
},
{ type: 'separator' },
{
// in macOS the Preferences menu item goes in the first menu
...(!isMac ? [{
label: _t('Preferences'),
accelerator: 'Command+,', // Mac-only accelerator
click() { global.mainWindow.webContents.send('preferences'); },
},
}] : []),
{
role: 'togglefullscreen',
label: _t('Toggle Full Screen'),
@ -121,7 +123,7 @@ function buildMenuTemplate() {
];
// macOS has specific menu conventions...
if (process.platform === 'darwin') {
if (isMac) {
template.unshift({
// first macOS menu is the name of the app
role: 'appMenu',
@ -129,7 +131,13 @@ function buildMenuTemplate() {
submenu: [
{
role: 'about',
label: _t('About'),
label: _t('About') + ' ' + app.name,
},
{ type: 'separator' },
{
label: _t('Preferences') + '…',
accelerator: 'Command+,', // Mac-only accelerator
click() { global.mainWindow.webContents.send('preferences'); },
},
{ type: 'separator' },
{