Skip to content

Commit

Permalink
Added About menu for non-mac devices.
Browse files Browse the repository at this point in the history
Closes #1262
  • Loading branch information
imolorhe committed Jun 13, 2020
1 parent 522b27d commit 0c8c153
Showing 1 changed file with 48 additions and 39 deletions.
87 changes: 48 additions & 39 deletions packages/altair-electron/src/menu.js
@@ -1,7 +1,29 @@
const { app, Menu } = require('electron');

const createMenu = (actions) => {
const isMac = process.platform === 'darwin';

const template = [
...( isMac ? [{
label: app.getName(),
submenu: [
{ role: "about" },
{ label: 'Check for Updates...', click: actions.checkForUpdates },
{
label: 'Preferences',
accelerator: 'Cmd+,',
click: actions.showSettings
},
{ type: "separator" },
{ role: "services", submenu: [] },
{ type: "separator" },
{ role: "hide" },
{ role: "hideothers" },
{ role: "unhide" },
{ type: "separator" },
{ role: "quit" }
]
}] : []),
{
label: "Edit",
submenu: [
Expand All @@ -28,7 +50,14 @@ const createMenu = (actions) => {
{ role: "paste" },
{ role: "pasteandmatchstyle" },
{ role: "delete" },
{ role: "selectall" }
{ role: "selectall" },
...(isMac ? [
{ type: "separator" },
{
label: "Speech",
submenu: [{ role: "startspeaking" }, { role: "stopspeaking" }]
}
] : [])
]
},
{
Expand All @@ -55,7 +84,14 @@ const createMenu = (actions) => {
role: "window",
submenu: [
{ role: "minimize" },
{ role: "close" }
{ role: "close" },
...(isMac ? [
{ role: "minimize" },
{ type: "separator" },
{ role: "front" }
] : [
{ role: 'about' },
]),
]
},
{
Expand All @@ -71,46 +107,19 @@ const createMenu = (actions) => {
},
]
},
];

if (process.platform === "darwin") {
template.unshift({
label: app.getName(),
{
label: 'Help',
submenu: [
{ role: "about" },
{ label: 'Check for Updates...', click: actions.checkForUpdates },
{
label: 'Preferences',
accelerator: 'Cmd+,',
click: actions.showSettings
},
{ type: "separator" },
{ role: "services", submenu: [] },
{ type: "separator" },
{ role: "hide" },
{ role: "hideothers" },
{ role: "unhide" },
{ type: "separator" },
{ role: "quit" }
label: 'Open documentation',
click: async () => {
const { shell } = require('electron');
await shell.openExternal('https://altair.sirmuel.design/docs/');
}
}
]
});

// Edit menu
template[1].submenu.push(
{ type: "separator" },
{
label: "Speech",
submenu: [{ role: "startspeaking" }, { role: "stopspeaking" }]
}
);

// Window menu
template[3].submenu = [
{ role: "minimize" },
{ type: "separator" },
{ role: "front" }
];
}
},
];

const menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);
Expand Down

0 comments on commit 0c8c153

Please sign in to comment.