Skip to content

Commit

Permalink
WinGui: Fix a bug in the Add presets window where the Audio / Subtitl…
Browse files Browse the repository at this point in the history
…e defaults would not set. Fixes HandBrake#2457
  • Loading branch information
sr55 committed Nov 25, 2019
1 parent 8de6f15 commit a5d359d
Showing 7 changed files with 38 additions and 2 deletions.
8 changes: 6 additions & 2 deletions win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs
Original file line number Diff line number Diff line change
@@ -307,7 +307,9 @@ public void Add()
/// </summary>
public void EditAudioDefaults()
{
if (this.windowManager.ShowDialog(this.audioDefaultsViewModel) == true)
this.audioDefaultsViewModel.ResetApplied();
bool? result = this.windowManager.ShowDialog(this.audioDefaultsViewModel);
if (audioDefaultsViewModel.IsApplied)
{
this.Preset.AudioTrackBehaviours = this.audioDefaultsViewModel.AudioBehaviours.Clone();
}
@@ -318,10 +320,12 @@ public void EditAudioDefaults()
/// </summary>
public void EditSubtitleDefaults()
{
this.subtitlesDefaultsViewModel.ResetApplied();
SubtitlesDefaultsView view = new SubtitlesDefaultsView();
view.DataContext = this.subtitlesDefaultsViewModel;
view.ShowDialog();

if (view.ShowDialog() == true)
if (subtitlesDefaultsViewModel.IsApplied)
{
this.Preset.SubtitleTrackBehaviours = this.subtitlesDefaultsViewModel.SubtitleBehaviours.Clone();
}
8 changes: 8 additions & 0 deletions win/CS/HandBrakeWPF/ViewModels/AudioDefaultsViewModel.cs
Original file line number Diff line number Diff line change
@@ -130,6 +130,8 @@ private set
}
}

public bool IsApplied { get; set; }

/// <summary>
/// Gets SelectedLangauges.
/// </summary>
@@ -430,6 +432,11 @@ public void LanguageClearAll()
this.AudioBehaviours.SelectedLangauges.Clear();
}

public void ResetApplied()
{
this.IsApplied = false;
}

#endregion

#region Methods
@@ -446,6 +453,7 @@ public void LanguageClearAll()
public void Setup(Preset preset, EncodeTask task)
{
// Reset
this.IsApplied = false;
this.AudioBehaviours = new AudioBehaviours();

// Setup for this Encode Task.
Original file line number Diff line number Diff line change
@@ -23,6 +23,8 @@ public interface IAudioDefaultsViewModel : IViewModelBase
/// </summary>
AudioBehaviours AudioBehaviours { get; }

bool IsApplied { get; }

/// <summary>
/// The setup languages.
/// </summary>
@@ -38,5 +40,7 @@ public interface IAudioDefaultsViewModel : IViewModelBase
/// The refresh task.
/// </summary>
void RefreshTask();

void ResetApplied();
}
}
Original file line number Diff line number Diff line change
@@ -22,6 +22,8 @@ public interface ISubtitlesDefaultsViewModel : IViewModelBase
/// </summary>
SubtitleBehaviours SubtitleBehaviours { get; }

bool IsApplied { get; }

/// <summary>
/// The setup languages.
/// </summary>
@@ -37,5 +39,7 @@ public interface ISubtitlesDefaultsViewModel : IViewModelBase
/// The behaviours.
/// </param>
void SetupLanguages(SubtitleBehaviours behaviours);

void ResetApplied();
}
}
10 changes: 10 additions & 0 deletions win/CS/HandBrakeWPF/ViewModels/SubtitlesDefaultsViewModel.cs
Original file line number Diff line number Diff line change
@@ -56,6 +56,8 @@ public SubtitlesDefaultsViewModel()

#region Properties

public bool IsApplied { get; set; }

/// <summary>
/// Gets CharacterCodes.
/// </summary>
@@ -213,6 +215,11 @@ public void SetupLanguages(Preset preset)
}
}

public void ResetApplied()
{
this.IsApplied = false;
}

/// <summary>
/// The setup languages.
/// </summary>
@@ -221,6 +228,9 @@ public void SetupLanguages(Preset preset)
/// </param>
public void SetupLanguages(SubtitleBehaviours behaviours)
{
// Reset
this.IsApplied = false;

// Step 1, Set the behaviour mode
this.SubtitleBehaviours.SelectedBehaviour = SubtitleBehaviourModes.None;
this.SubtitleBehaviours.SelectedBurnInBehaviour = SubtitleBurnInBehaviourModes.None;
3 changes: 3 additions & 0 deletions win/CS/HandBrakeWPF/Views/AudioDefaultsView.xaml.cs
Original file line number Diff line number Diff line change
@@ -12,6 +12,8 @@ namespace HandBrakeWPF.Views
using System.Windows;
using System.Windows.Controls;

using HandBrakeWPF.ViewModels;

/// <summary>
/// Interaction logic for AudioDefaultsView.xaml
/// </summary>
@@ -27,6 +29,7 @@ public AudioDefaultsView()

private void Apply_OnClick(object sender, RoutedEventArgs e)
{
((AudioDefaultsViewModel)DataContext).IsApplied = true;
this.Close();
}
}
3 changes: 3 additions & 0 deletions win/CS/HandBrakeWPF/Views/SubtitlesDefaultsView.xaml.cs
Original file line number Diff line number Diff line change
@@ -12,6 +12,8 @@ namespace HandBrakeWPF.Views
using System.Windows;
using System.Windows.Controls;

using HandBrakeWPF.ViewModels;

/// <summary>
/// Interaction logic for SubtitlesDefaultsView.xaml
/// </summary>
@@ -27,6 +29,7 @@ public SubtitlesDefaultsView()

private void Apply_OnClick(object sender, RoutedEventArgs e)
{
((SubtitlesDefaultsViewModel)DataContext).IsApplied = true;
this.Close();
}
}

0 comments on commit a5d359d

Please sign in to comment.