Skip to content

The swiss army knife of lossless video/audio editing

simplify concat sheet

Mikael Finstad2511105affe5
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 7becf005..7f689b5a 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -85,7 +85,7 @@ Before releasing, consider [Maintainence chores](#maintainence-chores) first.
### Release built version
- Open draft in github and add the prepared release notes
-- Add prefix `-DO-NOT-DOWNLOAD` to `LosslessCut-mac-universal.pkg` and `LosslessCut-win-x64.appx`
+- Add suffix `-DONT-USE-THIS-FILE` to `LosslessCut-mac-universal.pkg` and `LosslessCut-win-x64.appx`
- *If GitHub release*
- Release the draft
- *If Store-only hotfix release*
diff --git a/src/renderer/src/colors.ts b/src/renderer/src/colors.ts
index 4ac56339..34a82bb8 100644
--- a/src/renderer/src/colors.ts
+++ b/src/renderer/src/colors.ts
@@ -1,5 +1,6 @@
export const saveColor = 'var(--green-11)';
export const dangerColor = 'var(--red-11)';
+export const warningColor = 'var(--orange-9)';
export const primaryColor = 'var(--cyan-9)';
export const primaryTextColor = 'var(--cyan-11)';
export const controlsBackground = 'var(--gray-4)';
diff --git a/src/renderer/src/components/ConcatSheet.tsx b/src/renderer/src/components/ConcatSheet.tsx
index 807d60d1..eaa50a58 100644
--- a/src/renderer/src/components/ConcatSheet.tsx
+++ b/src/renderer/src/components/ConcatSheet.tsx
@@ -1,7 +1,7 @@
import { memo, useState, useCallback, useEffect, useMemo, CSSProperties, Dispatch, SetStateAction } from 'react';
import { useTranslation } from 'react-i18next';
import { AiOutlineMergeCells } from 'react-icons/ai';
-import { FaQuestionCircle, FaExclamationTriangle, FaCog } from 'react-icons/fa';
+import { FaQuestionCircle, FaExclamationTriangle, FaCog, FaCheck } from 'react-icons/fa';
import i18n from 'i18next';
import invariant from 'tiny-invariant';
@@ -14,7 +14,7 @@ import { getOutDir } from '../util';
import { FFprobeChapter, FFprobeFormat, FFprobeStream } from '../../../../ffprobe';
import Button, { DialogButton } from './Button';
import { defaultMergedFileTemplate, GeneratedOutFileNames, GenerateMergedOutFileNames } from '../util/outputNameTemplate';
-import { primaryColor } from '../colors';
+import { primaryColor, saveColor, warningColor } from '../colors';
import ExportSheet from './ExportSheet';
import * as Dialog from './Dialog';
import FileNameTemplateEditor from './FileNameTemplateEditor';
@@ -23,12 +23,12 @@ const { basename } = window.require('path');
const rowStyle: CSSProperties = {
- fontSize: '1em', margin: '.3em 0', overflowY: 'auto', whiteSpace: 'nowrap',
+ margin: '.3em 0', overflowY: 'auto', whiteSpace: 'nowrap',
};
function Alert({ text }: { text: string }) {
return (
- <div style={{ marginBottom: '1em' }}><FaExclamationTriangle style={{ color: 'var(--orange-8)', fontSize: '1.3em', verticalAlign: 'middle', marginRight: '.2em' }} /> {text}</div>
+ <div style={{ marginBottom: '1em' }}><FaExclamationTriangle style={{ color: warningColor, verticalAlign: 'middle', marginRight: '.2em' }} /> {text}</div>
);
}
@@ -62,19 +62,32 @@ function ConcatSheet({ isShown, onHide, paths, mergedFileTemplate, generateMerge
return paths[0];
}, [paths]);
- useEffect(() => {
- if (!isShown) return undefined;
+ const generateFileNames = useCallback(async (template: string) => {
+ invariant(firstPath != null && fileFormat != null);
+ const outputDir = getOutDir(customOutDir, firstPath);
- let aborted = false;
+ return generateMergedFileNames({ template, filePaths: paths, fileFormat, outputDir, epochMs: uniqueSuffix });
+ }, [customOutDir, fileFormat, firstPath, generateMergedFileNames, paths, uniqueSuffix]);
- (async () => {
+ useEffect(() => {
+ if (!isShown) {
setFileMeta(undefined);
setFileFormat(undefined);
setDetectedFileFormat(undefined);
+ }
+ }, [isShown, setDetectedFileFormat, setFileFormat]);
+
+ useEffect(() => {
+ if (!isShown) return undefined;
+
+ const abortController = new AbortController();
+
+ (async () => {
invariant(firstPath != null);
const fileMetaNew = await readFileMeta(firstPath);
const fileFormatNew = await getDefaultOutFormat({ filePath: firstPath, fileMeta: fileMetaNew });
- if (aborted) return;
+ if (abortController.signal.aborted) return;
+
setFileMeta(fileMetaNew);
setDetectedFileFormat(fileFormatNew);
if (outFormatLocked) {
@@ -85,17 +98,24 @@ function ConcatSheet({ isShown, onHide, paths, mergedFileTemplate, generateMerge
setUniqueSuffix(Date.now());
})().catch(console.error);
- return () => {
- aborted = true;
- };
- }, [firstPath, isShown, outFormatLocked, setDetectedFileFormat, setFileFormat]);
+ return () => abortController.abort();
+ }, [firstPath, isShown, outFormatLocked, setDetectedFileFormat, setFileFormat, setMergedFileTemplate, simpleMode]);
- const generateFileNames = useCallback(async (template: string) => {
- invariant(firstPath != null && fileFormat != null);
- const outputDir = getOutDir(customOutDir, firstPath);
+ useEffect(() => {
+ const abortController = new AbortController();
+ console.log('wat', fileFormat);
- return generateMergedFileNames({ template, filePaths: paths, fileFormat, outputDir, epochMs: uniqueSuffix });
- }, [customOutDir, fileFormat, firstPath, generateMergedFileNames, paths, uniqueSuffix]);
+ (async () => {
+ // in simple mode, set merged file template to a generated name based on first file, so they don't *have to* deal with variables
+ if (isShown && simpleMode && firstPath != null && fileFormat != null) {
+ const generated = await generateFileNames(defaultMergedFileTemplate);
+ if (abortController.signal.aborted) return;
+ setMergedFileTemplate(generated.fileNames[0]);
+ }
+ })().catch(console.error);
+
+ return () => abortController.abort();
+ }, [fileFormat, firstPath, generateFileNames, isShown, setMergedFileTemplate, simpleMode]);
const allFilesMeta = useMemo(() => {
if (paths.length === 0) return undefined;
@@ -137,12 +157,12 @@ function ConcatSheet({ isShown, onHide, paths, mergedFileTemplate, generateMerge
useEffect(() => {
if (!isShown || !enableReadFileMeta) return undefined;
- let aborted = false;
+ const abortController = new AbortController();
(async () => {
// eslint-disable-next-line no-restricted-syntax
for (const path of paths) {
- if (aborted) return;
+ if (abortController.signal.aborted) return;
if (!allFilesMetaCache[path]) {
// eslint-disable-next-line no-await-in-loop
const fileMetaNew = await readFileMeta(path);
@@ -151,9 +171,7 @@ function ConcatSheet({ isShown, onHide, paths, mergedFileTemplate, generateMerge
}
})().catch(console.error);
- return () => {
- aborted = true;
- };
+ return () => abortController.abort();
}, [allFilesMetaCache, enableReadFileMeta, isShown, paths]);
const onConcatClick = useCallback(async () => {
@@ -166,6 +184,11 @@ function ConcatSheet({ isShown, onHide, paths, mergedFileTemplate, generateMerge
await onConcat({ paths, includeAllStreams, streams: fileMeta!.streams, fileFormat, clearBatchFilesAfterConcat, generatedFileNames });
}, [clearBatchFilesAfterConcat, customOutDir, fileFormat, fileMeta, firstPath, generateMergedFileNames, includeAllStreams, mergedFileTemplate, onConcat, paths, uniqueSuffix]);
+ const handleReadFileMetaCheckedChange = useCallback((checked: boolean) => {
+ setEnableReadFileMeta(checked);
+ setAllFilesMetaCache({});
+ }, []);
+
return (
<ExportSheet
visible={isShown}
@@ -179,38 +202,42 @@ function ConcatSheet({ isShown, onHide, paths, mergedFileTemplate, generateMerge
width="70em"
>
<div style={{ marginBottom: '1em' }}>
- <div style={{ whiteSpace: 'pre-wrap', fontSize: '.9em', marginBottom: '1em' }}>
+ <div style={{ whiteSpace: 'pre-wrap', marginBottom: '1em' }}>
{t('This dialog can be used to concatenate files in series, e.g. one after the other:\n[file1][file2][file3]\nIt can NOT be used for merging tracks in parallell (like adding an audio track to a video).\nMake sure all files are of the exact same codecs & codec parameters (fps, resolution etc).')}
</div>
- <div style={{ backgroundColor: 'var(--gray-1)', borderRadius: '.1em' }}>
+ <div>
{paths.map((path, index) => (
<div key={path} style={rowStyle} title={path}>
<div>
<span style={{ opacity: 0.7, marginRight: '.4em' }}>{`${index + 1}.`}</span>
<span>{basename(path)}</span>
- {!allFilesMetaCache[path] && <FaQuestionCircle style={{ color: 'var(--orange-8)', verticalAlign: 'middle', marginLeft: '1em' }} />}
-
- {problemsByFile[path] && (
- <Dialog.Root>
- <Dialog.Trigger asChild>
- <Button title={i18n.t('Mismatches detected')} style={{ color: 'var(--orange-8)', marginLeft: '1em', padding: '.2em .4em' }}><FaExclamationTriangle /></Button>
- </Dialog.Trigger>
-
- <Dialog.Portal>
- <Dialog.Overlay />
- <Dialog.Content aria-describedby={undefined}>
- <Dialog.Title>{t('Mismatches detected')}</Dialog.Title>
-
- <ul style={{ margin: '10px 0', textAlign: 'left' }}>
- {(problemsByFile[path] || []).map((problem) => <li key={problem}>{problem}</li>)}
- </ul>
-
- <Dialog.CloseButton />
- </Dialog.Content>
- </Dialog.Portal>
- </Dialog.Root>
+ {allFilesMetaCache[path] ? (
+ problemsByFile[path] ? (
+ <Dialog.Root>
+ <Dialog.Trigger asChild>
+ <Button title={i18n.t('Mismatches detected')} style={{ color: warningColor, marginLeft: '1em', padding: '.2em .4em' }}><FaExclamationTriangle /></Button>
+ </Dialog.Trigger>
+
+ <Dialog.Portal>
+ <Dialog.Overlay />
+ <Dialog.Content aria-describedby={undefined}>
+ <Dialog.Title>{t('Mismatches detected')}</Dialog.Title>
+
+ <ul style={{ margin: '10px 0', textAlign: 'left' }}>
+ {(problemsByFile[path] || []).map((problem) => <li key={problem}>{problem}</li>)}
+ </ul>
+
+ <Dialog.CloseButton />
+ </Dialog.Content>
+ </Dialog.Portal>
+ </Dialog.Root>
+ ) : (
+ <FaCheck style={{ color: saveColor, verticalAlign: 'middle', marginLeft: '1em' }} />
+ )
+ ) : (
+ <FaQuestionCircle style={{ color: warningColor, verticalAlign: 'middle', marginLeft: '1em' }} />
)}
</div>
</div>
@@ -218,12 +245,12 @@ function ConcatSheet({ isShown, onHide, paths, mergedFileTemplate, generateMerge
</div>
</div>
- <div style={{ marginBottom: '1em' }}>
- <Checkbox style={{ marginBottom: '.7em' }} checked={enableReadFileMeta} onCheckedChange={(checked) => setEnableReadFileMeta(!!checked)} label={t('Check compatibility')} />
+ <div style={{ display: 'flex', alignItems: 'center', gap: '1em', marginBottom: '1em', flexWrap: 'wrap' }}>
+ <Checkbox checked={enableReadFileMeta} onCheckedChange={handleReadFileMetaCheckedChange} label={t('Check compatibility')} />
<Dialog.Root>
<Dialog.Trigger asChild>
- <Button style={{ padding: '.3em .5em', marginBottom: '.5em' }}><FaCog style={{ verticalAlign: 'top', fontSize: '1.4em', marginRight: '.2em' }} /> {t('Options')}</Button>
+ <Button style={{ padding: '.3em .5em' }}><FaCog style={{ verticalAlign: 'middle', fontSize: '1.4em', marginRight: '.2em' }} /> {t('Options')}</Button>
</Dialog.Trigger>
<Dialog.Portal>
@@ -247,7 +274,7 @@ function ConcatSheet({ isShown, onHide, paths, mergedFileTemplate, generateMerge
<Dialog.ButtonRow>
<Dialog.Close asChild>
- <DialogButton primary>{t('Done')}</DialogButton>
+ <DialogButton primary>{t('Close')}</DialogButton>
</Dialog.Close>
</Dialog.ButtonRow>
@@ -256,23 +283,23 @@ function ConcatSheet({ isShown, onHide, paths, mergedFileTemplate, generateMerge
</Dialog.Portal>
</Dialog.Root>
- <div>{t('Output container format:')}</div>
-
{fileFormat != null && detectedFileFormat != null && (
- <OutputFormatSelect style={{ height: '1.7em', maxWidth: '20em', marginBottom: '.7em' }} detectedFileFormat={detectedFileFormat} fileFormat={fileFormat} onOutputFormatUserChange={onOutputFormatUserChange} />
+ <OutputFormatSelect style={{ height: '2.1em', maxWidth: '20em' }} detectedFileFormat={detectedFileFormat} fileFormat={fileFormat} onOutputFormatUserChange={onOutputFormatUserChange} />
)}
+ </div>
- {fileFormat != null && (
+ {fileFormat != null && (
+ <div style={{ marginBottom: '1em' }}>
<FileNameTemplateEditor mode="merge-files" template={mergedFileTemplate} setTemplate={setMergedFileTemplate} defaultTemplate={defaultMergedFileTemplate} generateFileNames={generateFileNames} />
- )}
+ </div>
+ )}
- {enableReadFileMeta && (!allFilesMeta || Object.values(problemsByFile).length > 0) && (
- <Alert text={t('A mismatch was detected in at least one file. You may proceed, but the resulting file might not be playable.')} />
- )}
- {!enableReadFileMeta && (
- <Alert text={t('File compatibility check is not enabled, so the merge operation might not produce a valid output. Enable "Check compatibility" below to check file compatibility before merging.')} />
- )}
- </div>
+ {enableReadFileMeta && (!allFilesMeta || Object.values(problemsByFile).length > 0) && (
+ <Alert text={t('A mismatch was detected in at least one file. You may proceed, but the resulting file might not be playable.')} />
+ )}
+ {!enableReadFileMeta && (
+ <Alert text={t('File compatibility check is not enabled, so the merge operation might not produce a valid output. Enable "Check compatibility" below to check file compatibility before merging.')} />
+ )}
</ExportSheet>
);
}
diff --git a/src/renderer/src/components/ErrorDialog.tsx b/src/renderer/src/components/ErrorDialog.tsx
index fb465737..791edbbe 100644
--- a/src/renderer/src/components/ErrorDialog.tsx
+++ b/src/renderer/src/components/ErrorDialog.tsx
@@ -3,6 +3,7 @@ import { FaExclamationTriangle } from 'react-icons/fa';
import * as Dialog from './Dialog';
import { DialogButton } from './Button';
+import { warningColor } from '../colors';
export interface GenericError {
@@ -27,7 +28,7 @@ export default function ErrorDialog({ error, onOpenChange }: {
{error != null && (
<>
<Dialog.Title>
- <FaExclamationTriangle style={{ color: 'var(--orange-6)', marginRight: '.5em', verticalAlign: 'middle' }} />
+ <FaExclamationTriangle style={{ color: warningColor, marginRight: '.5em', verticalAlign: 'middle' }} />
{error.title ?? t('Error')}
</Dialog.Title>
diff --git a/src/renderer/src/components/ExportConfirm.tsx b/src/renderer/src/components/ExportConfirm.tsx
index 10e0fc43..d8f59a4a 100644
--- a/src/renderer/src/components/ExportConfirm.tsx
+++ b/src/renderer/src/components/ExportConfirm.tsx
@@ -12,7 +12,7 @@ import HighlightedText from './HighlightedText';
import Select from './Select';
import Switch from './Switch';
-import { primaryTextColor } from '../colors';
+import { primaryTextColor, warningColor } from '../colors';
import { withBlur } from '../util';
import getSwal from '../swal';
import { isMov as ffmpegIsMov } from '../util/streams';
@@ -31,8 +31,8 @@ import AnimatedTr from './AnimatedTr';
const noticeStyle: CSSProperties = { marginBottom: '.5em' };
-const infoStyle: CSSProperties = { ...noticeStyle, color: 'var(--blue-12)' };
-const warningStyle: CSSProperties = { ...noticeStyle, color: 'var(--orange-8)' };
+const infoStyle: CSSProperties = { ...noticeStyle, color: primaryTextColor };
+const warningStyle: CSSProperties = { ...noticeStyle, color: warningColor };
const rightIconStyle: CSSProperties = { fontSize: '1.2em', verticalAlign: 'middle' };
@@ -55,7 +55,7 @@ function ShiftTimes({ values, num, setNum }: { values: number[], num: number, se
function renderNoticeIcon(notice: { warning?: boolean | undefined } | undefined, style?: CSSProperties) {
if (!notice) return undefined;
return notice.warning ? (
- <FaExclamationTriangle style={{ flexShrink: '0', fontSize: '.8em', verticalAlign: 'baseline', color: 'var(--orange-9)', ...style }} />
+ <FaExclamationTriangle style={{ flexShrink: '0', fontSize: '.8em', verticalAlign: 'baseline', color: warningColor, ...style }} />
) : (
<FaInfoCircle style={{ flexShrink: '0', fontSize: '.8em', verticalAlign: 'baseline', color: 'var(--blue-10)', ...style }} />
);
diff --git a/src/renderer/src/components/FileNameTemplateEditor.tsx b/src/renderer/src/components/FileNameTemplateEditor.tsx
index 573b4c35..96cca413 100644
--- a/src/renderer/src/components/FileNameTemplateEditor.tsx
+++ b/src/renderer/src/components/FileNameTemplateEditor.tsx
@@ -4,7 +4,7 @@ import i18n from 'i18next';
import { useTranslation } from 'react-i18next';
import { IoIosHelpCircle } from 'react-icons/io';
import { motion, AnimatePresence } from 'framer-motion';
-import { FaCheck, FaEdit, FaExclamationTriangle, FaFile, FaUndo } from 'react-icons/fa';
+import { FaCaretUp, FaEdit, FaExclamationTriangle, FaEye, FaFile, FaUndo } from 'react-icons/fa';
import HighlightedText from './HighlightedText';
import { segNumVariable, segSuffixVariable, GenerateOutFileNames, extVariable, segTagsVariable, segNumIntVariable, selectedSegNumVariable, selectedSegNumIntVariable, GeneratedOutFileNames } from '../util/outputNameTemplate';
@@ -14,7 +14,7 @@ import Select from './Select';
import TextInput from './TextInput';
import Button from './Button';
import * as Dialog from './Dialog';
-import { dangerColor, saveColor } from '../colors';
+import { dangerColor, warningColor } from '../colors';
const electron = window.require('electron');
@@ -29,6 +29,7 @@ function FileNameTemplateEditor(opts: {
setTemplate: (text: string) => void,
defaultTemplate: string,
generateFileNames: GenerateOutFileNames,
+ ignoreMissingExtensionWarning?: boolean,
} & ({
currentSegIndexSafe: number,
mode: 'separate'
@@ -44,14 +45,17 @@ function FileNameTemplateEditor(opts: {
const [generated, setGenerated] = useState<GeneratedOutFileNames>();
const haveImportantMessage = generated != null && (generated.problems.error != null || generated.problems.sameAsInputFileNameWarning);
- const [shown, setShown] = useState(haveImportantMessage);
+ const [open, setOpen] = useState(haveImportantMessage);
+
useEffect(() => {
// if an important message appears, make sure we don't auto-close after it's resolved
// https://github.com/mifi/lossless-cut/issues/2567
- if (haveImportantMessage) setShown(true);
+ if (haveImportantMessage) setOpen(true);
}, [haveImportantMessage]);
- const needToShow = shown || haveImportantMessage;
+ useEffect(() => {
+ setText(templateIn);
+ }, [templateIn]);
const inputRef = useRef<HTMLInputElement>(null);
@@ -111,18 +115,18 @@ function FileNameTemplateEditor(opts: {
setTemplate(debouncedText);
}, [debouncedText, setTemplate]);
+ useEffect(() => {
+ if (open) inputRef.current?.focus();
+ }, [open]);
+
const reset = useCallback(() => {
setTemplate(defaultTemplate);
setText(defaultTemplate);
}, [defaultTemplate, setTemplate]);
- const onHideClick = useCallback(() => {
- if (generated != null && generated.problems.error == null) setShown(false);
- }, [generated]);
-
- const onShowClick = useCallback(() => {
- if (!shown) setShown(true);
- }, [shown]);
+ const handleSampleClick = useCallback(() => {
+ setOpen((v) => !v);
+ }, []);
const onTextChange = useCallback<ChangeEventHandler<HTMLInputElement>>((e) => setText(e.target.value), []);
@@ -138,6 +142,9 @@ function FileNameTemplateEditor(opts: {
setText(newValue);
}, [text]);
+ // In simple mode for merge-files, we auto generate file name, so there will be no ${EXT} variable
+ const shouldIgnoreMissingExtension = useMemo(() => simpleMode && mode === 'merge-files', [simpleMode, mode]);
+
function formatCurrentSegFileOrFirst(names: string[]) {
if (mode === 'separate') {
const { currentSegIndexSafe } = opts;
@@ -146,7 +153,8 @@ function FileNameTemplateEditor(opts: {
return fileName;
}
}
- return names[0] ?? '-';
+
+ return names[0];
}
return (
@@ -160,34 +168,42 @@ function FileNameTemplateEditor(opts: {
</div>
)}
- <motion.div animate={{ marginBottom: needToShow ? '1.5em' : '.3em' }}>
+ <div>
{generated != null && (
<div style={{ marginBottom: '.3em' }}>
- <HighlightedText role="button" onClick={onShowClick} style={{ wordBreak: 'break-word', cursor: needToShow ? undefined : 'pointer' }}>
+ <HighlightedText title={open ? t('Close') : t('Edit')} role="button" onClick={handleSampleClick} style={{ wordBreak: 'break-word', cursor: 'pointer' }}>
+ {generated.problems.error != null && <FaExclamationTriangle style={{ color: dangerColor, marginRight: '.2em', verticalAlign: 'middle' }} />}
{generated.originalFileNames != null && formatCurrentSegFileOrFirst(generated.fileNames)}
- <span style={generated.originalFileNames != null ? { textDecoration: 'line-through', marginLeft: '.3em', color: dangerColor } : undefined}>{formatCurrentSegFileOrFirst(generated.originalFileNames ?? generated.fileNames)}</span>
- {!needToShow && <FaEdit style={{ fontSize: '.9em', marginLeft: '.4em', verticalAlign: 'middle' }} />}
+ <span style={generated.originalFileNames != null ? { textDecoration: 'line-through', marginLeft: '.3em', color: dangerColor } : undefined}>
+ {formatCurrentSegFileOrFirst(generated.originalFileNames ?? generated.fileNames)}
+ </span>
+ {open ? (
+ <FaCaretUp style={{ fontSize: '.9em', marginLeft: '.4em', verticalAlign: 'middle' }} />
+ ) : (
+ <FaEdit style={{ fontSize: '.9em', marginLeft: '.4em', verticalAlign: 'middle' }} />
+ )}
</HighlightedText>
</div>
)}
<AnimatePresence>
- {needToShow && (
+ {open && (
<motion.div
key="1"
- style={{ background: 'var(--gray-1)', padding: '.3em .5em', borderRadius: '.3em', margin: '0 -.5em' }}
- initial={{ opacity: 0, height: 0, marginTop: 0 }}
- animate={{ opacity: 1, height: 'auto', marginTop: '.7em' }}
- exit={{ opacity: 0, height: 0, marginTop: 0 }}
+ style={{ border: '.1em solid var(--gray-5)', padding: '.5em .7em', borderRadius: '.3em' }}
+ initial={{ opacity: 0, height: 0, marginTop: 0, marginBottom: 0 }}
+ animate={{ opacity: 1, height: 'auto', marginTop: '.7em', marginBottom: '1em' }}
+ exit={{ opacity: 0, height: 0, marginTop: 0, marginBottom: 0 }}
>
<div style={{ color: 'var(--gray-11)', fontSize: '.8em' }}>{t('Output file name template')}:</div>
+
<div style={{ display: 'flex', alignItems: 'center', marginBottom: '.2em' }}>
- <TextInput ref={inputRef} onChange={onTextChange} value={text} autoComplete="off" autoCapitalize="off" autoCorrect="off" />
+ <TextInput ref={inputRef} onChange={onTextChange} value={text} autoComplete="off" autoCapitalize="off" autoCorrect="off" style={{ padding: '.3em' }} />
{generated != null && generated.fileNames.length > 1 && (
<Dialog.Root>
<Dialog.Trigger asChild>
- <Button style={{ marginLeft: '.3em' }}>{t('Preview')}</Button>
+ <Button style={{ marginLeft: '.3em', padding: '.3em' }} title={t('Preview')}><FaEye /></Button>
</Dialog.Trigger>
<Dialog.Portal>
@@ -205,18 +221,15 @@ function FileNameTemplateEditor(opts: {
</Dialog.Root>
)}
- <Button title={t('Reset')} onClick={reset} style={{ marginLeft: '.3em' }}><FaUndo style={{ fontSize: '.8em', color: dangerColor }} /></Button>
- {!haveImportantMessage && (
- <Button title={t('Close')} onClick={onHideClick} style={{ marginLeft: '.3em', color: saveColor }}><FaCheck style={{ fontSize: '.8em' }} /></Button>
- )}
+ <Button title={t('Reset')} onClick={reset} style={{ marginLeft: '.3em', padding: '.3em' }}><FaUndo style={{ fontSize: '.8em', color: dangerColor }} /></Button>
</div>
- <div style={{ fontSize: '.8em', color: 'var(--gray-11)', display: 'flex', gap: '.3em', flexWrap: 'wrap', alignItems: 'center', marginBottom: '.7em' }}>
+ <div style={{ fontSize: '.9em', color: 'var(--gray-11)', display: 'flex', gap: '.3em', flexWrap: 'wrap', alignItems: 'center', marginBottom: '.7em' }}>
{`${i18n.t('Variables')}:`}
<IoIosHelpCircle fontSize="1.3em" color="var(--gray-12)" role="button" cursor="pointer" onClick={() => electron.shell.openExternal('https://github.com/mifi/lossless-cut/blob/master/docs.md#custom-exported-file-names')} />
{availableVariables.map((variable) => (
- <span key={variable} role="button" style={{ cursor: 'pointer', marginRight: '.2em', textDecoration: 'underline', textDecorationStyle: 'dashed', fontSize: '.9em' }} onClick={() => onVariableClick(variable)}>{variable}</span>
+ <span key={variable} role="button" style={{ cursor: 'copy', marginRight: '.2em', textDecoration: 'underline', textDecorationStyle: 'dashed', fontSize: '.9em' }} onClick={() => onVariableClick(variable)}>{variable}</span>
))}
</div>
@@ -233,36 +246,36 @@ function FileNameTemplateEditor(opts: {
<Switch checked={safeOutputFileName} onCheckedChange={toggleSafeOutputFileName} style={{ verticalAlign: 'middle', marginRight: '.5em' }} />
<span>{t('Sanitize file names')}</span>
- {!safeOutputFileName && <FaExclamationTriangle color="var(--amber-9)" style={{ marginLeft: '.5em', verticalAlign: 'middle' }} />}
+ {!safeOutputFileName && <FaExclamationTriangle color={warningColor} style={{ marginLeft: '.5em', verticalAlign: 'middle' }} />}
</div>
</motion.div>
)}
</AnimatePresence>
{generated?.problems.error != null ? (
- <div style={{ marginBottom: '1em', fontSize: '.9em' }}>
- <FaExclamationTriangle color={dangerColor} style={{ verticalAlign: 'middle', fontSize: '1.1em' }} /> {generated.problems.error}
+ <div style={{ marginBottom: '1em' }}>
+ <FaExclamationTriangle color={dangerColor} style={{ verticalAlign: 'middle', marginRight: '.3em' }} />{generated.problems.error}
</div>
) : (
generated != null && (
<>
{generated.problems.sameAsInputFileNameWarning && (
<div style={{ marginBottom: '1em' }}>
- <FaExclamationTriangle style={{ verticalAlign: 'middle', marginRight: '.3em' }} color="var(--amber-9)" />
+ <FaExclamationTriangle style={{ verticalAlign: 'middle', marginRight: '.3em' }} color={warningColor} />
{i18n.t('Output file name is the same as the source file name. This increases the risk of accidentally overwriting or deleting source files!')}
</div>
)}
- {isMissingExtension && (
+ {!shouldIgnoreMissingExtension && isMissingExtension && (
<div style={{ marginBottom: '1em' }}>
- <FaExclamationTriangle style={{ verticalAlign: 'middle', marginRight: '.3em' }} color="var(--amber-9)" />
+ <FaExclamationTriangle style={{ verticalAlign: 'middle', marginRight: '.3em' }} color={warningColor} />
{i18n.t('The file name template is missing {{ext}} and will result in a file without the suggested extension. This may result in an unplayable output file.', { ext: extVariableFormatted })}
</div>
)}
</>
)
)}
- </motion.div>
+ </div>
</>
);
}
diff --git a/src/renderer/src/components/GenericDialog.tsx b/src/renderer/src/components/GenericDialog.tsx
index e5ee76e6..089080f8 100644
--- a/src/renderer/src/components/GenericDialog.tsx
+++ b/src/renderer/src/components/GenericDialog.tsx
@@ -9,6 +9,7 @@ import { DialogButton } from './Button';
import { showItemInFolder } from '../util';
import { CleanupChoice, CleanupChoicesType, ListItem, Notices, OutputIncorrectSeeHelpMenu, UnorderedList, Warnings } from '../dialogs';
import Checkbox from './Checkbox';
+import { saveColor, warningColor } from '../colors';
export interface GenericDialogParams {
@@ -174,7 +175,7 @@ export function useDialog() {
width: '60em',
children: (
<UnorderedList>
- <ListItem icon={<FaCheckCircle />} iconColor={hasWarnings ? 'var(--orange-8)' : 'var(--green-11)'} style={{ fontWeight: 'bold' }}>{hasWarnings ? t('Export finished with warning(s)', { count: warnings.length }) : t('Export is done!')}</ListItem>
+ <ListItem icon={<FaCheckCircle />} iconColor={hasWarnings ? warningColor : saveColor} style={{ fontWeight: 'bold' }}>{hasWarnings ? t('Export finished with warning(s)', { count: warnings.length }) : t('Export is done!')}</ListItem>
<Warnings warnings={warnings} />
<ListItem icon={<FaInfoCircle />}>{t('Please test the output file in your desired player/editor before you delete the source file.')}</ListItem>
<OutputIncorrectSeeHelpMenu />
diff --git a/src/renderer/src/components/Warning.tsx b/src/renderer/src/components/Warning.tsx
index f8d60213..ed44bdde 100644
--- a/src/renderer/src/components/Warning.tsx
+++ b/src/renderer/src/components/Warning.tsx
@@ -1,8 +1,9 @@
import { DetailedHTMLProps, HTMLAttributes, useMemo } from 'react';
+import { warningColor } from '../colors';
export default function Warning({ style, ...props }: DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>) {
- const mergedStyle = useMemo(() => ({ color: 'var(--orange-8)', ...style }), [style]);
+ const mergedStyle = useMemo(() => ({ color: warningColor, ...style }), [style]);
// eslint-disable-next-line react/jsx-props-no-spreading
return <div style={mergedStyle} {...props} />;
}
diff --git a/src/renderer/src/dialogs/index.tsx b/src/renderer/src/dialogs/index.tsx
index 163630c6..af062964 100644
--- a/src/renderer/src/dialogs/index.tsx
+++ b/src/renderer/src/dialogs/index.tsx
@@ -12,7 +12,7 @@ import CopyClipboardButton from '../components/CopyClipboardButton';
import { appPath, isMac, isMasBuild, isWindows, isWindowsStoreBuild, testFailFsOperation, trashFile, unlinkWithRetry } from '../util';
import { ParseTimecode } from '../types';
import { FindKeyframeMode } from '../ffmpeg';
-import { dangerColor } from '../colors';
+import { dangerColor, primaryColor, warningColor } from '../colors';
import getSwal from '../swal';
import isDev from '../isDev';
@@ -509,10 +509,10 @@ export const ListItem = ({ icon, iconColor, children, style }: { icon: ReactNode
);
export const Notices = ({ notices }: { notices: string[] }) => notices.map((msg) => (
- <ListItem key={msg} icon={<FaInfoCircle />} iconColor="var(--blue-9)">{msg}</ListItem>
+ <ListItem key={msg} icon={<FaInfoCircle />} iconColor={primaryColor}>{msg}</ListItem>
));
export const Warnings = ({ warnings }: { warnings: string[] }) => warnings.map((msg) => (
- <ListItem key={msg} icon={<FaExclamationTriangle />} iconColor="var(--orange-8)">{msg}</ListItem>
+ <ListItem key={msg} icon={<FaExclamationTriangle />} iconColor={warningColor}>{msg}</ListItem>
));
export const OutputIncorrectSeeHelpMenu = () => (
<ListItem icon={<FaQuestionCircle />}>{i18n.t('If output does not look right, see the Help menu.')}</ListItem>