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-12-11 16:15:35 +01:00
|
|
|
{
|
|
|
|
label: 'Save project (CSV)',
|
|
|
|
click() {
|
2020-12-14 17:29:07 +01:00
|
|
|
mainWindow.webContents.send('exportEdlFile', 'csv');
|
2020-12-11 16:15:35 +01:00
|
|
|
},
|
|
|
|
},
|
2020-11-18 21:24:20 +01:00
|
|
|
{
|
|
|
|
label: 'Import project',
|
|
|
|
submenu: [
|
2020-11-19 22:51:17 +01:00
|
|
|
{
|
|
|
|
label: 'Text chapters / YouTube',
|
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('importEdlFile', 'youtube');
|
|
|
|
},
|
|
|
|
},
|
2020-11-18 21:24:20 +01:00
|
|
|
{
|
|
|
|
label: 'DaVinci Resolve / Final Cut Pro XML',
|
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('importEdlFile', 'xmeml');
|
|
|
|
},
|
|
|
|
},
|
2020-11-19 22:51:17 +01:00
|
|
|
{
|
|
|
|
label: 'CUE sheet file',
|
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('importEdlFile', 'cue');
|
|
|
|
},
|
|
|
|
},
|
2020-12-08 17:10:31 +01:00
|
|
|
{
|
|
|
|
label: 'PotPlayer Bookmarks (.pbf)',
|
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('importEdlFile', 'pbf');
|
|
|
|
},
|
|
|
|
},
|
2020-11-18 21:24:20 +01:00
|
|
|
],
|
|
|
|
},
|
2020-12-14 17:29:07 +01:00
|
|
|
{
|
|
|
|
label: 'Export project',
|
|
|
|
submenu: [
|
|
|
|
{
|
|
|
|
label: 'Human readable (TSV)',
|
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('exportEdlFile', 'tsv');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2020-03-26 12:04:36 +01:00
|
|
|
{ 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
|
|
|
},
|
|
|
|
},
|
2020-11-22 23:53:04 +01:00
|
|
|
{
|
|
|
|
label: 'Fix incorrect duration',
|
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('fixInvalidDuration');
|
|
|
|
},
|
|
|
|
},
|
2020-03-26 12:04:36 +01:00
|
|
|
{ type: 'separator' },
|
2020-12-11 16:15:35 +01:00
|
|
|
|
2020-03-26 12:04:36 +01:00
|
|
|
{ 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-11-21 00:04:08 +01:00
|
|
|
{ type: 'separator' },
|
|
|
|
{
|
|
|
|
label: 'Segments',
|
|
|
|
submenu: [
|
2020-12-14 12:29:17 +01:00
|
|
|
{
|
|
|
|
label: 'Clear all segments',
|
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('clearSegments');
|
|
|
|
},
|
|
|
|
},
|
2020-11-25 22:42:10 +01:00
|
|
|
{
|
|
|
|
label: 'Reorder segments by start time',
|
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('reorderSegsByStartTime');
|
|
|
|
},
|
|
|
|
},
|
2020-11-21 00:04:08 +01:00
|
|
|
{
|
|
|
|
label: 'Create num segments',
|
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('createNumSegments');
|
|
|
|
},
|
|
|
|
},
|
2020-11-21 00:30:53 +01:00
|
|
|
{
|
|
|
|
label: 'Create fixed duration segments',
|
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('createFixedDurationSegments');
|
|
|
|
},
|
|
|
|
},
|
2020-11-21 00:04:08 +01:00
|
|
|
],
|
|
|
|
},
|
2020-12-11 16:15:35 +01:00
|
|
|
{
|
|
|
|
label: 'Tracks',
|
|
|
|
submenu: [
|
|
|
|
{
|
|
|
|
label: 'Extract all tracks',
|
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('extract-all-streams');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Edit tracks / metadata tags',
|
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('showStreamsSelector');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2020-03-26 12:04:36 +01:00
|
|
|
],
|
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));
|
|
|
|
};
|