Skip to content

The swiss army knife of lossless video/audio editing

pull out code

Mikael Finstad05348e9bd0a2
diff --git a/src/App.jsx b/src/App.jsx
index b235d923..dc9d2988 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -65,7 +65,7 @@ import {
checkDirWriteAccess, dirExists, isMasBuild, isStoreBuild, dragPreventer,
filenamify, getOutFileExtension, generateSegFileName, defaultOutSegTemplate,
havePermissionToReadFile, resolvePathIfNeeded, getPathReadAccessError, html5ifiedPrefix, html5dummySuffix, findExistingHtml5FriendlyFile,
- deleteFiles, isOutOfSpaceError, getNumDigits, isExecaFailure, readFileSize, readFileSizes, checkFileSizes,
+ deleteFiles, isOutOfSpaceError, getNumDigits, isExecaFailure, readFileSize, readFileSizes, checkFileSizes, setDocumentTitle,
} from './util';
import { formatDuration } from './util/duration';
import { adjustRate } from './util/rate-calculator';
@@ -95,11 +95,6 @@ const { focusWindow } = remote.require('./electron');
const calcShouldShowWaveform = (zoomedDuration) => (zoomedDuration != null && zoomedDuration < ffmpegExtractWindow * 8);
const calcShouldShowKeyframes = (zoomedDuration) => (zoomedDuration != null && zoomedDuration < ffmpegExtractWindow * 8);
-function setDocumentExtraTitle(extra) {
- const baseTitle = 'LosslessCut';
- if (extra != null) document.title = `${baseTitle} - ${extra}`;
- else document.title = baseTitle;
-}
const videoStyle = { width: '100%', height: '100%', objectFit: 'contain' };
const bottomMotionStyle = { background: controlsBackground };
@@ -172,15 +167,7 @@ const App = memo(() => {
setWorkingState(val);
}, []);
- useEffect(() => {
- const parts = [];
- if (filePath) parts.push(basename(filePath));
- if (working) {
- parts.push('-', working);
- if (cutProgress != null) parts.push(`${(cutProgress * 100).toFixed(1)}%`);
- }
- setDocumentExtraTitle(parts.length > 0 ? parts.join(' ') : undefined);
- }, [cutProgress, filePath, working]);
+ useEffect(() => setDocumentTitle({ filePath, working, cutProgress }), [cutProgress, filePath, working]);
const zoom = Math.floor(zoomUnrounded);
diff --git a/src/util.js b/src/util.js
index 13ad2eb4..e987486b 100644
--- a/src/util.js
+++ b/src/util.js
@@ -7,7 +7,7 @@ import prettyBytes from 'pretty-bytes';
import isDev from './isDev';
-const { dirname, parse: parsePath, join, extname, isAbsolute, resolve } = window.require('path');
+const { dirname, parse: parsePath, join, extname, isAbsolute, resolve, basename } = window.require('path');
const fsExtra = window.require('fs-extra');
const { stat } = window.require('fs/promises');
const os = window.require('os');
@@ -378,3 +378,19 @@ export function checkFileSizes(inputSize, outputSize) {
if (relDiff > maxDiffPercent / 100) return i18n.t('The size of the merged output file ({{outputFileTotalSize}}) differs from the total size of source files ({{sourceFilesTotalSize}}) by more than {{maxDiffPercent}}%. This could indicate that there was a problem during the merge.', { maxDiffPercent, sourceFilesTotalSize, outputFileTotalSize });
return undefined;
}
+
+function setDocumentExtraTitle(extra) {
+ const baseTitle = 'LosslessCut';
+ if (extra != null) document.title = `${baseTitle} - ${extra}`;
+ else document.title = baseTitle;
+}
+
+export function setDocumentTitle({ filePath, working, cutProgress }) {
+ const parts = [];
+ if (filePath) parts.push(basename(filePath));
+ if (working) {
+ parts.push('-', working);
+ if (cutProgress != null) parts.push(`${(cutProgress * 100).toFixed(1)}%`);
+ }
+ setDocumentExtraTitle(parts.length > 0 ? parts.join(' ') : undefined);
+}