From 625b696a48002ce66977c03744561fa3cd2ae69b Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Fri, 24 May 2024 17:52:14 +0200 Subject: [PATCH] add title to dialogs #1954 --- src/renderer/src/App.tsx | 10 +++++----- src/renderer/src/dialogs/index.tsx | 6 ++++-- src/renderer/src/edlStore.ts | 4 ++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx index 6ad384fc..4d69b34e 100644 --- a/src/renderer/src/App.tsx +++ b/src/renderer/src/App.tsx @@ -86,7 +86,7 @@ import { rightBarWidth, leftBarWidth, ffmpegExtractWindow, zoomMax } from './uti import BigWaveform from './components/BigWaveform'; import isDev from './isDev'; -import { Chapter, ChromiumHTMLVideoElement, CustomTagsByFile, EdlFileType, FfmpegCommandLog, FilesMeta, FormatTimecode, ParamsByStreamId, ParseTimecode, PlaybackMode, SegmentColorIndex, SegmentTags, SegmentToExport, StateSegment, Thumbnail, TunerType } from './types'; +import { Chapter, ChromiumHTMLVideoElement, CustomTagsByFile, EdlExportType, EdlFileType, EdlImportType, FfmpegCommandLog, FilesMeta, FormatTimecode, ParamsByStreamId, ParseTimecode, PlaybackMode, SegmentColorIndex, SegmentTags, SegmentToExport, StateSegment, Thumbnail, TunerType } from './types'; import { CaptureFormat, KeyboardAction, Html5ifyMode, WaveformMode } from '../../../types'; import { FFprobeChapter, FFprobeFormat, FFprobeStream } from '../../../ffprobe'; @@ -2055,14 +2055,14 @@ function App() { const showIncludeExternalStreamsDialog = useCallback(async () => { try { - const { canceled, filePaths } = await showOpenDialog({ properties: ['openFile'] }); + const { canceled, filePaths } = await showOpenDialog({ properties: ['openFile'], title: t('Include more tracks from other file') }); const [firstFilePath] = filePaths; if (canceled || firstFilePath == null) return; await addStreamSourceFile(firstFilePath); } catch (err) { handleError(err); } - }, [addStreamSourceFile]); + }, [addStreamSourceFile, t]); const toggleFullscreenVideo = useCallback(async () => { if (!screenfull.isEnabled) { @@ -2372,7 +2372,7 @@ function App() { const onVideoClick = useCallback(() => togglePlay(), [togglePlay]); useEffect(() => { - async function tryExportEdlFile(type) { + async function tryExportEdlFile(type: EdlExportType) { if (!checkFileOpened()) return; try { await exportEdlFile({ type, cutSegments: selectedSegments, customOutDir, filePath, getFrameCount }); @@ -2382,7 +2382,7 @@ function App() { } } - async function importEdlFile(type) { + async function importEdlFile(type: EdlImportType) { if (!checkFileOpened()) return; try { diff --git a/src/renderer/src/dialogs/index.tsx b/src/renderer/src/dialogs/index.tsx index 165b8bbf..73c9db11 100644 --- a/src/renderer/src/dialogs/index.tsx +++ b/src/renderer/src/dialogs/index.tsx @@ -46,9 +46,11 @@ export async function promptTimeOffset({ initialValue, title, text, inputPlaceho // https://github.com/mifi/lossless-cut/issues/1495 export const showOpenDialog = async ({ filters = isWindows ? [{ name: i18n.t('All Files'), extensions: ['*'] }] : undefined, + title, ...props - // @ts-expect-error todo -}: Parameters[0]) => dialog.showOpenDialog({ ...props, filters }); +}: Omit[0], 'title'> & { title: string }) => ( + dialog.showOpenDialog({ ...props, title, ...(filters != null ? { filters } : {}) }) +); export async function askForYouTubeInput() { const example = i18n.t('YouTube video description\n00:00 Intro\n00:01 Chapter 2\n00:00:02.123 Chapter 3'); diff --git a/src/renderer/src/edlStore.ts b/src/renderer/src/edlStore.ts index 25a162b1..a57f017e 100644 --- a/src/renderer/src/edlStore.ts +++ b/src/renderer/src/edlStore.ts @@ -131,7 +131,7 @@ export async function askForEdlImport({ type, fps }: { type: EdlImportType, fps? else if (type === 'srt') filters = [{ name: i18n.t('Subtitles (SRT)'), extensions: ['srt'] }]; else if (type === 'llc') filters = [{ name: i18n.t('LosslessCut project'), extensions: ['llc'] }]; - const { canceled, filePaths } = await showOpenDialog({ properties: ['openFile'], filters }); + const { canceled, filePaths } = await showOpenDialog({ properties: ['openFile'], filters, title: i18n.t('Import project') }); const [firstFilePath] = filePaths; if (canceled || firstFilePath == null) return []; return readEdlFile({ type, path: firstFilePath, fps }); @@ -167,7 +167,7 @@ export async function exportEdlFile({ type, cutSegments, customOutDir, filePath, const defaultPath = getOutPath({ filePath, customOutDir, fileName: `${basename(filePath)}.${ext}` }); - const { canceled, filePath: savePath } = await dialog.showSaveDialog({ defaultPath, ...(filters != null ? { filters } : {}) }); + const { canceled, filePath: savePath } = await dialog.showSaveDialog({ defaultPath, title: i18n.t('Export project'), ...(filters != null ? { filters } : {}) }); if (canceled || !savePath) return; console.log('Saving', type, savePath); // eslint-disable-next-line unicorn/prefer-switch