2016-10-30 11:57:12 +01:00
|
|
|
const electron = require('electron'); // eslint-disable-line
|
|
|
|
|
2018-09-30 22:08:36 +02:00
|
|
|
const { Menu } = electron;
|
|
|
|
const { dialog } = electron;
|
2016-10-30 11:57:12 +01:00
|
|
|
|
2020-03-26 12:04:36 +01:00
|
|
|
const { homepage, releasesPage } = require('./constants');
|
2016-10-30 11:57:12 +01:00
|
|
|
|
2018-02-17 15:15:30 +01:00
|
|
|
module.exports = (app, mainWindow, newVersion) => {
|
2020-03-26 12:04:36 +01:00
|
|
|
const menu = [
|
|
|
|
...(process.platform === 'darwin' ? [{ role: 'appMenu' }] : []),
|
2016-10-30 11:57:12 +01:00
|
|
|
|
2020-03-26 12:04:36 +01: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' },
|
|
|
|
{
|
2020-05-17 07:44:19 +02:00
|
|
|
label: 'Load project (CSV)',
|
2020-03-26 12:04:36 +01:00
|
|
|
click() {
|
2020-11-18 21:24:20 +01:00
|
|
|
mainWindow.webContents.send('importEdlFile', 'csv');
|
2020-03-26 12:04:36 +01:00
|
|
|
},
|
|
|
|
},
|
2020-11-18 21:24:20 +01:00
|
|
|
{
|
|
|
|
label: 'Import project',
|
|
|
|
submenu: [
|
|
|
|
{
|
|
|
|
label: 'DaVinci Resolve / Final Cut Pro XML',
|
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('importEdlFile', 'xmeml');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2020-03-26 12:04:36 +01:00
|
|
|
{
|
2020-05-17 07:44:19 +02:00
|
|
|
label: 'Save project (CSV)',
|
2020-03-26 12:04:36 +01:00
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('exportEdlFile');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ type: 'separator' },
|
|
|
|
{
|
2020-04-27 09:56:42 +02:00
|
|
|
label: 'Convert to supported format',
|
2020-03-26 12:04:36 +01:00
|
|
|
click() {
|
2020-04-07 16:03:33 +02:00
|
|
|
mainWindow.webContents.send('html5ify');
|
2020-03-26 12:04:36 +01: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 11:41:01 +01:00
|
|
|
},
|
|
|
|
|
2020-03-26 12:04:36 +01: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 11:41:01 +01:00
|
|
|
},
|
|
|
|
|
2020-03-26 12:04:36 +01:00
|
|
|
{
|
|
|
|
label: 'View',
|
|
|
|
submenu: [
|
|
|
|
{ role: 'togglefullscreen' },
|
|
|
|
],
|
|
|
|
},
|
2020-02-20 11:41:01 +01:00
|
|
|
|
2020-03-26 14:31:11 +01: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 11:57:12 +01:00
|
|
|
|
2020-03-26 12:04:36 +01:00
|
|
|
{
|
2019-01-28 02:25:31 +01:00
|
|
|
label: 'Tools',
|
|
|
|
submenu: [
|
|
|
|
{
|
|
|
|
label: 'Merge files',
|
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('show-merge-dialog', true);
|
|
|
|
},
|
|
|
|
},
|
2020-04-07 16:03:33 +02:00
|
|
|
{
|
2020-04-27 09:56:42 +02:00
|
|
|
label: 'Batch convert to supported format',
|
2020-04-07 16:03:33 +02:00
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('batchConvertFriendlyFormat');
|
|
|
|
},
|
|
|
|
},
|
2020-02-20 18:57:14 +01:00
|
|
|
{
|
|
|
|
label: 'Set custom start offset/timecode',
|
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('set-start-offset', true);
|
|
|
|
},
|
|
|
|
},
|
2020-03-26 12:04:36 +01:00
|
|
|
{ role: 'toggleDevTools' },
|
2019-01-28 02:25:31 +01:00
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
2016-11-05 21:22:31 +01:00
|
|
|
role: 'help',
|
|
|
|
submenu: [
|
2020-02-22 16:44:21 +01:00
|
|
|
{
|
2020-03-26 12:04:36 +01:00
|
|
|
label: 'Help and shortcuts',
|
2020-02-22 16:44:21 +01:00
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('openHelp');
|
|
|
|
},
|
|
|
|
},
|
2020-03-26 12:04:36 +01:00
|
|
|
{
|
|
|
|
label: 'About',
|
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('openAbout');
|
|
|
|
},
|
|
|
|
},
|
2016-11-05 21:22:31 +01:00
|
|
|
{
|
|
|
|
label: 'Learn More',
|
|
|
|
click() { electron.shell.openExternal(homepage); },
|
|
|
|
},
|
2020-04-10 12:54:51 +02:00
|
|
|
{
|
|
|
|
label: 'Report an error',
|
|
|
|
click() { mainWindow.webContents.send('openSendReportDialog'); },
|
|
|
|
},
|
2016-11-05 21:22:31 +01:00
|
|
|
],
|
2020-03-26 12:04:36 +01:00
|
|
|
},
|
|
|
|
];
|
2016-10-30 11:57:12 +01:00
|
|
|
|
2018-02-17 15:15:30 +01:00
|
|
|
if (newVersion) {
|
|
|
|
menu.push({
|
|
|
|
label: 'New version!',
|
|
|
|
submenu: [
|
|
|
|
{
|
|
|
|
label: `Download ${newVersion}`,
|
|
|
|
click() { electron.shell.openExternal(releasesPage); },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-10-30 11:57:12 +01:00
|
|
|
Menu.setApplicationMenu(Menu.buildFromTemplate(menu));
|
|
|
|
};
|