You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
session-desktop/app/menu.js

215 lines
3.7 KiB
JavaScript

function createTemplate(options, messages) {
const showDebugLog = options.showDebugLog;
const showAbout = options.showAbout;
const openReleaseNotes = options.openReleaseNotes;
const openNewBugForm = options.openNewBugForm;
const openSupportPage = options.openSupportPage;
const openForums = options.openForums;
let template = [{
label: messages.mainMenuFile.message,
submenu: [
{
role: 'quit',
},
]
},
{
label: messages.mainMenuEdit.message,
submenu: [
{
role: 'undo',
},
{
role: 'redo',
},
{
type: 'separator',
},
{
role: 'cut',
},
{
role: 'copy',
},
{
role: 'paste',
},
{
role: 'pasteandmatchstyle',
},
{
role: 'delete',
},
{
role: 'selectall',
}
]
},
{
label: messages.mainMenuView.message,
submenu: [
{
role: 'resetzoom',
},
{
role: 'zoomin',
},
{
role: 'zoomout',
},
{
type: 'separator',
},
{
role: 'togglefullscreen',
},
{
type: 'separator',
},
{
label: messages.debugLog.message,
click: showDebugLog,
},
{
type: 'separator',
},
{
role: 'toggledevtools',
},
]
},
{
label: messages.mainMenuWindow.message,
role: 'window',
submenu: [
{
role: 'minimize',
},
]
},
{
label: messages.mainMenuHelp.message,
role: 'help',
submenu: [
{
label: messages.goToReleaseNotes.message,
click: openReleaseNotes,
},
{
type: 'separator',
},
{
label: messages.goToForums.message,
click: openForums,
},
{
label: messages.goToSupportPage.message,
click: openSupportPage,
},
{
label: messages.fileABug.message,
click: openNewBugForm,
},
{
type: 'separator',
},
{
label: messages.aboutSignalDesktop.message,
click: showAbout,
},
]
}];
if (process.platform === 'darwin') {
return updateForMac(template, messages, options);
}
return template;
}
function updateForMac(template, messages, options) {
const showWindow = options.showWindow;
const showAbout = options.showAbout;
// Remove About item and separator from Help menu, since it's on the first menu
template[4].submenu.pop();
template[4].submenu.pop();
// Replace File menu
template.shift();
template.unshift({
submenu: [
{
label: messages.aboutSignalDesktop.message,
click: showAbout,
},
{
type: 'separator',
},
{
role: 'hide',
},
{
role: 'hideothers',
},
{
role: 'unhide',
},
{
type: 'separator',
},
{
role: 'quit',
},
]
});
// Add to Edit menu
template[1].submenu.push(
{
type: 'separator'
},
{
label: messages.speech.message,
submenu: [
{
role: 'startspeaking',
},
{
role: 'stopspeaking',
},
]
}
);
// Add to Window menu
template[3].submenu = [
{
accelerator: 'CmdOrCtrl+W',
role: 'close',
},
{
accelerator: 'CmdOrCtrl+M',
role: 'minimize',
},
{
role: 'zoom',
},
{
label: messages.show.message,
click: showWindow,
},
{
type: 'separator',
},
{
role: 'front',
},
];
return template;
}
module.exports = createTemplate;