2016-10-30 10:57:12 +00:00
|
|
|
const electron = require('electron'); // eslint-disable-line
|
|
|
|
|
2018-09-30 20:08:36 +00:00
|
|
|
const { Menu } = electron;
|
|
|
|
const { dialog } = electron;
|
2016-10-30 10:57:12 +00:00
|
|
|
|
2020-03-26 11:04:36 +00:00
|
|
|
const { homepage, releasesPage } = require('./constants');
|
2016-10-30 10:57:12 +00:00
|
|
|
|
2018-02-17 14:15:30 +00:00
|
|
|
module.exports = (app, mainWindow, newVersion) => {
|
2020-03-26 11:04:36 +00:00
|
|
|
const menu = [
|
|
|
|
...(process.platform === 'darwin' ? [{ role: 'appMenu' }] : []),
|
2016-10-30 10:57:12 +00:00
|
|
|
|
2020-03-26 11:04:36 +00:00
|
|
|
{
|
|
|
|
label: 'File',
|
|
|
|
submenu: [
|
|
|
|
{
|
|
|
|
label: 'Open',
|
|
|
|
accelerator: 'CmdOrCtrl+O',
|
|
|
|
async click() {
|
|
|
|
const { canceled, filePaths } = await dialog.showOpenDialog({ properties: ['openFile', 'multiSelections'] });
|
|
|
|
if (canceled) return;
|
|
|
|
mainWindow.webContents.send('file-opened', filePaths);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Close',
|
|
|
|
accelerator: 'CmdOrCtrl+W',
|
|
|
|
async click() {
|
|
|
|
mainWindow.webContents.send('close-file');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ type: 'separator' },
|
|
|
|
{
|
|
|
|
label: 'Import CSV cut file',
|
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('importEdlFile');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Export CSV cut file',
|
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('exportEdlFile');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ type: 'separator' },
|
|
|
|
{
|
2020-04-07 14:03:33 +00:00
|
|
|
label: 'Convert to friendly format',
|
2020-03-26 11:04:36 +00:00
|
|
|
click() {
|
2020-04-07 14:03:33 +00:00
|
|
|
mainWindow.webContents.send('html5ify');
|
2020-03-26 11:04:36 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{ type: 'separator' },
|
|
|
|
{
|
|
|
|
label: 'Extract all streams',
|
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('extract-all-streams', false);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ type: 'separator' },
|
|
|
|
{
|
|
|
|
label: 'Settings',
|
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('openSettings');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ type: 'separator' },
|
|
|
|
{
|
|
|
|
label: 'Exit',
|
|
|
|
click() {
|
|
|
|
app.quit();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
2020-02-20 10:41:01 +00:00
|
|
|
},
|
|
|
|
|
2020-03-26 11:04:36 +00:00
|
|
|
{
|
|
|
|
label: 'Edit',
|
|
|
|
submenu: [
|
|
|
|
{
|
|
|
|
label: 'Undo',
|
|
|
|
accelerator: 'CmdOrCtrl+Z',
|
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('undo');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Redo',
|
|
|
|
accelerator: 'Shift+CmdOrCtrl+Z',
|
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('redo');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ type: 'separator' },
|
|
|
|
{ role: 'cut' },
|
|
|
|
{ role: 'copy' },
|
|
|
|
{ role: 'paste' },
|
|
|
|
{ role: 'selectall' },
|
|
|
|
],
|
2020-02-20 10:41:01 +00:00
|
|
|
},
|
|
|
|
|
2020-03-26 11:04:36 +00:00
|
|
|
{
|
|
|
|
label: 'View',
|
|
|
|
submenu: [
|
|
|
|
{ role: 'togglefullscreen' },
|
|
|
|
],
|
|
|
|
},
|
2020-02-20 10:41:01 +00:00
|
|
|
|
2020-03-26 13:31:11 +00:00
|
|
|
// On Windows the windowMenu has a close Ctrl+W which clashes with File->Close shortcut
|
|
|
|
...(process.platform === 'darwin'
|
|
|
|
? [{ role: 'windowMenu' }]
|
|
|
|
: [{
|
|
|
|
label: 'Window',
|
|
|
|
submenu: [{ role: 'minimize' }],
|
|
|
|
}]
|
|
|
|
),
|
2016-10-30 10:57:12 +00:00
|
|
|
|
2020-03-26 11:04:36 +00:00
|
|
|
{
|
2019-01-28 01:25:31 +00:00
|
|
|
label: 'Tools',
|
|
|
|
submenu: [
|
|
|
|
{
|
|
|
|
label: 'Merge files',
|
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('show-merge-dialog', true);
|
|
|
|
},
|
|
|
|
},
|
2020-04-07 14:03:33 +00:00
|
|
|
{
|
|
|
|
label: 'Batch convert to friendly format',
|
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('batchConvertFriendlyFormat');
|
|
|
|
},
|
|
|
|
},
|
2020-02-20 17:57:14 +00:00
|
|
|
{
|
|
|
|
label: 'Set custom start offset/timecode',
|
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('set-start-offset', true);
|
|
|
|
},
|
|
|
|
},
|
2020-03-26 11:04:36 +00:00
|
|
|
{ role: 'toggleDevTools' },
|
2019-01-28 01:25:31 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
2016-11-05 20:22:31 +00:00
|
|
|
role: 'help',
|
|
|
|
submenu: [
|
2020-02-22 15:44:21 +00:00
|
|
|
{
|
2020-03-26 11:04:36 +00:00
|
|
|
label: 'Help and shortcuts',
|
2020-02-22 15:44:21 +00:00
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('openHelp');
|
|
|
|
},
|
|
|
|
},
|
2020-03-26 11:04:36 +00:00
|
|
|
{
|
|
|
|
label: 'About',
|
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('openAbout');
|
|
|
|
},
|
|
|
|
},
|
2016-11-05 20:22:31 +00:00
|
|
|
{
|
|
|
|
label: 'Learn More',
|
|
|
|
click() { electron.shell.openExternal(homepage); },
|
|
|
|
},
|
2020-04-10 10:54:51 +00:00
|
|
|
{
|
|
|
|
label: 'Report an error',
|
|
|
|
click() { mainWindow.webContents.send('openSendReportDialog'); },
|
|
|
|
},
|
2016-11-05 20:22:31 +00:00
|
|
|
],
|
2020-03-26 11:04:36 +00:00
|
|
|
},
|
|
|
|
];
|
2016-10-30 10:57:12 +00:00
|
|
|
|
2018-02-17 14:15:30 +00:00
|
|
|
if (newVersion) {
|
|
|
|
menu.push({
|
|
|
|
label: 'New version!',
|
|
|
|
submenu: [
|
|
|
|
{
|
|
|
|
label: `Download ${newVersion}`,
|
|
|
|
click() { electron.shell.openExternal(releasesPage); },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-10-30 10:57:12 +00:00
|
|
|
Menu.setApplicationMenu(Menu.buildFromTemplate(menu));
|
|
|
|
};
|