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

401 lines
11 KiB
JavaScript
Raw Normal View History

2022-11-23 10:00:00 +01:00
const electron = require('electron');
const i18n = require('i18next');
2016-10-30 11:57:12 +01:00
2023-02-06 07:33:02 +01:00
// menu-safe i18n.t:
// https://github.com/mifi/lossless-cut/issues/1456
const t = (key) => i18n.t(key).replace(/&/g, '&&');
2018-09-30 22:08:36 +02:00
const { Menu } = 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
{
2023-02-06 07:33:02 +01:00
label: t('File'),
submenu: [
{
2023-02-06 07:33:02 +01:00
label: t('Open'),
accelerator: 'CmdOrCtrl+O',
async click() {
mainWindow.webContents.send('openFilesDialog');
},
},
{
2023-02-06 07:33:02 +01:00
label: 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
{
2023-02-06 07:33:02 +01:00
label: t('Close batch'),
2021-08-28 16:47:43 +02:00
async click() {
2022-02-23 12:43:19 +01:00
mainWindow.webContents.send('closeBatchFiles');
2021-08-28 16:47:43 +02:00
},
},
{ type: 'separator' },
{
2023-02-06 07:33:02 +01:00
label: t('Import project (LLC)...'),
click() {
mainWindow.webContents.send('importEdlFile', 'llc');
},
},
2020-12-11 16:15:35 +01:00
{
2023-02-06 07:33:02 +01:00
label: 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
{
2023-02-06 07:33:02 +01:00
label: t('Import project'),
2020-11-18 21:24:20 +01:00
submenu: [
{
2023-02-06 07:33:02 +01:00
label: t('Times in seconds (CSV)'),
click() {
mainWindow.webContents.send('importEdlFile', 'csv');
},
},
{
2023-02-06 07:33:02 +01:00
label: t('Frame numbers (CSV)'),
click() {
mainWindow.webContents.send('importEdlFile', 'csv-frames');
},
},
{
2023-02-06 07:33:02 +01:00
label: t('EDL (MPlayer)'),
click() {
mainWindow.webContents.send('importEdlFile', 'mplayer');
},
},
{
2023-02-06 07:33:02 +01:00
label: t('Text chapters / YouTube'),
click() {
mainWindow.webContents.send('importEdlFile', 'youtube');
},
},
2020-11-18 21:24:20 +01:00
{
2023-02-06 07:33:02 +01:00
label: t('DaVinci Resolve / Final Cut Pro XML'),
2020-11-18 21:24:20 +01:00
click() {
mainWindow.webContents.send('importEdlFile', 'xmeml');
},
},
2022-07-17 23:36:57 +02:00
{
2023-02-06 07:33:02 +01:00
label: t('Final Cut Pro FCPX / FCPXML'),
2022-07-17 23:36:57 +02:00
click() {
mainWindow.webContents.send('importEdlFile', 'fcpxml');
},
},
{
2023-02-06 07:33:02 +01:00
label: t('CUE sheet file'),
click() {
mainWindow.webContents.send('importEdlFile', 'cue');
},
},
{
2023-02-06 07:33:02 +01:00
label: t('PotPlayer Bookmarks (.pbf)'),
click() {
mainWindow.webContents.send('importEdlFile', 'pbf');
},
},
2020-11-18 21:24:20 +01:00
],
},
{
2023-02-06 07:33:02 +01:00
label: t('Export project'),
submenu: [
{
2023-02-06 07:33:02 +01:00
label: t('Times in seconds (CSV)'),
click() {
mainWindow.webContents.send('exportEdlFile', 'csv');
},
},
{
2023-02-06 07:33:02 +01:00
label: t('Timestamps (CSV)'),
click() {
2020-12-15 00:49:08 +01:00
mainWindow.webContents.send('exportEdlFile', 'csv-human');
},
},
{
2023-02-06 07:33:02 +01:00
label: t('Frame numbers (CSV)'),
click() {
mainWindow.webContents.send('exportEdlFile', 'csv-frames');
},
},
2020-12-15 00:49:08 +01:00
{
2023-02-06 07:33:02 +01:00
label: t('Timestamps (TSV/TXT)'),
2020-12-15 00:49:08 +01:00
click() {
mainWindow.webContents.send('exportEdlFile', 'tsv-human');
},
},
{
2023-02-06 07:33:02 +01:00
label: t('Start times as YouTube Chapters'),
click() {
mainWindow.webContents.send('exportEdlYouTube');
},
},
],
},
{ type: 'separator' },
{
2023-02-06 07:33:02 +01:00
label: t('Convert to supported format'),
click() {
mainWindow.webContents.send('html5ify');
},
},
2020-11-22 23:53:04 +01:00
{
2023-02-06 07:33:02 +01:00
label: 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' },
{
2023-02-06 07:33:02 +01:00
label: t('Settings'),
accelerator: 'CmdOrCtrl+,',
click() {
2022-02-23 12:43:19 +01:00
mainWindow.webContents.send('toggleSettings');
},
},
2022-08-12 11:37:39 +02:00
// Due to Apple Review Guidelines, we cannot include an Exit menu item here
// Apple has their own Quit from the app menu
...(process.platform !== 'darwin' ? [
{ type: 'separator' },
{
2023-02-06 07:33:02 +01:00
label: t('Exit'),
2022-08-12 11:37:39 +02:00
click() {
app.quit();
},
},
2022-08-12 11:37:39 +02:00
] : []),
],
2020-02-20 11:41:01 +01:00
},
{
2023-02-06 07:33:02 +01:00
label: t('Edit'),
submenu: [
// https://github.com/mifi/lossless-cut/issues/610
// https://github.com/mifi/lossless-cut/issues/1183
2023-02-06 07:33:02 +01:00
{ role: 'undo', label: t('Undo') },
{ role: 'redo', label: t('Redo') },
{ type: 'separator' },
2023-02-06 07:33:02 +01:00
{ role: 'cut', label: t('Cut') },
{ role: 'copy', label: t('Copy') },
{ role: 'paste', label: t('Paste') },
{ role: 'selectall', label: t('Select All') },
{ type: 'separator' },
{
2023-02-06 07:33:02 +01:00
label: t('Segments'),
submenu: [
2020-12-14 12:29:17 +01:00
{
2023-02-06 07:33:02 +01:00
label: t('Clear all segments'),
2020-12-14 12:29:17 +01:00
click() {
mainWindow.webContents.send('clearSegments');
},
},
{
2023-02-06 07:33:02 +01:00
label: t('Reorder segments by start time'),
click() {
mainWindow.webContents.send('reorderSegsByStartTime');
},
},
{
2023-02-06 07:33:02 +01:00
label: t('Create num segments'),
click() {
mainWindow.webContents.send('createNumSegments');
},
},
{
2023-02-06 07:33:02 +01:00
label: t('Create fixed duration segments'),
click() {
mainWindow.webContents.send('createFixedDurationSegments');
},
},
2022-05-24 07:31:48 +02:00
{
2023-02-06 07:33:02 +01:00
label: t('Create random segments'),
2022-05-24 07:31:48 +02:00
click() {
mainWindow.webContents.send('createRandomSegments');
},
},
{
2023-02-06 07:33:02 +01:00
label: t('Invert all segments on timeline'),
click() {
mainWindow.webContents.send('invertAllSegments');
},
},
{
2023-02-06 07:33:02 +01:00
label: t('Fill gaps between segments'),
click() {
mainWindow.webContents.send('fillSegmentsGaps');
},
},
{
2023-02-06 07:33:02 +01:00
label: t('Combine overlapping segments'),
click() {
mainWindow.webContents.send('combineOverlappingSegments');
},
},
2022-02-18 07:34:20 +01:00
{
2023-02-06 07:33:02 +01:00
label: t('Shuffle segments order'),
2022-02-18 07:34:20 +01:00
click() {
mainWindow.webContents.send('shuffleSegments');
},
},
2022-03-01 16:10:25 +01:00
{
2023-02-06 07:33:02 +01:00
label: t('Shift all segments on timeline'),
2022-03-01 16:10:25 +01:00
click() {
mainWindow.webContents.send('shiftAllSegmentTimes');
},
},
2023-02-05 12:08:28 +01:00
{
2023-02-06 07:33:02 +01:00
label: t('Align segment times to keyframes'),
2023-02-05 12:08:28 +01:00
click() {
mainWindow.webContents.send('alignSegmentTimesToKeyframes');
},
},
],
},
2020-12-11 16:15:35 +01:00
{
2023-02-06 07:33:02 +01:00
label: t('Tracks'),
2020-12-11 16:15:35 +01:00
submenu: [
{
2023-02-06 07:33:02 +01:00
label: 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
},
},
{
2023-02-06 07:33:02 +01:00
label: 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
},
{
2023-02-06 07:33:02 +01:00
label: t('View'),
submenu: [
2023-02-06 07:33:02 +01:00
{ role: 'togglefullscreen', label: 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'
2023-02-06 07:33:02 +01:00
? [{ role: 'windowMenu', label: t('Window') }]
2020-03-26 14:31:11 +01:00
: [{
2023-02-06 07:33:02 +01:00
label: t('Window'),
submenu: [{ role: 'minimize', label: t('Minimize') }],
2020-03-26 14:31:11 +01:00
}]
),
2016-10-30 11:57:12 +01:00
{
2023-02-06 07:33:02 +01:00
label: t('Tools'),
submenu: [
2022-02-23 14:16:02 +01:00
{
2023-02-06 07:33:02 +01:00
label: t('Merge/concatenate files'),
2022-02-23 14:16:02 +01:00
click() {
mainWindow.webContents.send('concatCurrentBatch');
},
},
{
2023-02-06 07:33:02 +01:00
label: t('Set custom start offset/timecode'),
click() {
2022-02-23 14:16:02 +01:00
mainWindow.webContents.send('askSetStartTimeOffset');
},
},
{
2023-02-06 07:33:02 +01:00
label: t('Detect black scenes'),
click() {
mainWindow.webContents.send('detectBlackScenes');
},
},
{
2023-02-06 07:33:02 +01:00
label: t('Detect silent scenes'),
click() {
mainWindow.webContents.send('detectSilentScenes');
},
},
{
2023-02-06 07:33:02 +01:00
label: t('Detect scene changes'),
click() {
mainWindow.webContents.send('detectSceneChanges');
},
},
{
2023-02-06 07:33:02 +01:00
label: t('Create segments from keyframes'),
click() {
mainWindow.webContents.send('createSegmentsFromKeyframes');
},
},
{
2023-02-06 07:33:02 +01:00
label: t('Last ffmpeg commands'),
click() { mainWindow.webContents.send('toggleLastCommands'); },
},
{ type: 'separator' },
2023-02-06 07:33:02 +01:00
{ role: 'toggleDevTools', label: t('Toggle Developer Tools') },
],
},
{
role: 'help',
2023-02-06 07:33:02 +01:00
label: t('Help'),
submenu: [
{
2023-02-06 07:33:02 +01:00
label: t('How to use'),
click() { electron.shell.openExternal('https://mifi.no/losslesscut/usage'); },
},
{
2023-02-06 07:33:02 +01:00
label: t('FAQ'),
click() { electron.shell.openExternal('https://mifi.no/losslesscut/faq'); },
},
2021-11-15 08:32:27 +01:00
{
2023-02-06 07:33:02 +01:00
label: t('Troubleshooting'),
click() { electron.shell.openExternal('https://mifi.no/losslesscut/troubleshooting'); },
2021-11-15 08:32:27 +01:00
},
{
2023-02-06 07:33:02 +01:00
label: t('Learn More'),
click() { electron.shell.openExternal(homepage); },
},
{
2023-02-06 07:33:02 +01:00
label: t('Licenses'),
click() { electron.shell.openExternal(licensesPage); },
},
{ type: 'separator' },
{
2023-02-06 07:33:02 +01:00
label: t('Keyboard & mouse shortcuts'),
click() {
mainWindow.webContents.send('toggleKeyboardShortcuts');
},
},
{
2023-02-06 07:33:02 +01:00
label: t('Report an error'),
click() { mainWindow.webContents.send('openSendReportDialog'); },
},
{
2023-02-06 07:33:02 +01:00
label: t('Version'),
click() { mainWindow.webContents.send('openAbout'); },
},
],
},
];
2016-10-30 11:57:12 +01:00
2018-02-17 15:15:30 +01:00
if (newVersion) {
menu.push({
2023-02-06 07:33:02 +01:00
label: t('New version!'),
2018-02-17 15:15:30 +01:00
submenu: [
{
2023-02-06 07:33:02 +01:00
label: 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));
};