1
0
mirror of https://github.com/mifi/lossless-cut.git synced 2024-11-25 19:52:44 +01:00
lossless-cut/public/menu.js

192 lines
4.5 KiB
JavaScript
Raw Normal View History

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
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) => {
const menu = [
...(process.platform === 'darwin' ? [{ role: 'appMenu' }] : []),
2016-10-30 11:57:12 +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)',
click() {
2020-11-18 21:24:20 +01:00
mainWindow.webContents.send('importEdlFile', 'csv');
},
},
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-05-17 07:44:19 +02:00
label: 'Save project (CSV)',
click() {
mainWindow.webContents.send('exportEdlFile');
},
},
{ type: 'separator' },
{
label: 'Convert to supported format',
click() {
mainWindow.webContents.send('html5ify');
},
},
{ 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
},
{
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
},
{
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
{
label: 'Tools',
submenu: [
{
label: 'Merge files',
click() {
mainWindow.webContents.send('show-merge-dialog', true);
},
},
{
label: 'Batch convert to supported format',
click() {
mainWindow.webContents.send('batchConvertFriendlyFormat');
},
},
{
label: 'Set custom start offset/timecode',
click() {
mainWindow.webContents.send('set-start-offset', true);
},
},
{ role: 'toggleDevTools' },
],
},
{
role: 'help',
submenu: [
{
label: 'Help and shortcuts',
click() {
mainWindow.webContents.send('openHelp');
},
},
{
label: 'About',
click() {
mainWindow.webContents.send('openAbout');
},
},
{
label: 'Learn More',
click() { electron.shell.openExternal(homepage); },
},
{
label: '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: 'New version!',
submenu: [
{
label: `Download ${newVersion}`,
click() { electron.shell.openExternal(releasesPage); },
},
],
});
}
2016-10-30 11:57:12 +01:00
Menu.setApplicationMenu(Menu.buildFromTemplate(menu));
};