2023-07-08 16:47:25 +02:00
|
|
|
const { app, Menu } = require("electron")
|
|
|
|
import { OPEN_SETTINGS_EVENT } from "../constants";
|
|
|
|
import { openAboutWindow } from "./about";
|
2024-01-06 02:51:07 +01:00
|
|
|
import { quit } from "./index"
|
2023-01-15 12:45:06 +01:00
|
|
|
|
2023-07-08 16:47:25 +02:00
|
|
|
const isMac = process.platform === "darwin"
|
2023-01-15 12:45:06 +01:00
|
|
|
|
|
|
|
const template = [
|
|
|
|
// { role: 'appMenu' }
|
|
|
|
...(isMac ? [{
|
|
|
|
label: app.name,
|
|
|
|
submenu: [
|
2023-07-08 16:47:25 +02:00
|
|
|
{
|
|
|
|
label: 'About',
|
2023-07-11 11:24:34 +02:00
|
|
|
click: (menuItem, window, event) => {
|
2023-07-08 16:47:25 +02:00
|
|
|
// open about window
|
|
|
|
openAboutWindow()
|
|
|
|
},
|
|
|
|
},
|
2023-01-15 12:45:06 +01:00
|
|
|
{ type: 'separator' },
|
2023-01-20 15:33:26 +01:00
|
|
|
{
|
2024-01-12 14:29:36 +01:00
|
|
|
label: 'Settings',
|
2023-01-20 15:33:26 +01:00
|
|
|
click: (menuItem, window, event) => {
|
|
|
|
window?.webContents.send(OPEN_SETTINGS_EVENT)
|
|
|
|
},
|
|
|
|
accelerator: isMac ? 'Command+,': null,
|
|
|
|
},
|
|
|
|
{ type: 'separator' },
|
2023-01-15 12:45:06 +01:00
|
|
|
{ role: 'services' },
|
|
|
|
{ type: 'separator' },
|
|
|
|
{ role: 'hide' },
|
|
|
|
{ role: 'hideOthers' },
|
|
|
|
{ role: 'unhide' },
|
|
|
|
{ type: 'separator' },
|
|
|
|
{ role: 'quit' }
|
|
|
|
]
|
2023-01-24 17:08:38 +01:00
|
|
|
}] : [{
|
|
|
|
role: 'fileMenu',
|
|
|
|
submenu: [
|
|
|
|
{
|
2024-01-12 14:29:36 +01:00
|
|
|
label: 'Settings',
|
2023-01-24 17:08:38 +01:00
|
|
|
click: (menuItem, window, event) => {
|
|
|
|
window?.webContents.send(OPEN_SETTINGS_EVENT)
|
|
|
|
},
|
|
|
|
},
|
2023-07-11 11:24:34 +02:00
|
|
|
{
|
|
|
|
label: 'About',
|
|
|
|
click: (menuItem, window, event) => {
|
|
|
|
// open about window
|
|
|
|
openAboutWindow()
|
|
|
|
},
|
|
|
|
},
|
2023-01-24 17:08:38 +01:00
|
|
|
],
|
|
|
|
}]),
|
2023-01-15 12:45:06 +01:00
|
|
|
/*{
|
|
|
|
label: 'File',
|
|
|
|
submenu: [
|
|
|
|
isMac ? { role: 'close' } : { 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' },
|
2023-12-27 14:21:52 +01:00
|
|
|
{
|
|
|
|
accelerator: 'CommandOrControl+=',
|
|
|
|
role: "zoomIn",
|
|
|
|
visible: false
|
|
|
|
},
|
|
|
|
{
|
|
|
|
accelerator: 'CmdOrCtrl+Plus',
|
|
|
|
role: "zoomIn",
|
|
|
|
visible: true
|
|
|
|
},
|
2023-01-15 12:45:06 +01:00
|
|
|
{ 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: [
|
|
|
|
{
|
2024-07-08 14:14:21 +02:00
|
|
|
label: 'Documentation',
|
|
|
|
click: async () => {
|
|
|
|
const { shell } = require('electron')
|
|
|
|
await shell.openExternal('https://heynote.com/docs/')
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Website',
|
2023-01-15 12:45:06 +01:00
|
|
|
click: async () => {
|
|
|
|
const { shell } = require('electron')
|
|
|
|
await shell.openExternal('https://heynote.com')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2024-01-01 20:02:30 +01:00
|
|
|
export const menu = Menu.buildFromTemplate(template)
|
|
|
|
|
|
|
|
|
|
|
|
export function getTrayMenu(win) {
|
|
|
|
return Menu.buildFromTemplate([
|
|
|
|
{
|
|
|
|
label: 'Open Heynote',
|
|
|
|
click: () => {
|
|
|
|
win.show()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ type: 'separator' },
|
|
|
|
...template,
|
|
|
|
{ type: 'separator' },
|
|
|
|
{
|
|
|
|
label: 'Quit',
|
|
|
|
click: () => {
|
2024-01-06 02:51:07 +01:00
|
|
|
quit()
|
2024-01-01 20:02:30 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
])
|
|
|
|
}
|
2023-01-15 12:45:06 +01:00
|
|
|
|