diff options
author | sr55 <[email protected]> | 2021-01-13 18:22:36 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2021-01-13 18:22:36 +0000 |
commit | fe1893bce2bb9ad8d417ff2acf4ee383e05819df (patch) | |
tree | 41d0d207e6880ee60de601058e14f8a26b2752c1 /win/CS/HandBrakeWPF/ViewModels | |
parent | 2b2a8efa3cf966597afa1f7097dd0c374c3204fe (diff) |
WinGui: Fixes #3347 where the preset menu list was slow to update.
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels')
3 files changed, 24 insertions, 53 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IPresetManagerViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IPresetManagerViewModel.cs index 1ccb3c225..ad4e2195a 100644 --- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IPresetManagerViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IPresetManagerViewModel.cs @@ -9,10 +9,12 @@ namespace HandBrakeWPF.ViewModels.Interfaces { + using System; + public interface IPresetManagerViewModel { bool IsOpen { get; set; } - void SetupWindow(); + void SetupWindow(Action callback); } } diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index f25e4559b..f6e6eb958 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -90,7 +90,6 @@ namespace HandBrakeWPF.ViewModels private string alertWindowText;
private bool hasSource;
private bool isSettingPreset;
- private IPresetObject selectedPresetCategory;
private bool isModifiedPreset;
private bool updateAvailable;
@@ -270,43 +269,6 @@ namespace HandBrakeWPF.ViewModels public IEnumerable<IPresetObject> PresetsCategories { get; set; }
- public IPresetObject SelectedPresetCategory
- {
- get
- {
- return this.selectedPresetCategory;
- }
- set
- {
- if (!object.Equals(this.selectedPresetCategory, value))
- {
- this.selectedPresetCategory = value;
- this.NotifyOfPropertyChange(() => this.SelectedPresetCategory);
- this.NotifyOfPropertyChange(() => this.CategoryPresets);
- }
- }
- }
-
- public IEnumerable<Preset> CategoryPresets
- {
- get
- {
- PresetDisplayCategory category = this.SelectedPresetCategory as PresetDisplayCategory;
- if (category != null && category.Presets != null)
- {
- if (!category.Presets.Contains(this.SelectedPreset))
- {
- this.SelectedPreset = category.Presets.FirstOrDefault();
- }
-
- return new BindingList<Preset>(category.Presets);
- }
-
- this.SelectedPreset = null;
- return new BindingList<Preset>();
- }
- }
-
public Preset SelectedPreset
{
get
@@ -1072,7 +1034,7 @@ namespace HandBrakeWPF.ViewModels if (!this.PresetManagerViewModel.IsOpen)
{
this.PresetManagerViewModel.IsOpen = true;
- this.PresetManagerViewModel.SetupWindow();
+ this.PresetManagerViewModel.SetupWindow(PresetManageCallback);
this.windowManager.ShowWindow(this.PresetManagerViewModel);
}
else if (this.PresetManagerViewModel.IsOpen)
@@ -1082,6 +1044,12 @@ namespace HandBrakeWPF.ViewModels }
}
+
+ private void PresetManageCallback()
+ {
+ this.NotifyOfPropertyChange(() => this.PresetsCategories);
+ }
+
public void LaunchHelp()
{
try
@@ -1638,7 +1606,6 @@ namespace HandBrakeWPF.ViewModels this.windowManager.ShowDialog(presetViewModel);
this.NotifyOfPropertyChange(() => this.PresetsCategories);
- this.NotifyOfPropertyChange(() => this.CategoryPresets);
}
public void PresetUpdate()
@@ -1691,7 +1658,7 @@ namespace HandBrakeWPF.ViewModels this.windowManager.ShowDialog(presetViewModel);
Preset preset = presetViewModel.Preset;
- this.NotifyOfPropertyChange(() => this.CategoryPresets);
+ this.NotifyOfPropertyChange(() => this.PresetsCategories);
this.selectedPreset = preset; // Reselect the preset
this.NotifyOfPropertyChange(() => this.SelectedPreset);
}
@@ -1724,7 +1691,7 @@ namespace HandBrakeWPF.ViewModels }
this.presetService.Remove(this.selectedPreset);
- this.NotifyOfPropertyChange(() => this.CategoryPresets);
+ this.NotifyOfPropertyChange(() => this.PresetsCategories);
this.SelectedPreset = this.presetService.DefaultPreset;
}
else
@@ -1753,7 +1720,7 @@ namespace HandBrakeWPF.ViewModels if (dialogResult.HasValue && dialogResult.Value)
{
this.presetService.Import(dialog.FileName);
- this.NotifyOfPropertyChange(() => this.CategoryPresets);
+ this.NotifyOfPropertyChange(() => this.PresetsCategories);
}
}
@@ -1790,7 +1757,6 @@ namespace HandBrakeWPF.ViewModels this.presetService.UpdateBuiltInPresets();
this.NotifyOfPropertyChange(() => this.PresetsCategories);
- this.NotifyOfPropertyChange(() => this.CategoryPresets);
this.SetDefaultPreset();
@@ -1817,11 +1783,6 @@ namespace HandBrakeWPF.ViewModels return;
}
- if (this.SelectedPresetCategory == null || this.SelectedPresetCategory.Category != preset.Category)
- {
- this.SelectedPresetCategory = this.PresetsCategories.FirstOrDefault(c => c.Category == preset.Category);
- }
-
this.selectedPreset = preset;
this.NotifyOfPropertyChange(() => this.SelectedPreset);
@@ -2078,7 +2039,6 @@ namespace HandBrakeWPF.ViewModels (PresetDisplayCategory)this.PresetsCategories.FirstOrDefault(
p => p.Category == this.presetService.DefaultPreset.Category);
- this.SelectedPresetCategory = category;
this.SelectedPreset = this.presetService.DefaultPreset;
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/PresetManagerViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/PresetManagerViewModel.cs index 54c99db92..065c377d6 100644 --- a/win/CS/HandBrakeWPF/ViewModels/PresetManagerViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/PresetManagerViewModel.cs @@ -29,6 +29,8 @@ namespace HandBrakeWPF.ViewModels using Microsoft.Win32; + using Action = System.Action; + public class PresetManagerViewModel : ViewModelBase, IPresetManagerViewModel { private readonly IPresetService presetService; @@ -39,6 +41,7 @@ namespace HandBrakeWPF.ViewModels private IPresetObject selectedPresetCategory; private Preset selectedPreset; private PictureSettingsResLimitModes selectedPictureSettingsResLimitMode; + private Action mainWindowCallback; public PresetManagerViewModel(IPresetService presetService, IErrorService errorService, IWindowManager windowManager) { @@ -214,8 +217,9 @@ namespace HandBrakeWPF.ViewModels public bool IsCustomMaxRes { get; private set; } - public void SetupWindow() + public void SetupWindow(Action mainwindowCallback) { + this.mainWindowCallback = mainwindowCallback; this.PresetsCategories = this.presetService.Presets; this.NotifyOfPropertyChange(() => this.PresetsCategories); this.presetService.LoadCategoryStates(); @@ -416,7 +420,12 @@ namespace HandBrakeWPF.ViewModels { this.presetService.Save(); this.IsOpen = false; - this.presetService.PresetCollectionChanged -= this.PresetService_PresetCollectionChanged; + this.presetService.PresetCollectionChanged -= this.PresetService_PresetCollectionChanged; + + if (this.mainWindowCallback != null) + { + mainWindowCallback(); + } } public void SetCurrentPresetAsDefault() |