From 7d461d6ae420669ab25da6e12b77ad5569913ff4 Mon Sep 17 00:00:00 2001 From: Yun Chan Date: Tue, 2 Jun 2026 21:35:47 +0900 Subject: [PATCH] =?UTF-8?q?feat(quick):=20=EB=B9=A0=EB=A5=B8=20=EB=B3=80?= =?UTF-8?q?=ED=99=98=20=EA=B0=84=EB=8B=A8=20=EC=98=B5=EC=85=98=20=ED=8C=9D?= =?UTF-8?q?=EC=97=85=20+=20=EC=A4=91=EA=B0=84=20=EC=B7=A8=EC=86=8C=20?= =?UTF-8?q?=EC=A7=80=EC=9B=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 컨텍스트 메뉴에서 형식(MP4/MP3 등) 선택 시 간단 옵션 팝업을 띄우고, 변환 중 취소를 지원한다. - QuickOptionsWindow(신규): 출력 형식에 맞춘 간단 옵션(영상=품질CRF/해상도/GPU, 오디오=비트레이트, 이미지=품질) 팝업. '변환'으로 진행, '취소'로 종료, '자세히 옵션…'으로 풀 UI(MainWindow) 전환. OptionsViewModel 재사용 → ToConvertOptions()로 변환 옵션 구성. - App.RunQuickAsync: 변환 전 팝업 표시 + 선택 옵션 적용. ConvertManyAsync에 취소 토큰 전달(이전엔 None이라 취소 불가였음). 변환 경로는 ShutdownMode=OnExplicitShutdown으로 전환해 **취소/창 닫기 시 ffmpeg를 종료한 '뒤' 앱을 종료**(고아 프로세스·백그라운드 잔류 방지). 성공 시 결과 창 닫을 때까지 대기. - QuickProgressWindow: 변환 중 '취소' 버튼 + 창 Closing 시 취소(CancellationTokenSource 주입). 완료 시 취소 버튼 숨김. 버그 수정: 빠른 변환 진행 창을 닫아도 변환이 백그라운드에서 계속 돌던 문제 해결. 빌드 0/0, 106 테스트 그린, publish 후 팝업/일반 실행 크래시 없이 로드. --- src/Everything2Everything.App/App.xaml.cs | 29 +++++- .../Views/QuickOptionsWindow.xaml | 92 +++++++++++++++++++ .../Views/QuickOptionsWindow.xaml.cs | 64 +++++++++++++ .../Views/QuickProgressWindow.xaml | 28 ++++-- .../Views/QuickProgressWindow.xaml.cs | 25 ++++- 5 files changed, 226 insertions(+), 12 deletions(-) create mode 100644 src/Everything2Everything.App/Views/QuickOptionsWindow.xaml create mode 100644 src/Everything2Everything.App/Views/QuickOptionsWindow.xaml.cs diff --git a/src/Everything2Everything.App/App.xaml.cs b/src/Everything2Everything.App/App.xaml.cs index ff19a02..6446478 100644 --- a/src/Everything2Everything.App/App.xaml.cs +++ b/src/Everything2Everything.App/App.xaml.cs @@ -97,19 +97,34 @@ public partial class App : Application private async Task RunQuickAsync(IReadOnlyList files, string outputExtension) { + // 빠른 변환 전, 출력 형식에 맞춘 간단 옵션 팝업. + // '자세히 옵션…'이면 풀 UI(MainWindow)로 전환, '취소'면 종료, '변환'이면 선택 옵션으로 진행. + var optWin = new QuickOptionsWindow(outputExtension, files.Count, Settings); + var confirmed = optWin.ShowDialog(); + if (optWin.OpenFullUi) { ShowConvertDialog(files); return; } + if (confirmed != true) { Shutdown(0); return; } + + // 변환 경로 동안은 명시적 종료 모드 — 진행 창을 닫아도 변환을 취소(ffmpeg 종료)한 '뒤' 앱을 종료한다. + // (기본 OnLastWindowClose면 창 닫는 즉시 종료가 시작돼 ffmpeg가 고아로 백그라운드에 남는다.) + ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown; + var logPath = Path.Combine(Path.GetTempPath(), "Everything2Everything_quick.log"); var log = new System.Text.StringBuilder(); log.AppendLine($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}] Quick start → {outputExtension}, {files.Count} file(s)"); foreach (var f in files) log.AppendLine($" src: {f}"); - var progress = new QuickProgressWindow(files.Count, outputExtension); + using var cts = new CancellationTokenSource(); + var progress = new QuickProgressWindow(files.Count, cts, outputExtension); + var closed = new TaskCompletionSource(); + progress.Closed += (_, _) => closed.TrySetResult(); progress.Show(); try { - var options = ConvertOptions.Quick() with { VideoPreferGpu = Settings.Get("video.gpu") != "false" }; + var options = optWin.Options.ToConvertOptions(); var reporter = new Progress(p => progress.Report(p)); - var results = await Engine.ConvertManyAsync(files, outputExtension, options, reporter); + var results = await Engine.ConvertManyAsync( + files, outputExtension, options, reporter, BatchMode.Independent, cts.Token); foreach (var r in results) { @@ -120,6 +135,13 @@ public partial class App : Application } progress.Finish(results); + await closed.Task; // 결과 창을 사용자가 닫을 때까지 대기(성공 경로) + } + catch (OperationCanceledException) + { + // 사용자가 취소(취소 버튼/창 닫기) — ffmpeg는 이미 중단된 뒤 여기에 도달. 진행 창 닫고 종료. + log.AppendLine(" CANCELLED by user"); + try { progress.Close(); } catch { } } catch (Exception ex) { @@ -132,6 +154,7 @@ public partial class App : Application finally { try { File.WriteAllText(logPath, log.ToString()); } catch { } + Shutdown(0); // 모든 경로에서 명시적 종료(백그라운드 잔류·고아 프로세스 방지) } } diff --git a/src/Everything2Everything.App/Views/QuickOptionsWindow.xaml b/src/Everything2Everything.App/Views/QuickOptionsWindow.xaml new file mode 100644 index 0000000..8adf646 --- /dev/null +++ b/src/Everything2Everything.App/Views/QuickOptionsWindow.xaml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +