1
0
mirror of https://github.com/mifi/lossless-cut.git synced 2024-11-25 19:52:44 +01:00
This commit is contained in:
Mikael Finstad 2021-03-30 18:05:41 +07:00
parent 5e1700ef04
commit 546b702e7a
No known key found for this signature in database
GPG Key ID: 25AB36E3E81CBC26
4 changed files with 57 additions and 67 deletions

View File

@ -37,7 +37,6 @@ import ExportConfirm from './ExportConfirm';
import ValueTuner from './components/ValueTuner';
import { loadMifiLink } from './mifi';
import { primaryColor, controlsBackground, waveformColor } from './colors';
import { showMergeDialog, showOpenAndMergeDialog } from './merge/merge';
import allOutFormats from './outFormats';
import { captureFrameFromTag, captureFrameFfmpeg } from './capture-frame';
import {
@ -56,7 +55,7 @@ import {
hasDuplicates, havePermissionToReadFile,
} from './util';
import { formatDuration } from './util/duration';
import { askForOutDir, askForImportChapters, createNumSegments, createFixedDurationSegments, promptTimeOffset, askForHtml5ifySpeed, askForYouTubeInput, askForFileOpenAction, confirmExtractAllStreamsDialog, cleanupFilesDialog, showDiskFull, showCutFailedDialog, labelSegmentDialog, openYouTubeChaptersDialog } from './dialogs';
import { askForOutDir, askForImportChapters, createNumSegments, createFixedDurationSegments, promptTimeOffset, askForHtml5ifySpeed, askForYouTubeInput, askForFileOpenAction, confirmExtractAllStreamsDialog, cleanupFilesDialog, showDiskFull, showCutFailedDialog, labelSegmentDialog, openYouTubeChaptersDialog, showMergeDialog, showOpenAndMergeDialog, openAbout } from './dialogs';
import { openSendReportDialog } from './reporting';
import { fallbackLng } from './i18n';
import { createSegment, createInitialCutSegments, getCleanCutSegments, getSegApparentStart, findSegmentsAtCursor, sortSegments, invertSegments } from './segments';
@ -71,7 +70,7 @@ const trash = window.require('trash');
const { unlink, exists } = window.require('fs-extra');
const { extname, parse: parsePath, sep: pathSep, join: pathJoin, normalize: pathNormalize, resolve: pathResolve, isAbsolute: pathIsAbsolute } = window.require('path');
const { dialog, app } = electron.remote;
const { dialog } = electron.remote;
const { focusWindow } = electron.remote.require('./electron');
@ -1652,7 +1651,6 @@ const App = memo(() => {
useEffect(() => {
function showOpenAndMergeDialog2() {
showOpenAndMergeDialog({
dialog,
defaultPath: outputDir,
onMergeClick: mergeFiles,
});
@ -1724,14 +1722,6 @@ const App = memo(() => {
await loadEdlFile(filePaths[0], type);
}
function openAbout() {
Swal.fire({
icon: 'info',
title: 'About LosslessCut',
text: `You are running version ${app.getVersion()}`,
});
}
async function batchConvertFriendlyFormat() {
const title = i18n.t('Select files to batch convert to supported format');
const { canceled, filePaths } = await dialog.showOpenDialog({ properties: ['openFile', 'multiSelections'], title, message: title });

View File

@ -7,10 +7,13 @@ import withReactContent from 'sweetalert2-react-content';
import { parseDuration } from './util/duration';
import { parseYouTube } from './edlFormats';
import CopyClipboardButton from './components/CopyClipboardButton';
import { errorToast } from './util';
import SortableFiles from './SortableFiles';
const electron = window.require('electron'); // eslint-disable-line
const { dialog } = electron.remote;
const { dialog, app } = electron.remote;
const ReactSwal = withReactContent(Swal);
@ -296,3 +299,54 @@ export async function labelSegmentDialog(currentName) {
});
return value;
}
export function openAbout() {
Swal.fire({
icon: 'info',
title: 'About LosslessCut',
text: `You are running version ${app.getVersion()}`,
});
}
export async function showMergeDialog(paths, onMergeClick) {
if (!paths) return;
if (paths.length < 2) {
errorToast(i18n.t('More than one file must be selected'));
return;
}
let swalElem;
let outPaths = paths;
let allStreams = false;
let segmentsToChapters = false;
const { dismiss } = await ReactSwal.fire({
width: '90%',
showCancelButton: true,
confirmButtonText: i18n.t('Merge!'),
onBeforeOpen: (el) => { swalElem = el; },
html: (<SortableFiles
items={outPaths}
onChange={(val) => { outPaths = val; }}
onAllStreamsChange={(val) => { allStreams = val; }}
onSegmentsToChaptersChange={(val) => { segmentsToChapters = val; }}
helperContainer={() => swalElem}
/>),
});
if (!dismiss) {
await onMergeClick({ paths: outPaths, allStreams, segmentsToChapters });
}
}
export async function showOpenAndMergeDialog({ defaultPath, onMergeClick }) {
const title = i18n.t('Please select files to be merged');
const message = i18n.t('Please select files to be merged. The files need to be of the exact same format and codecs');
const { canceled, filePaths } = await dialog.showOpenDialog({
title,
defaultPath,
properties: ['openFile', 'multiSelections'],
message,
});
if (canceled) return;
showMergeDialog(filePaths, onMergeClick);
}

View File

@ -1,54 +0,0 @@
import React from 'react';
import swal from 'sweetalert2';
import i18n from 'i18next';
import withReactContent from 'sweetalert2-react-content';
import SortableFiles from './SortableFiles';
import { errorToast } from '../util';
const MySwal = withReactContent(swal);
export async function showMergeDialog(paths, onMergeClick) {
if (!paths) return;
if (paths.length < 2) {
errorToast(i18n.t('More than one file must be selected'));
return;
}
let swalElem;
let outPaths = paths;
let allStreams = false;
let segmentsToChapters = false;
const { dismiss } = await MySwal.fire({
width: '90%',
showCancelButton: true,
confirmButtonText: i18n.t('Merge!'),
onBeforeOpen: (el) => { swalElem = el; },
html: (<SortableFiles
items={outPaths}
onChange={(val) => { outPaths = val; }}
onAllStreamsChange={(val) => { allStreams = val; }}
onSegmentsToChaptersChange={(val) => { segmentsToChapters = val; }}
helperContainer={() => swalElem}
/>),
});
if (!dismiss) {
await onMergeClick({ paths: outPaths, allStreams, segmentsToChapters });
}
}
export async function showOpenAndMergeDialog({ dialog, defaultPath, onMergeClick }) {
const title = i18n.t('Please select files to be merged');
const message = i18n.t('Please select files to be merged. The files need to be of the exact same format and codecs');
const { canceled, filePaths } = await dialog.showOpenDialog({
title,
defaultPath,
properties: ['openFile', 'multiSelections'],
message,
});
if (canceled) return;
showMergeDialog(filePaths, onMergeClick);
}