diff --git a/package.json b/package.json
index 0ce59cf9..17b7df6d 100644
--- a/package.json
+++ b/package.json
@@ -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"
},
diff --git a/public/constants.js b/public/constants.js
new file mode 100644
index 00000000..760fc3f9
--- /dev/null
+++ b/public/constants.js
@@ -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,
+};
diff --git a/public/menu.js b/public/menu.js
index 5c9c0ec3..f166b4f3 100644
--- a/public/menu.js
+++ b/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({
diff --git a/public/update-checker.js b/public/update-checker.js
index 359b3d58..78b80aa9 100644
--- a/public/update-checker.js
+++ b/public/update-checker.js
@@ -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');
diff --git a/src/App.jsx b/src/App.jsx
index d8b26716..6a0be921 100644
--- a/src/App.jsx
+++ b/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,
diff --git a/src/HelpSheet.jsx b/src/HelpSheet.jsx
index f337bbd0..e6b7ba1c 100644
--- a/src/HelpSheet.jsx
+++ b/src/HelpSheet.jsx
@@ -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(({
>
+ For usage help and issues, go to
+ electron.shell.openExternal(homepage)}>{homepage}
+