From 0459b39db5addd4acb700e85f7e7e39b249ae576 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sun, 30 Dec 2018 21:25:51 +0000 Subject: [PATCH] WinGui: Fix issues with "Any" language selection with the "First" option used. For both Audio and Subtitle tabs, this should now only provide 1 track. Fixes #1735 and makes the behaviour consistent with the Mac/Linux GUI's --- .../HandBrakeWPF/ViewModels/AudioViewModel.cs | 105 ++++++++++-------- .../ViewModels/SubtitlesViewModel.cs | 39 +++---- 2 files changed, 74 insertions(+), 70 deletions(-) diff --git a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs index d5b7840ff..90a3d249f 100644 --- a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs @@ -393,24 +393,6 @@ namespace HandBrakeWPF.ViewModels this.NotifyOfPropertyChange(() => this.Task); } - /// - /// Add all remaining for selected languages. - /// - public void AddAllRemainingForSelectedLanguages() - { - // Add them if they are not already added. - foreach (Audio sourceTrack in this.GetSelectedLanguagesTracks()) - { - // Step 2: Check if the track list already contrains this track - bool found = this.Task.AudioTracks.Any(audioTrack => Equals(audioTrack.ScannedTrack, sourceTrack)); - if (!found) - { - // If it doesn't, add it. - this.Add(sourceTrack, true); - } - } - } - #endregion #region Methods @@ -479,24 +461,6 @@ namespace HandBrakeWPF.ViewModels return true; } - /// - /// Add all source tracks that don't currently exist on the list. - /// - private void AddAllRemainingTracks() - { - // For all the source audio tracks - foreach (Audio sourceTrack in this.SourceTracks) - { - // Step 2: Check if the track list already contrains this track - bool found = this.Task.AudioTracks.Any(audioTrack => Equals(audioTrack.ScannedTrack, sourceTrack)); - if (!found) - { - // If it doesn't, add it. - this.Add(sourceTrack, true); - } - } - } - /// /// Attempt to automatically select the correct audio tracks based on the users settings. /// @@ -549,6 +513,13 @@ namespace HandBrakeWPF.ViewModels /// private void AddFirstForSelectedLanguages() { + bool anyLanguageSelected = this.AudioBehaviours.SelectedLangauges.Contains(Constants.Any); + + if (anyLanguageSelected && this.Task.AudioTracks.Count >= 1) + { + return; + } + foreach (Audio sourceTrack in this.GetSelectedLanguagesTracks()) { // Step 2: Check if the track list already contrains this track @@ -569,6 +540,48 @@ namespace HandBrakeWPF.ViewModels // If it doesn't, add it. this.Add(sourceTrack, true); + + // If we are using "(Any)" then break here. We only add the first track in this instance. + if (anyLanguageSelected) + { + break; + } + } + } + } + + /// + /// Add all source tracks that don't currently exist on the list. + /// + private void AddAllRemainingTracks() + { + // For all the source audio tracks + foreach (Audio sourceTrack in this.SourceTracks) + { + // Step 2: Check if the track list already contrains this track + bool found = this.Task.AudioTracks.Any(audioTrack => Equals(audioTrack.ScannedTrack, sourceTrack)); + if (!found) + { + // If it doesn't, add it. + this.Add(sourceTrack, true); + } + } + } + + /// + /// Add all remaining for selected languages. + /// + public void AddAllRemainingForSelectedLanguages() + { + // Add them if they are not already added. + foreach (Audio sourceTrack in this.GetSelectedLanguagesTracks()) + { + // Step 2: Check if the track list already contrains this track + bool found = this.Task.AudioTracks.Any(audioTrack => Equals(audioTrack.ScannedTrack, sourceTrack)); + if (!found) + { + // If it doesn't, add it. + this.Add(sourceTrack, true); } } } @@ -605,21 +618,15 @@ namespace HandBrakeWPF.ViewModels /// private IEnumerable