Skip to content

Commit

Permalink
Merge pull request #530 from bradbeam/misc-mac-fixes
Browse files Browse the repository at this point in the history
feat: Add additional menu items
  • Loading branch information
Xzandro authored Oct 28, 2024
2 parents 208d62c + a6f6a43 commit cdb87f3
Showing 1 changed file with 84 additions and 19 deletions.
103 changes: 84 additions & 19 deletions app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,27 +405,92 @@ app.on('ready', async () => {
app.setAppUserModelId(process.execPath);
createWindow();

if (process.platform === 'darwin') {
// Create our menu entries so that we can use MAC shortcuts like copy & paste
Menu.setApplicationMenu(
Menu.buildFromTemplate([
const isMac = process.platform === 'darwin';

const template = [
// { role: 'appMenu' }
...(isMac
? [
{
label: app.name,
submenu: [
{ role: 'about' },
{ type: 'separator' },
{ role: 'services' },
{ type: 'separator' },
{ role: 'hide' },
{ role: 'hideOthers' },
{ role: 'unhide' },
{ type: 'separator' },
{ role: 'quit' },
],
},
]
: []),
// { role: 'editMenu' }
{
label: 'Edit',
submenu: [
{ role: 'undo' },
{ role: 'redo' },
{ type: 'separator' },
{ role: 'cut' },
{ role: 'copy' },
{ role: 'paste' },
...(isMac
? [
{ role: 'pasteAndMatchStyle' },
{ role: 'delete' },
{ role: 'selectAll' },
{ type: 'separator' },
{
label: 'Speech',
submenu: [{ role: 'startSpeaking' }, { role: 'stopSpeaking' }],
},
]
: [{ role: 'delete' }, { type: 'separator' }, { role: 'selectAll' }]),
],
},
// { role: 'viewMenu' }
{
label: 'View',
submenu: [
{ role: 'reload' },
{ role: 'forceReload' },
{ role: 'toggleDevTools' },
{ type: 'separator' },
{ role: 'resetZoom' },
{ role: 'zoomIn' },
{ role: 'zoomOut' },
{ type: 'separator' },
{ role: 'togglefullscreen' },
],
},
// { role: 'windowMenu' }
{
label: 'Window',
submenu: [
{ role: 'minimize' },
{ role: 'zoom' },
...(isMac ? [{ type: 'separator' }, { role: 'front' }, { type: 'separator' }, { role: 'window' }] : [{ role: 'close' }]),
],
},
{
role: 'help',
submenu: [
{
label: 'Edit',
submenu: [
{ role: 'undo' },
{ role: 'redo' },
{ type: 'separator' },
{ role: 'cut' },
{ role: 'copy' },
{ role: 'paste' },
{ role: 'pasteandmatchstyle' },
{ role: 'delete' },
{ role: 'selectall' },
],
label: 'Learn More',
click: async () => {
const { shell } = require('electron');
await shell.openExternal('https://github.com/Xzandro/sw-exporter');
},
},
])
);
}
],
},
];

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

storage.getAll(async (error, data) => {
if (error) throw error;
Expand Down

0 comments on commit cdb87f3

Please sign in to comment.