1
0
mirror of https://github.com/mifi/lossless-cut.git synced 2024-11-22 10:22:31 +01:00
lossless-cut/public/menu.js

318 lines
8.9 KiB
JavaScript
Raw Normal View History

2016-10-30 11:57:12 +01:00
const electron = require('electron'); // eslint-disable-line
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
const { homepage, getReleaseUrl, licensesPage } = require('./constants');
2016-10-30 11:57:12 +01:00
2018-02-17 15:15:30 +01:00
module.exports = (app, mainWindow, newVersion) => {
const menu = [
...(process.platform === 'darwin' ? [{ role: 'appMenu' }] : []),
2016-10-30 11:57:12 +01:00
{
label: i18n.t('File'),
submenu: [
{
label: i18n.t('Open'),
accelerator: 'CmdOrCtrl+O',
async click() {
const { canceled, filePaths } = await dialog.showOpenDialog({ properties: ['openFile', 'multiSelections'] });
if (canceled) return;
2022-02-23 12:43:19 +01:00
mainWindow.webContents.send('openFiles', filePaths);
},
},
{
label: i18n.t('Close'),
accelerator: 'CmdOrCtrl+W',
async click() {
2022-02-23 12:43:19 +01:00
mainWindow.webContents.send('closeCurrentFile');
},
},
2021-08-28 16:47:43 +02:00
{
label: i18n.t('Close batch'),
async click() {
2022-02-23 12:43:19 +01:00
mainWindow.webContents.send('closeBatchFiles');
2021-08-28 16:47:43 +02:00
},
},
{ type: 'separator' },
{
label: i18n.t('Import project (LLC)...'),
click() {
mainWindow.webContents.send('importEdlFile', 'llc');
},
},
2020-12-11 16:15:35 +01:00
{
label: i18n.t('Export project (LLC)...'),
2020-12-11 16:15:35 +01:00
click() {
mainWindow.webContents.send('exportEdlFile', 'llc');
2020-12-11 16:15:35 +01:00
},
},
2020-11-18 21:24:20 +01:00
{
label: i18n.t('Import project'),
2020-11-18 21:24:20 +01:00
submenu: [
{
label: i18n.t('Times in seconds (CSV)'),
click() {
mainWindow.webContents.send('importEdlFile', 'csv');
},
},
{
label: i18n.t('Frame numbers (CSV)'),
click() {
mainWindow.webContents.send('importEdlFile', 'csv-frames');
},
},
{
label: i18n.t('EDL (MPlayer)'),
click() {
mainWindow.webContents.send('importEdlFile', 'mplayer');
},
},
{
label: i18n.t('Text chapters / YouTube'),
click() {
mainWindow.webContents.send('importEdlFile', 'youtube');
},
},
2020-11-18 21:24:20 +01:00
{
label: i18n.t('DaVinci Resolve / Final Cut Pro XML'),
2020-11-18 21:24:20 +01:00
click() {
mainWindow.webContents.send('importEdlFile', 'xmeml');
},
},
{
label: i18n.t('CUE sheet file'),
click() {
mainWindow.webContents.send('importEdlFile', 'cue');
},
},
{
label: i18n.t('PotPlayer Bookmarks (.pbf)'),
click() {
mainWindow.webContents.send('importEdlFile', 'pbf');
},
},
2020-11-18 21:24:20 +01:00
],
},
{
label: i18n.t('Export project'),
submenu: [
{
label: i18n.t('Times in seconds (CSV)'),
click() {
mainWindow.webContents.send('exportEdlFile', 'csv');
},
},
{
label: i18n.t('Timestamps (CSV)'),
click() {
2020-12-15 00:49:08 +01:00
mainWindow.webContents.send('exportEdlFile', 'csv-human');
},
},
{
label: i18n.t('Frame numbers (CSV)'),
click() {
mainWindow.webContents.send('exportEdlFile', 'csv-frames');
},
},
2020-12-15 00:49:08 +01:00
{
label: i18n.t('Timestamps (TSV/TXT)'),
2020-12-15 00:49:08 +01:00
click() {
mainWindow.webContents.send('exportEdlFile', 'tsv-human');
},
},
{
label: i18n.t('Start times as YouTube Chapters'),
click() {
mainWindow.webContents.send('exportEdlYouTube');
},
},
],
},
{ type: 'separator' },
{
label: i18n.t('Convert to supported format'),
click() {
mainWindow.webContents.send('html5ify');
},
},
2020-11-22 23:53:04 +01:00
{
label: i18n.t('Fix incorrect duration'),
2020-11-22 23:53:04 +01:00
click() {
mainWindow.webContents.send('fixInvalidDuration');
},
},
{ type: 'separator' },
2020-12-11 16:15:35 +01:00
{ type: 'separator' },
{
label: i18n.t('Settings'),
accelerator: 'CmdOrCtrl+,',
click() {
2022-02-23 12:43:19 +01:00
mainWindow.webContents.send('toggleSettings');
},
},
{ type: 'separator' },
{
label: i18n.t('Exit'),
click() {
app.quit();
},
},
],
2020-02-20 11:41:01 +01:00
},
{
label: i18n.t('Edit'),
submenu: [
2021-08-13 18:20:29 +02:00
{ role: 'undo', label: i18n.t('Undo') },
{ role: 'redo', label: i18n.t('Redo') },
{ type: 'separator' },
2021-08-13 18:20:29 +02:00
{ role: 'cut', label: i18n.t('Cut') },
{ role: 'copy', label: i18n.t('Copy') },
{ role: 'paste', label: i18n.t('Paste') },
{ role: 'selectall', label: i18n.t('Select All') },
{ type: 'separator' },
{
label: i18n.t('Segments'),
submenu: [
2020-12-14 12:29:17 +01:00
{
label: i18n.t('Clear all segments'),
2020-12-14 12:29:17 +01:00
click() {
mainWindow.webContents.send('clearSegments');
},
},
{
label: i18n.t('Reorder segments by start time'),
click() {
mainWindow.webContents.send('reorderSegsByStartTime');
},
},
{
label: i18n.t('Create num segments'),
click() {
mainWindow.webContents.send('createNumSegments');
},
},
{
label: i18n.t('Create fixed duration segments'),
click() {
mainWindow.webContents.send('createFixedDurationSegments');
},
},
{
label: i18n.t('Invert all segments on timeline'),
click() {
mainWindow.webContents.send('invertAllCutSegments');
},
},
2022-02-18 07:34:20 +01:00
{
label: i18n.t('Shuffle segments order'),
click() {
mainWindow.webContents.send('shuffleSegments');
},
},
],
},
2020-12-11 16:15:35 +01:00
{
label: i18n.t('Tracks'),
2020-12-11 16:15:35 +01:00
submenu: [
{
label: i18n.t('Extract all tracks'),
2020-12-11 16:15:35 +01:00
click() {
2022-02-23 12:43:19 +01:00
mainWindow.webContents.send('extractAllStreams');
2020-12-11 16:15:35 +01:00
},
},
{
label: i18n.t('Edit tracks / metadata tags'),
2020-12-11 16:15:35 +01:00
click() {
mainWindow.webContents.send('showStreamsSelector');
},
},
],
},
],
2020-02-20 11:41:01 +01:00
},
{
label: i18n.t('View'),
submenu: [
2021-08-13 18:20:29 +02:00
{ role: 'togglefullscreen', label: i18n.t('Toggle Full Screen') },
],
},
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'
2021-08-13 18:20:29 +02:00
? [{ role: 'windowMenu', label: i18n.t('Window') }]
2020-03-26 14:31:11 +01:00
: [{
label: i18n.t('Window'),
2021-08-13 18:20:29 +02:00
submenu: [{ role: 'minimize', label: i18n.t('Minimize') }],
2020-03-26 14:31:11 +01:00
}]
),
2016-10-30 11:57:12 +01:00
{
label: i18n.t('Tools'),
submenu: [
2022-02-23 14:16:02 +01:00
{
label: i18n.t('Merge/concatenate files'),
click() {
mainWindow.webContents.send('concatCurrentBatch');
},
},
{
label: i18n.t('Set custom start offset/timecode'),
click() {
2022-02-23 14:16:02 +01:00
mainWindow.webContents.send('askSetStartTimeOffset');
},
},
2021-08-13 18:20:29 +02:00
{ role: 'toggleDevTools', label: i18n.t('Toggle Developer Tools') },
],
},
{
role: 'help',
2021-08-13 18:20:29 +02:00
label: i18n.t('Help'),
submenu: [
{
label: i18n.t('Help and shortcuts'),
click() {
2022-02-23 12:43:19 +01:00
mainWindow.webContents.send('toggleHelp');
},
},
{
label: i18n.t('About'),
click() {
mainWindow.webContents.send('openAbout');
},
},
2021-11-15 08:32:27 +01:00
{
label: i18n.t('Licenses'),
click() { electron.shell.openExternal(licensesPage); },
},
{
label: i18n.t('Learn More'),
click() { electron.shell.openExternal(homepage); },
},
{
label: i18n.t('Report an error'),
click() { mainWindow.webContents.send('openSendReportDialog'); },
},
],
},
];
2016-10-30 11:57:12 +01:00
2018-02-17 15:15:30 +01:00
if (newVersion) {
menu.push({
label: i18n.t('New version!'),
2018-02-17 15:15:30 +01:00
submenu: [
{
label: i18n.t('Download {{version}}', { version: newVersion }),
click() { electron.shell.openExternal(getReleaseUrl(newVersion)); },
2018-02-17 15:15:30 +01:00
},
],
});
}
2016-10-30 11:57:12 +01:00
Menu.setApplicationMenu(Menu.buildFromTemplate(menu));
};