2016-10-30 11:57:12 +01:00
|
|
|
const electron = require('electron'); // eslint-disable-line
|
2021-03-28 19:12:58 +02:00
|
|
|
const i18n = require('i18next');
|
2016-10-30 11:57:12 +01:00
|
|
|
|
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
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('File'),
|
2020-03-26 12:04:36 +01:00
|
|
|
submenu: [
|
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('Open'),
|
2020-03-26 12:04:36 +01:00
|
|
|
accelerator: 'CmdOrCtrl+O',
|
|
|
|
async click() {
|
|
|
|
const { canceled, filePaths } = await dialog.showOpenDialog({ properties: ['openFile', 'multiSelections'] });
|
|
|
|
if (canceled) return;
|
|
|
|
mainWindow.webContents.send('file-opened', filePaths);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('Close'),
|
2020-03-26 12:04:36 +01:00
|
|
|
accelerator: 'CmdOrCtrl+W',
|
|
|
|
async click() {
|
|
|
|
mainWindow.webContents.send('close-file');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ type: 'separator' },
|
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('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
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('Save project (CSV)'),
|
2020-12-11 16:15:35 +01:00
|
|
|
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
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('Import project'),
|
2020-11-18 21:24:20 +01:00
|
|
|
submenu: [
|
2021-02-21 19:12:25 +01:00
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('EDL (MPlayer)'),
|
2021-02-21 19:12:25 +01:00
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('importEdlFile', 'mplayer');
|
|
|
|
},
|
|
|
|
},
|
2020-11-19 22:51:17 +01:00
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('Text chapters / YouTube'),
|
2020-11-19 22:51:17 +01:00
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('importEdlFile', 'youtube');
|
|
|
|
},
|
|
|
|
},
|
2020-11-18 21:24:20 +01:00
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('DaVinci Resolve / Final Cut Pro XML'),
|
2020-11-18 21:24:20 +01:00
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('importEdlFile', 'xmeml');
|
|
|
|
},
|
|
|
|
},
|
2020-11-19 22:51:17 +01:00
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('CUE sheet file'),
|
2020-11-19 22:51:17 +01:00
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('importEdlFile', 'cue');
|
|
|
|
},
|
|
|
|
},
|
2020-12-08 17:10:31 +01:00
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('PotPlayer Bookmarks (.pbf)'),
|
2020-12-08 17:10:31 +01:00
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('importEdlFile', 'pbf');
|
|
|
|
},
|
|
|
|
},
|
2020-11-18 21:24:20 +01:00
|
|
|
],
|
|
|
|
},
|
2020-12-14 17:29:07 +01:00
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('Export project'),
|
2020-12-14 17:29:07 +01:00
|
|
|
submenu: [
|
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('Timestamps (CSV)'),
|
2020-12-14 17:29:07 +01:00
|
|
|
click() {
|
2020-12-15 00:49:08 +01:00
|
|
|
mainWindow.webContents.send('exportEdlFile', 'csv-human');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('Timestamps (TSV/TXT)'),
|
2020-12-15 00:49:08 +01:00
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('exportEdlFile', 'tsv-human');
|
2020-12-14 17:29:07 +01:00
|
|
|
},
|
|
|
|
},
|
2021-02-19 13:46:08 +01:00
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('Start times as YouTube Chapters'),
|
2021-02-19 13:46:08 +01:00
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('exportEdlYouTube');
|
|
|
|
},
|
|
|
|
},
|
2020-12-14 17:29:07 +01:00
|
|
|
],
|
|
|
|
},
|
2020-03-26 12:04:36 +01:00
|
|
|
{ type: 'separator' },
|
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('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
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('Fix incorrect duration'),
|
2020-11-22 23:53:04 +01:00
|
|
|
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' },
|
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('Settings'),
|
2021-04-18 13:04:53 +02:00
|
|
|
accelerator: 'CmdOrCtrl+,',
|
2020-03-26 12:04:36 +01:00
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('openSettings');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ type: 'separator' },
|
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('Exit'),
|
2020-03-26 12:04:36 +01:00
|
|
|
click() {
|
|
|
|
app.quit();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
2020-02-20 11:41:01 +01:00
|
|
|
},
|
|
|
|
|
2020-03-26 12:04:36 +01:00
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('Edit'),
|
2020-03-26 12:04:36 +01:00
|
|
|
submenu: [
|
2021-01-23 21:37:06 +01:00
|
|
|
{ role: 'undo' },
|
|
|
|
{ role: 'redo' },
|
2020-03-26 12:04:36 +01:00
|
|
|
{ type: 'separator' },
|
|
|
|
{ role: 'cut' },
|
|
|
|
{ role: 'copy' },
|
|
|
|
{ role: 'paste' },
|
|
|
|
{ role: 'selectall' },
|
2020-11-21 00:04:08 +01:00
|
|
|
{ type: 'separator' },
|
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('Segments'),
|
2020-11-21 00:04:08 +01:00
|
|
|
submenu: [
|
2020-12-14 12:29:17 +01:00
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('Clear all segments'),
|
2020-12-14 12:29:17 +01:00
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('clearSegments');
|
|
|
|
},
|
|
|
|
},
|
2020-11-25 22:42:10 +01:00
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('Reorder segments by start time'),
|
2020-11-25 22:42:10 +01:00
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('reorderSegsByStartTime');
|
|
|
|
},
|
|
|
|
},
|
2020-11-21 00:04:08 +01:00
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('Create num segments'),
|
2020-11-21 00:04:08 +01:00
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('createNumSegments');
|
|
|
|
},
|
|
|
|
},
|
2020-11-21 00:30:53 +01:00
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('Create fixed duration segments'),
|
2020-11-21 00:30:53 +01:00
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('createFixedDurationSegments');
|
|
|
|
},
|
|
|
|
},
|
2020-11-21 00:04:08 +01:00
|
|
|
],
|
|
|
|
},
|
2020-12-11 16:15:35 +01:00
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('Tracks'),
|
2020-12-11 16:15:35 +01:00
|
|
|
submenu: [
|
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('Extract all tracks'),
|
2020-12-11 16:15:35 +01:00
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('extract-all-streams');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('Edit tracks / metadata tags'),
|
2020-12-11 16:15:35 +01:00
|
|
|
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
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('View'),
|
2020-03-26 12:04:36 +01:00
|
|
|
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' }]
|
|
|
|
: [{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('Window'),
|
2020-03-26 14:31:11 +01:00
|
|
|
submenu: [{ role: 'minimize' }],
|
|
|
|
}]
|
|
|
|
),
|
2016-10-30 11:57:12 +01:00
|
|
|
|
2020-03-26 12:04:36 +01:00
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('Tools'),
|
2019-01-28 02:25:31 +01:00
|
|
|
submenu: [
|
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('Merge files'),
|
2019-01-28 02:25:31 +01:00
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('show-merge-dialog', true);
|
|
|
|
},
|
|
|
|
},
|
2020-04-07 16:03:33 +02:00
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('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
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('Set custom start offset/timecode'),
|
2020-02-20 18:57:14 +01:00
|
|
|
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
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('Help and shortcuts'),
|
2020-02-22 16:44:21 +01:00
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('openHelp');
|
|
|
|
},
|
|
|
|
},
|
2020-03-26 12:04:36 +01:00
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('About'),
|
2020-03-26 12:04:36 +01:00
|
|
|
click() {
|
|
|
|
mainWindow.webContents.send('openAbout');
|
|
|
|
},
|
|
|
|
},
|
2016-11-05 21:22:31 +01:00
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('Learn More'),
|
2016-11-05 21:22:31 +01:00
|
|
|
click() { electron.shell.openExternal(homepage); },
|
|
|
|
},
|
2020-04-10 12:54:51 +02:00
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('Report an error'),
|
2020-04-10 12:54:51 +02:00
|
|
|
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({
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('New version!'),
|
2018-02-17 15:15:30 +01:00
|
|
|
submenu: [
|
|
|
|
{
|
2021-03-28 19:12:58 +02:00
|
|
|
label: i18n.t('Download {{version}}', { version: newVersion }),
|
2018-02-17 15:15:30 +01:00
|
|
|
click() { electron.shell.openExternal(releasesPage); },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-10-30 11:57:12 +01:00
|
|
|
Menu.setApplicationMenu(Menu.buildFromTemplate(menu));
|
|
|
|
};
|