pull out code

pull/1457/head
Mikael Finstad 3 years ago
parent 7215f711db
commit 05348e9bd0
No known key found for this signature in database
GPG Key ID: 25AB36E3E81CBC26

@ -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);

@ -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);
}

Loading…
Cancel
Save