Put Preferences menu item in correct location on macOS

Signed-off-by: Aaron Raimist <aaron@raim.ist>
This commit is contained in:
Aaron Raimist 2021-06-03 22:56:02 -05:00
parent 767445e6f6
commit 5055ad0aec
No known key found for this signature in database
GPG key ID: 37419210002890EF

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 = [
@ -78,11 +80,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'),
@ -122,7 +124,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',
@ -133,6 +135,12 @@ function buildMenuTemplate() {
label: _t('About'),
},
{ type: 'separator' },
{
label: _t('Preferences'),
accelerator: 'Command+,', // Mac-only accelerator
click() { global.mainWindow.webContents.send('preferences'); },
},
{ type: 'separator' },
{
role: 'services',
label: _t('Services'),