show title in open dialog

#1954
pull/1961/head
Mikael Finstad 2 years ago
parent 36454f5e49
commit 88fbcc0129
No known key found for this signature in database
GPG Key ID: 25AB36E3E81CBC26

@ -107,6 +107,8 @@ hevcPlaybackSupportedPromise.catch((err) => console.error(err));
function App() { function App() {
const { t } = useTranslation();
// Per project state // Per project state
const [commandedTime, setCommandedTime] = useState(0); const [commandedTime, setCommandedTime] = useState(0);
const [ffmpegCommandLog, setFfmpegCommandLog] = useState<FfmpegCommandLog>([]); const [ffmpegCommandLog, setFfmpegCommandLog] = useState<FfmpegCommandLog>([]);
@ -730,7 +732,7 @@ function App() {
// Cleanup removed thumbnails // Cleanup removed thumbnails
useEffect(() => { useEffect(() => {
thumnailsRef.current.forEach((thumbnail) => { thumnailsRef.current.forEach((thumbnail) => {
if (!thumbnails.some((t) => t.url === thumbnail.url)) URL.revokeObjectURL(thumbnail.url); if (!thumbnails.some((nextThumbnail) => nextThumbnail.url === thumbnail.url)) URL.revokeObjectURL(thumbnail.url);
}); });
thumnailsRef.current = thumbnails; thumnailsRef.current = thumbnails;
}, [thumbnails]); }, [thumbnails]);
@ -739,7 +741,7 @@ function App() {
const subtitlesByStreamIdRef = useRef({}); const subtitlesByStreamIdRef = useRef({});
useEffect(() => { useEffect(() => {
Object.values(thumnailsRef.current).forEach(({ url }) => { Object.values(thumnailsRef.current).forEach(({ url }) => {
if (!Object.values(subtitlesByStreamId).some((t) => t.url === url)) URL.revokeObjectURL(url); if (!Object.values(subtitlesByStreamId).some((existingThumbnail) => existingThumbnail.url === url)) URL.revokeObjectURL(url);
}); });
subtitlesByStreamIdRef.current = subtitlesByStreamId; subtitlesByStreamIdRef.current = subtitlesByStreamId;
}, [subtitlesByStreamId]); }, [subtitlesByStreamId]);
@ -1992,10 +1994,10 @@ function App() {
}, [alwaysConcatMultipleFiles, batchLoadPaths, setWorking, isFileOpened, batchFiles.length, userOpenSingleFile, checkFileOpened, loadEdlFile, enableAskForFileOpenAction, addStreamSourceFile, filePath]); }, [alwaysConcatMultipleFiles, batchLoadPaths, setWorking, isFileOpened, batchFiles.length, userOpenSingleFile, checkFileOpened, loadEdlFile, enableAskForFileOpenAction, addStreamSourceFile, filePath]);
const openFilesDialog = useCallback(async () => { const openFilesDialog = useCallback(async () => {
const { canceled, filePaths } = await showOpenDialog({ properties: ['openFile', 'openDirectory', 'multiSelections'], defaultPath: lastOpenedPathRef.current }); const { canceled, filePaths } = await showOpenDialog({ properties: ['openFile', 'openDirectory', 'multiSelections'], defaultPath: lastOpenedPathRef.current!, title: t('Open file') });
if (canceled) return; if (canceled) return;
userOpenFiles(filePaths); userOpenFiles(filePaths);
}, [userOpenFiles]); }, [t, userOpenFiles]);
const concatBatch = useCallback(() => { const concatBatch = useCallback(() => {
if (batchFiles.length < 2) { if (batchFiles.length < 2) {
@ -2455,8 +2457,6 @@ function App() {
const thumbnailsSorted = useMemo(() => sortBy(thumbnails, (thumbnail) => thumbnail.time), [thumbnails]); const thumbnailsSorted = useMemo(() => sortBy(thumbnails, (thumbnail) => thumbnail.time), [thumbnails]);
const { t } = useTranslation();
function renderSubtitles() { function renderSubtitles() {
if (!activeSubtitle) return null; if (!activeSubtitle) return null;
return <track default kind="subtitles" label={activeSubtitle.lang} srcLang="en" src={activeSubtitle.url} />; return <track default kind="subtitles" label={activeSubtitle.lang} srcLang="en" src={activeSubtitle.url} />;

@ -46,7 +46,7 @@ export const showOpenDialog = async ({
filters = isWindows ? [{ name: i18n.t('All Files'), extensions: ['*'] }] : undefined, filters = isWindows ? [{ name: i18n.t('All Files'), extensions: ['*'] }] : undefined,
...props ...props
// @ts-expect-error todo // @ts-expect-error todo
}) => dialog.showOpenDialog({ ...props, filters }); }: Parameters<typeof dialog.showOpenDialog>[0]) => dialog.showOpenDialog({ ...props, filters });
export async function askForYouTubeInput() { export async function askForYouTubeInput() {
const example = i18n.t('YouTube video description\n00:00 Intro\n00:01 Chapter 2\n00:00:02.123 Chapter 3'); const example = i18n.t('YouTube video description\n00:00 Intro\n00:01 Chapter 2\n00:00:02.123 Chapter 3');
@ -73,7 +73,7 @@ export async function askForYouTubeInput() {
export async function askForInputDir(defaultPath?: string | undefined) { export async function askForInputDir(defaultPath?: string | undefined) {
const { filePaths } = await showOpenDialog({ const { filePaths } = await showOpenDialog({
properties: ['openDirectory', 'createDirectory'], properties: ['openDirectory', 'createDirectory'],
defaultPath, defaultPath: defaultPath!,
title: i18n.t('Please confirm folder'), title: i18n.t('Please confirm folder'),
message: i18n.t('Press confirm to grant LosslessCut access to write the project file (due to App Sandbox restrictions).'), message: i18n.t('Press confirm to grant LosslessCut access to write the project file (due to App Sandbox restrictions).'),
buttonLabel: i18n.t('Confirm'), buttonLabel: i18n.t('Confirm'),
@ -84,7 +84,7 @@ export async function askForInputDir(defaultPath?: string | undefined) {
export async function askForOutDir(defaultPath?: string | undefined) { export async function askForOutDir(defaultPath?: string | undefined) {
const { filePaths } = await showOpenDialog({ const { filePaths } = await showOpenDialog({
properties: ['openDirectory', 'createDirectory'], properties: ['openDirectory', 'createDirectory'],
defaultPath, defaultPath: defaultPath!,
title: i18n.t('Where do you want to save output files?'), title: i18n.t('Where do you want to save output files?'),
message: i18n.t('Where do you want to save output files? Make sure there is enough free space in this folder'), message: i18n.t('Where do you want to save output files? Make sure there is enough free space in this folder'),
buttonLabel: i18n.t('Select output folder'), buttonLabel: i18n.t('Select output folder'),
@ -95,7 +95,7 @@ export async function askForOutDir(defaultPath?: string | undefined) {
export async function askForFfPath(defaultPath?: string | undefined) { export async function askForFfPath(defaultPath?: string | undefined) {
const { filePaths } = await showOpenDialog({ const { filePaths } = await showOpenDialog({
properties: ['openDirectory'], properties: ['openDirectory'],
defaultPath, defaultPath: defaultPath!,
title: i18n.t('Select custom FFmpeg directory'), title: i18n.t('Select custom FFmpeg directory'),
}); });
return (filePaths && filePaths.length === 1) ? filePaths[0] : undefined; return (filePaths && filePaths.length === 1) ? filePaths[0] : undefined;

Loading…
Cancel
Save