mirror of
https://github.com/mifi/lossless-cut.git
synced 2024-11-22 02:12:30 +01:00
parent
3ecc202022
commit
8a9438847b
@ -76,7 +76,6 @@
|
||||
"wait-on": "^4.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"electron-default-menu": "^1.0.0",
|
||||
"electron-is-dev": "^0.1.2",
|
||||
"electron-store": "^5.1.0",
|
||||
"execa": "^4.0.0",
|
||||
@ -89,6 +88,7 @@
|
||||
"i18next-node-fs-backend": "^2.1.3",
|
||||
"mime-types": "^2.1.14",
|
||||
"read-chunk": "^2.0.0",
|
||||
"semver": "^7.1.3",
|
||||
"string-to-stream": "^1.1.1",
|
||||
"trash": "^6.1.1"
|
||||
},
|
||||
|
7
public/constants.js
Normal file
7
public/constants.js
Normal file
@ -0,0 +1,7 @@
|
||||
const homepage = 'https://github.com/mifi/lossless-cut';
|
||||
const releasesPage = 'https://github.com/mifi/lossless-cut/releases';
|
||||
|
||||
module.exports = {
|
||||
homepage,
|
||||
releasesPage,
|
||||
};
|
207
public/menu.js
207
public/menu.js
@ -1,119 +1,130 @@
|
||||
const electron = require('electron'); // eslint-disable-line
|
||||
const defaultMenu = require('electron-default-menu');
|
||||
|
||||
const { Menu } = electron;
|
||||
const { dialog } = electron;
|
||||
|
||||
const homepage = 'https://github.com/mifi/lossless-cut';
|
||||
const releasesPage = 'https://github.com/mifi/lossless-cut/releases';
|
||||
const { homepage, releasesPage } = require('./constants');
|
||||
|
||||
module.exports = (app, mainWindow, newVersion) => {
|
||||
const menu = defaultMenu(app, electron.shell);
|
||||
const menu = [
|
||||
...(process.platform === 'darwin' ? [{ role: 'appMenu' }] : []),
|
||||
|
||||
const fileMenu = {
|
||||
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: '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');
|
||||
{
|
||||
label: 'Close',
|
||||
accelerator: 'CmdOrCtrl+W',
|
||||
async click() {
|
||||
mainWindow.webContents.send('close-file');
|
||||
},
|
||||
},
|
||||
},
|
||||
{ type: 'separator' },
|
||||
{
|
||||
label: 'Import CSV cut file',
|
||||
click() {
|
||||
mainWindow.webContents.send('importEdlFile');
|
||||
{ type: 'separator' },
|
||||
{
|
||||
label: 'Import CSV cut file',
|
||||
click() {
|
||||
mainWindow.webContents.send('importEdlFile');
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Export CSV cut file',
|
||||
click() {
|
||||
mainWindow.webContents.send('exportEdlFile');
|
||||
{
|
||||
label: 'Export CSV cut file',
|
||||
click() {
|
||||
mainWindow.webContents.send('exportEdlFile');
|
||||
},
|
||||
},
|
||||
},
|
||||
{ type: 'separator' },
|
||||
{
|
||||
label: 'Convert to friendly format (fastest)',
|
||||
click() {
|
||||
mainWindow.webContents.send('html5ify', 'fastest');
|
||||
{ type: 'separator' },
|
||||
{
|
||||
label: 'Convert to friendly format (fastest)',
|
||||
click() {
|
||||
mainWindow.webContents.send('html5ify', 'fastest');
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Convert to friendly format (fast)',
|
||||
click() {
|
||||
mainWindow.webContents.send('html5ify', 'fast');
|
||||
{
|
||||
label: 'Convert to friendly format (fast)',
|
||||
click() {
|
||||
mainWindow.webContents.send('html5ify', 'fast');
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Convert to friendly codec (slow)',
|
||||
click() {
|
||||
mainWindow.webContents.send('html5ify', 'slow');
|
||||
{
|
||||
label: 'Convert to friendly codec (slow)',
|
||||
click() {
|
||||
mainWindow.webContents.send('html5ify', 'slow');
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Convert to friendly codec (slowest, audio)',
|
||||
click() {
|
||||
mainWindow.webContents.send('html5ify', 'slow-audio');
|
||||
{
|
||||
label: 'Convert to friendly codec (slowest, audio)',
|
||||
click() {
|
||||
mainWindow.webContents.send('html5ify', 'slow-audio');
|
||||
},
|
||||
},
|
||||
},
|
||||
{ type: 'separator' },
|
||||
{
|
||||
label: 'Extract all streams',
|
||||
click() {
|
||||
mainWindow.webContents.send('extract-all-streams', false);
|
||||
{ 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: 'Settings',
|
||||
click() {
|
||||
mainWindow.webContents.send('openSettings');
|
||||
},
|
||||
},
|
||||
},
|
||||
{ type: 'separator' },
|
||||
{
|
||||
label: 'Exit',
|
||||
click() {
|
||||
app.quit();
|
||||
{ type: 'separator' },
|
||||
{
|
||||
label: 'Exit',
|
||||
click() {
|
||||
app.quit();
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const editSubMenu = menu.find(item => item.label === 'Edit').submenu;
|
||||
editSubMenu.splice(editSubMenu.findIndex(item => item.label === 'Undo'), 1, {
|
||||
label: 'Undo',
|
||||
accelerator: 'CmdOrCtrl+Z',
|
||||
click() {
|
||||
mainWindow.webContents.send('undo');
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
editSubMenu.splice(editSubMenu.findIndex(item => item.label === 'Redo'), 1, {
|
||||
label: 'Redo',
|
||||
accelerator: 'Shift+CmdOrCtrl+Z',
|
||||
click() {
|
||||
mainWindow.webContents.send('redo');
|
||||
{
|
||||
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' },
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
{
|
||||
label: 'View',
|
||||
submenu: [
|
||||
{ role: 'togglefullscreen' },
|
||||
],
|
||||
},
|
||||
|
||||
menu.splice((process.platform === 'darwin' ? 1 : 0), 0, fileMenu);
|
||||
{ role: 'windowMenu' },
|
||||
|
||||
const helpIndex = menu.findIndex(item => item.role === 'help');
|
||||
if (helpIndex >= 0) {
|
||||
menu.splice(helpIndex, 1, {
|
||||
{
|
||||
label: 'Tools',
|
||||
submenu: [
|
||||
{
|
||||
@ -128,25 +139,31 @@ module.exports = (app, mainWindow, newVersion) => {
|
||||
mainWindow.webContents.send('set-start-offset', true);
|
||||
},
|
||||
},
|
||||
{ role: 'toggleDevTools' },
|
||||
],
|
||||
},
|
||||
{
|
||||
role: 'help',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Help',
|
||||
label: 'Help and shortcuts',
|
||||
click() {
|
||||
mainWindow.webContents.send('openHelp');
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
label: 'About',
|
||||
click() {
|
||||
mainWindow.webContents.send('openAbout');
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Learn More',
|
||||
click() { electron.shell.openExternal(homepage); },
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
if (newVersion) {
|
||||
menu.push({
|
||||
|
@ -1,6 +1,8 @@
|
||||
const GitHub = require('github-api');
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
const electron = require('electron');
|
||||
const semver = require('semver');
|
||||
|
||||
|
||||
const { app } = electron;
|
||||
|
||||
@ -13,15 +15,15 @@ async function checkNewVersion() {
|
||||
// View the latest published full release for the repository.
|
||||
// Draft releases and prereleases are not returned by this endpoint.
|
||||
const res = (await repo.getRelease('latest')).data;
|
||||
const tagName = res.tag_name;
|
||||
const newestVersion = res.tag_name.replace(/^v?/, '');
|
||||
|
||||
const currentVersion = app.getVersion();
|
||||
// const currentVersion = '1.8.0';
|
||||
// const currentVersion = '3.17.2';
|
||||
|
||||
console.log('Current version', currentVersion);
|
||||
console.log('Newest version', tagName);
|
||||
console.log('Newest version', newestVersion);
|
||||
|
||||
if (tagName !== `v${currentVersion}`) return tagName;
|
||||
if (semver.lt(currentVersion, newestVersion)) return newestVersion;
|
||||
return undefined;
|
||||
} catch (e) {
|
||||
console.error('Failed to check github version');
|
||||
|
12
src/App.jsx
12
src/App.jsx
@ -59,7 +59,7 @@ const trash = window.require('trash');
|
||||
const { unlink, exists } = window.require('fs-extra');
|
||||
|
||||
|
||||
const { dialog } = electron.remote;
|
||||
const { dialog, app } = electron.remote;
|
||||
|
||||
|
||||
function createSegment({ start, end, name } = {}) {
|
||||
@ -1290,6 +1290,14 @@ const App = memo(() => {
|
||||
toggleHelp();
|
||||
}
|
||||
|
||||
function openAbout() {
|
||||
Swal.fire({
|
||||
icon: 'info',
|
||||
title: 'About LosslessCut',
|
||||
text: `You are running version ${app.getVersion()}`,
|
||||
});
|
||||
}
|
||||
|
||||
function openSettings() {
|
||||
toggleSettings();
|
||||
}
|
||||
@ -1306,6 +1314,7 @@ const App = memo(() => {
|
||||
electron.ipcRenderer.on('exportEdlFile', exportEdlFile);
|
||||
electron.ipcRenderer.on('openHelp', openHelp);
|
||||
electron.ipcRenderer.on('openSettings', openSettings);
|
||||
electron.ipcRenderer.on('openAbout', openAbout);
|
||||
|
||||
return () => {
|
||||
electron.ipcRenderer.removeListener('file-opened', fileOpened);
|
||||
@ -1320,6 +1329,7 @@ const App = memo(() => {
|
||||
electron.ipcRenderer.removeListener('exportEdlFile', exportEdlFile);
|
||||
electron.ipcRenderer.removeListener('openHelp', openHelp);
|
||||
electron.ipcRenderer.removeListener('openSettings', openSettings);
|
||||
electron.ipcRenderer.removeListener('openAbout', openAbout);
|
||||
};
|
||||
}, [
|
||||
load, mergeFiles, outputDir, filePath, isFileOpened, customOutDir, startTimeOffset, getHtml5ifiedPath,
|
||||
|
@ -5,9 +5,12 @@ import { motion, AnimatePresence } from 'framer-motion';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { toast } from './util';
|
||||
import { primaryColor } from './colors';
|
||||
|
||||
const { clipboard } = window.require('electron');
|
||||
const electron = window.require('electron');
|
||||
const { clipboard } = electron;
|
||||
|
||||
const { homepage } = electron.remote.require('./constants');
|
||||
|
||||
const HelpSheet = memo(({
|
||||
visible, onTogglePress, ffmpegCommandLog,
|
||||
@ -25,7 +28,11 @@ const HelpSheet = memo(({
|
||||
>
|
||||
<IoIosCloseCircleOutline role="button" onClick={onTogglePress} size={30} style={{ position: 'fixed', right: 0, top: 0, padding: 20 }} />
|
||||
|
||||
<h1>{t('Keyboard shortcuts')}</h1>
|
||||
<p style={{ fontWeight: 'bold' }}>
|
||||
For usage help and issues, go to<br />
|
||||
<span style={{ color: primaryColor, cursor: 'pointer' }} role="button" onClick={() => electron.shell.openExternal(homepage)}>{homepage}</span>
|
||||
</p>
|
||||
<h1>{t('Keyboard & mouse shortcuts')}</h1>
|
||||
<div><kbd>H</kbd> {t('Show/hide this screen')}</div>
|
||||
|
||||
<h2>{t('Playback')}</h2>
|
||||
|
10
yarn.lock
10
yarn.lock
@ -4436,11 +4436,6 @@ electron-builder@^22.3.2:
|
||||
update-notifier "^4.0.0"
|
||||
yargs "^15.1.0"
|
||||
|
||||
electron-default-menu@^1.0.0:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/electron-default-menu/-/electron-default-menu-1.0.1.tgz#3173c5018eb507404fec63bdf3b78c38eedba808"
|
||||
integrity sha1-MXPFAY61B0BP7GO987eMOO7bqAg=
|
||||
|
||||
electron-devtools-installer@^2.2.4:
|
||||
version "2.2.4"
|
||||
resolved "https://registry.yarnpkg.com/electron-devtools-installer/-/electron-devtools-installer-2.2.4.tgz#261a50337e37121d338b966f07922eb4939a8763"
|
||||
@ -11241,6 +11236,11 @@ semver@^7.1.1:
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.1.2.tgz#847bae5bce68c5d08889824f02667199b70e3d87"
|
||||
integrity sha512-BJs9T/H8sEVHbeigqzIEo57Iu/3DG6c4QoqTfbQB3BPA4zgzAomh/Fk9E7QtjWQ8mx2dgA9YCfSF4y9k9bHNpQ==
|
||||
|
||||
semver@^7.1.3:
|
||||
version "7.1.3"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.1.3.tgz#e4345ce73071c53f336445cfc19efb1c311df2a6"
|
||||
integrity sha512-ekM0zfiA9SCBlsKa2X1hxyxiI4L3B6EbVJkkdgQXnSEEaHlGdvyodMruTiulSRWMMB4NeIuYNMC9rTKTz97GxA==
|
||||
|
||||
send@0.17.1:
|
||||
version "0.17.1"
|
||||
resolved "https://registry.yarnpkg.com/send/-/send-0.17.1.tgz#c1d8b059f7900f7466dd4938bdc44e11ddb376c8"
|
||||
|
Loading…
Reference in New Issue
Block a user