From c98aff0338b9b4b2742057154e93de3cac31372d Mon Sep 17 00:00:00 2001 From: sr55 Date: Wed, 9 May 2018 18:02:58 +0100 Subject: [PATCH] WinGui: Make the error checking more aggressive when adding to queue. Add support for bailing out if batch adding and errors occur. --- .../Properties/Resources.Designer.cs | 21 +++++++++++++++- win/CS/HandBrakeWPF/Properties/Resources.resx | 9 ++++++- .../HandBrakeWPF/ViewModels/MainViewModel.cs | 25 ++++++++++++++++--- 3 files changed, 50 insertions(+), 5 deletions(-) diff --git a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs index adc43621c..a22cf482b 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs @@ -669,7 +669,7 @@ namespace HandBrakeWPF.Properties { /// /// Looks up a localized string similar to Warning: If you wish to have subtitles added to each item you are about to queue, please verify that you have the subtitle defaults setup correctly on the subtitles tab. /// - /// Do you wish to continue?. + ///Do you wish to continue?. /// public static string Main_AutoAdd_AudioAndSubWarning { get { @@ -686,6 +686,15 @@ namespace HandBrakeWPF.Properties { } } + /// + /// Looks up a localized string similar to Unable to add the last job to the queue. Do you wish to proceed trying to add the rest?. + /// + public static string Main_ContinueAddingToQueue { + get { + return ResourceManager.GetString("Main_ContinueAddingToQueue", resourceCulture); + } + } + /// /// Looks up a localized string similar to The current file already exists, do you wish to overwrite it?. /// @@ -905,6 +914,16 @@ namespace HandBrakeWPF.Properties { } } + /// + /// Looks up a localized string similar to The file '{0}' already exists! + ///Would you like to overwrite it?. + /// + public static string Main_QueueOverwritePrompt { + get { + return ResourceManager.GetString("Main_QueueOverwritePrompt", resourceCulture); + } + } + /// /// Looks up a localized string similar to Queue Paused. /// diff --git a/win/CS/HandBrakeWPF/Properties/Resources.resx b/win/CS/HandBrakeWPF/Properties/Resources.resx index 830154c53..84d46f2b9 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.resx +++ b/win/CS/HandBrakeWPF/Properties/Resources.resx @@ -327,7 +327,7 @@ In order to use the QuickSync encoder, you must: Warning: If you wish to have subtitles added to each item you are about to queue, please verify that you have the subtitle defaults setup correctly on the subtitles tab. - Do you wish to continue? +Do you wish to continue? You must turn on automatic file naming AND set a default path in preferences before you can add to the queue. @@ -878,4 +878,11 @@ Time Remaining: {5}, Elapsed: {6:d\:hh\:mm\:ss} HandBrake requires Windows 7 or later to run. Version 0.9.9 (XP) and 0.10.5 (Vista) was the last version to support these versions. + + Unable to add the last job to the queue. Do you wish to proceed trying to add the rest? + + + The file '{0}' already exists! +Would you like to overwrite it? + \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 8b1eb22e6..082e662fc 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -791,6 +791,7 @@ namespace HandBrakeWPF.ViewModels this.Destination = AutoNameHelper.AutoName(this.CurrentTask, this.SourceName, this.selectedPreset); } } + this.NotifyOfPropertyChange(() => this.CurrentTask); this.Duration = this.DurationCalculation(); @@ -1490,6 +1491,15 @@ namespace HandBrakeWPF.ViewModels return false; } + if (File.Exists(this.CurrentTask.Destination)) + { + MessageBoxResult result = this.errorService.ShowMessageBox(string.Format(Resources.Main_QueueOverwritePrompt, Path.GetFileName(this.CurrentTask.Destination)), Resources.Question, MessageBoxButton.YesNo, MessageBoxImage.Question); + if (result == MessageBoxResult.No) + { + return false; + } + } + if (!DirectoryUtilities.IsWritable(Path.GetDirectoryName(this.CurrentTask.Destination), true, this.errorService)) { this.errorService.ShowMessageBox(Resources.Main_NoPermissionsOrMissingDirectory, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); @@ -1556,9 +1566,10 @@ namespace HandBrakeWPF.ViewModels if (this.CurrentTask != null && this.CurrentTask.SubtitleTracks != null && this.CurrentTask.SubtitleTracks.Count > 0) { - if (this.SubtitleViewModel.SubtitleBehaviours == null || this.SubtitleViewModel.SubtitleBehaviours.SelectedBehaviour == SubtitleBehaviourModes.None) + if ((this.SubtitleViewModel.SubtitleBehaviours == null || this.SubtitleViewModel.SubtitleBehaviours.SelectedBehaviour == SubtitleBehaviourModes.None) + && !(this.CurrentTask.SubtitleTracks.Count == 1 && this.CurrentTask.SubtitleTracks.First().SubtitleType == SubtitleType.ForeignAudioSearch)) { - System.Windows.MessageBoxResult result = this.errorService.ShowMessageBox( + MessageBoxResult result = this.errorService.ShowMessageBox( Resources.Main_AutoAdd_AudioAndSubWarning, Resources.Warning, MessageBoxButton.YesNo, @@ -1574,7 +1585,15 @@ namespace HandBrakeWPF.ViewModels foreach (Title title in this.ScannedSource.Titles) { this.SelectedTitle = title; - this.AddToQueue(); + if (!this.AddToQueue()) + { + MessageBoxResult result = this.errorService.ShowMessageBox(Resources.Main_ContinueAddingToQueue, Resources.Question, MessageBoxButton.YesNo, MessageBoxImage.Question); + + if (result == MessageBoxResult.No) + { + break; + } + } } } -- 2.40.0