Skip to content

The swiss army knife of lossless video/audio editing

improve merge/concat dialog

Mikael Finstad96086d307f8d
diff --git a/src/App.jsx b/src/App.jsx
index 60dbcacb..9e118241 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -1582,7 +1582,7 @@ const App = memo(() => {
console.log(filePaths.join('\n'));
if (filePaths.length > 1) {
- showMergeDialog(sortBy(filePaths), mergeFiles);
+ showMergeDialog(filePaths, mergeFiles);
return;
}
diff --git a/src/SegmentList.jsx b/src/SegmentList.jsx
index b1b5fec6..535f7fcb 100644
--- a/src/SegmentList.jsx
+++ b/src/SegmentList.jsx
@@ -92,7 +92,7 @@ const Segment = memo(({ seg, index, currentSegIndex, formatTimecode, getFrameCou
onClick={() => !invertCutSegments && onClick(index)}
onDoubleClick={onDoubleClick}
positionTransition
- style={{ originY: 0, margin: '5px 0', border: `1px solid rgba(255,255,255,${isActive ? 1 : 0.3})`, padding: 5, borderRadius: 5, position: 'relative', opacity: !enabled && !invertCutSegments ? 0.5 : undefined }}
+ style={{ cursor: 'grab', originY: 0, margin: '5px 0', border: `1px solid rgba(255,255,255,${isActive ? 1 : 0.3})`, padding: 5, borderRadius: 5, position: 'relative', opacity: !enabled && !invertCutSegments ? 0.5 : undefined }}
initial={{ scaleY: 0 }}
animate={{ scaleY: 1 }}
exit={{ scaleY: 0 }}
diff --git a/src/SortableFiles.jsx b/src/SortableFiles.jsx
index 53b22638..f813d612 100644
--- a/src/SortableFiles.jsx
+++ b/src/SortableFiles.jsx
@@ -1,27 +1,25 @@
import React, { memo, useState, useCallback, useEffect } from 'react';
-import {
- sortableContainer,
- sortableElement,
-} from 'react-sortable-hoc';
+import { sortableContainer, sortableElement } from 'react-sortable-hoc';
import { basename } from 'path';
-import { Checkbox } from 'evergreen-ui';
+import { Pane, Checkbox, SortAlphabeticalIcon, SortAlphabeticalDescIcon, IconButton } from 'evergreen-ui';
import { useTranslation } from 'react-i18next';
import arrayMove from 'array-move';
+import orderBy from 'lodash/orderBy';
const rowStyle = {
- padding: 5, fontSize: 14, margin: '7px 0', boxShadow: '0 0 5px 0px rgba(0,0,0,0.3)', overflowY: 'auto', whiteSpace: 'nowrap',
+ padding: '3px 10px', fontSize: 14, margin: '7px 0', overflowY: 'auto', whiteSpace: 'nowrap', cursor: 'grab',
};
const SortableItem = sortableElement(({ value, sortIndex }) => (
- <div style={rowStyle} title={value}>
+ <Pane elevation={1} style={rowStyle} title={value}>
{sortIndex + 1}
{'. '}
{basename(value)}
- </div>
+ </Pane>
));
const SortableContainer = sortableContainer(({ items }) => (
- <div>
+ <div style={{ padding: '0 3px' }}>
{items.map((value, index) => (
<SortableItem key={value} index={index} sortIndex={index} value={value} />
))}
@@ -34,6 +32,7 @@ const SortableFiles = memo(({
const [items, setItems] = useState(itemsProp);
const [allStreams, setAllStreams] = useState(false);
const [segmentsToChapters, setSegmentsToChapters] = useState(false);
+ const [sortDesc, setSortDesc] = useState();
useEffect(() => onAllStreamsChange(allStreams), [allStreams, onAllStreamsChange]);
useEffect(() => onSegmentsToChaptersChange(segmentsToChapters), [segmentsToChapters, onSegmentsToChaptersChange]);
@@ -46,12 +45,16 @@ const SortableFiles = memo(({
const { t } = useTranslation();
+ function onSortClick() {
+ const newSortDesc = sortDesc == null ? false : !sortDesc;
+ setItems(orderBy(items, undefined, [newSortDesc ? 'desc' : 'asc']));
+ setSortDesc(newSortDesc);
+ }
return (
- <div>
- <div><b>{t('Merge/concatenate files')}</b></div>
+ <div style={{ textAlign: 'left' }}>
+ <div style={{ whiteSpace: 'pre-wrap', fontSize: 14, marginBottom: 10 }}>{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).\n\nDrag and drop to change the order of your files here:')}</div>
- <div style={{ whiteSpace: 'pre-wrap', textAlign: 'left', fontSize: 14 }}>{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).\n\nDrag and drop to change the order of your files here:')}</div>
<SortableContainer
items={items}
onSortEnd={onSortEnd}
@@ -61,13 +64,12 @@ const SortableFiles = memo(({
/>
<div style={{ marginTop: 10 }}>
- <div>
- <Checkbox checked={allStreams} onChange={e => setAllStreams(e.target.checked)} label={t('Include all tracks?')} />
- <div style={{ fontSize: 12, textAlign: 'left' }}>{t('If this is checked, all audio/video/subtitle/data tracks will be included. This may not always work for all file types. If not checked, only default streams will be included.')}</div>
- </div>
+ <Checkbox checked={allStreams} onChange={e => setAllStreams(e.target.checked)} label={`${t('Include all tracks?')} ${t('If this is checked, all audio/video/subtitle/data tracks will be included. This may not always work for all file types. If not checked, only default streams will be included.')}`} />
+
+ <Checkbox checked={segmentsToChapters} onChange={e => setSegmentsToChapters(e.target.checked)} label={t('Create chapters from merged segments? (slow)')} />
<div>
- <Checkbox checked={segmentsToChapters} onChange={e => setSegmentsToChapters(e.target.checked)} label={t('Create chapters from merged segments? (slow)')} />
+ <IconButton icon={sortDesc ? SortAlphabeticalDescIcon : SortAlphabeticalIcon} onClick={onSortClick} />
</div>
</div>
</div>
diff --git a/src/dialogs.jsx b/src/dialogs.jsx
index e03727ac..353ffc5c 100644
--- a/src/dialogs.jsx
+++ b/src/dialogs.jsx
@@ -342,6 +342,7 @@ export async function showMergeDialog(paths, onMergeClick) {
showCancelButton: true,
confirmButtonText: i18n.t('Merge!'),
willOpen: (el) => { swalElem = el; },
+ title: i18n.t('Merge/concatenate files'),
html: (<SortableFiles
items={outPaths}
onChange={(val) => { outPaths = val; }}
@@ -366,6 +367,7 @@ export async function showOpenAndMergeDialog({ defaultPath, onMergeClick }) {
message,
});
if (canceled) return;
+
showMergeDialog(filePaths, onMergeClick);
}