diff options
author | sr55 <[email protected]> | 2021-03-31 14:20:42 +0100 |
---|---|---|
committer | sr55 <[email protected]> | 2021-03-31 14:20:42 +0100 |
commit | c2083f5a0698d429a9c01588f612fd343a22badf (patch) | |
tree | 1c1d94c5e8a57f87937106bf36e17ca7b2f0cb20 | |
parent | 34ae75303b0aa5f716a402d9d936e29900c2c9e3 (diff) |
WinGui: When adding a new preset, select it rather than displaying the current preset as modified.
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs | 9 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/Interfaces/IAddPresetViewModel.cs | 7 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 9 |
3 files changed, 19 insertions, 6 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs index fca980ca7..2c224f138 100644 --- a/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs @@ -12,6 +12,7 @@ namespace HandBrakeWPF.ViewModels using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
+ using System.Runtime.CompilerServices;
using System.Windows;
using Caliburn.Micro;
@@ -62,6 +63,8 @@ namespace HandBrakeWPF.ViewModels public Preset Preset { get; }
+ public string PresetName => this.Preset.Name;
+
public bool ShowCustomInputs
{
get => this.showCustomInputs;
@@ -270,12 +273,12 @@ namespace HandBrakeWPF.ViewModels public void Cancel()
{
- this.Close();
+ this.TryCloseAsync(false);
}
- public void Close()
+ private void Close()
{
- this.TryCloseAsync();
+ this.TryCloseAsync(true);
}
private void SetSelectedPictureSettingsResLimitMode()
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAddPresetViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAddPresetViewModel.cs index 4a5ad7b08..825dd70b8 100644 --- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAddPresetViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAddPresetViewModel.cs @@ -13,7 +13,7 @@ namespace HandBrakeWPF.ViewModels.Interfaces using HandBrakeWPF.Model.Subtitles;
using HandBrakeWPF.Services.Scan.Model;
- using EncodeTask = HandBrakeWPF.Services.Encode.Model.EncodeTask;
+ using EncodeTask = Services.Encode.Model.EncodeTask;
/// <summary>
/// The Add Preset View Model
@@ -21,6 +21,11 @@ namespace HandBrakeWPF.ViewModels.Interfaces public interface IAddPresetViewModel
{
/// <summary>
+ /// Gets the name of the newly created preset.
+ /// </summary>
+ string PresetName { get; }
+
+ /// <summary>
/// Prepare the Preset window to create a Preset Object later.
/// </summary>
/// <param name="task">
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 798c2fa0a..d0b29f10a 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -18,6 +18,7 @@ namespace HandBrakeWPF.ViewModels using System.Linq;
using System.Text.Json;
using System.Threading;
+ using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
@@ -1524,9 +1525,13 @@ namespace HandBrakeWPF.ViewModels {
IAddPresetViewModel presetViewModel = IoC.Get<IAddPresetViewModel>();
presetViewModel.Setup(this.CurrentTask, this.SelectedTitle, this.AudioViewModel.AudioBehaviours, this.SubtitleViewModel.SubtitleBehaviours);
- this.windowManager.ShowDialogAsync(presetViewModel);
+ Task<bool?> result = this.windowManager.ShowDialogAsync(presetViewModel);
- this.NotifyOfPropertyChange(() => this.PresetsCategories);
+ if (result.Result.HasValue && result.Result.Value)
+ {
+ this.NotifyOfPropertyChange(() => this.PresetsCategories);
+ this.SelectedPreset = this.presetService.GetPreset(presetViewModel.PresetName);
+ }
}
public void PresetUpdate()
|