From 3e3218dfb1e09f7f2aa851d03c0dfedbf1b53a68 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sun, 8 Jan 2017 10:43:47 +0000 Subject: [PATCH] WinGui: Correctly synchronise the WhenDone dropdowns in the Queue, MainWindow and Preferences --- .../Interfaces/IOptionsViewModel.cs | 5 +++ .../ViewModels/Interfaces/IQueueViewModel.cs | 5 ++- .../HandBrakeWPF/ViewModels/MainViewModel.cs | 13 ++++++-- .../ViewModels/OptionsViewModel.cs | 10 +++++- .../HandBrakeWPF/ViewModels/QueueViewModel.cs | 23 ++++++++++++- win/CS/HandBrakeWPF/Views/MainView.xaml | 32 ++++++------------- win/CS/HandBrakeWPF/Views/QueueView.xaml | 28 ++++------------ 7 files changed, 66 insertions(+), 50 deletions(-) diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IOptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IOptionsViewModel.cs index c2d48f8e5..e37f1da07 100644 --- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IOptionsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IOptionsViewModel.cs @@ -23,5 +23,10 @@ namespace HandBrakeWPF.ViewModels.Interfaces /// The tab. /// void GotoTab(OptionsTab tab); + + /// + /// Refresh certain UI controls that can be updated outside preferences. + /// + void UpdateSettings(); } } \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IQueueViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IQueueViewModel.cs index 51c8e462e..4f455d373 100644 --- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IQueueViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IQueueViewModel.cs @@ -20,7 +20,10 @@ namespace HandBrakeWPF.ViewModels.Interfaces /// /// The action. /// - void WhenDone(string action); + /// + /// Save the change to the setting. Use false when updating UI. + /// + void WhenDone(string action, bool saveChange); /// /// The import. diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 15b959867..39db1a560 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -1713,7 +1713,7 @@ namespace HandBrakeWPF.ViewModels /// action public void WhenDone(string action) { - this.QueueViewModel?.WhenDone(action); + this.QueueViewModel?.WhenDone(action, true); } #endregion @@ -2517,10 +2517,17 @@ namespace HandBrakeWPF.ViewModels /// private void UserSettingServiceSettingChanged(object sender, SettingChangedEventArgs e) { - if (e.Key == UserSettingConstants.ShowAdvancedTab) + switch (e.Key) { - this.NotifyOfPropertyChange(() => this.ShowAdvancedTab); + case UserSettingConstants.ShowAdvancedTab: + this.NotifyOfPropertyChange(() => this.ShowAdvancedTab); + break; + + case UserSettingConstants.WhenCompleteAction: + this.QueueViewModel.WhenDone(this.userSettingService.GetUserSetting(UserSettingConstants.WhenCompleteAction), false); + break; } + } /// diff --git a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs index cdf480be6..873e2b513 100644 --- a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs @@ -15,7 +15,6 @@ namespace HandBrakeWPF.ViewModels using System.Globalization; using System.IO; using System.Linq; - using System.Text; using System.Windows; using Caliburn.Micro; @@ -1317,6 +1316,15 @@ namespace HandBrakeWPF.ViewModels // Use dvdnav this.DisableLibdvdNav = userSettingService.GetUserSetting(UserSettingConstants.DisableLibDvdNav); + + } + + /// + /// Some settings can be changed outside of this window. This will refresh their UI controls. + /// + public void UpdateSettings() + { + this.WhenDone = userSettingService.GetUserSetting("WhenCompleteAction"); } /// diff --git a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs index f56e6f4fc..97811dec9 100644 --- a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs @@ -177,9 +177,30 @@ namespace HandBrakeWPF.ViewModels /// The action. /// public void WhenDone(string action) + { + this.WhenDone(action, true); + } + + /// + /// Update the When Done Setting + /// + /// + /// The action. + /// + /// + /// Save the change to the setting. Use false when updating UI. + /// + public void WhenDone(string action, bool saveChange) { this.WhenDoneAction = action; - this.userSettingService.SetUserSetting(UserSettingConstants.WhenCompleteAction, action); + + if (saveChange) + { + this.userSettingService.SetUserSetting(UserSettingConstants.WhenCompleteAction, action); + } + + IOptionsViewModel ovm = IoC.Get(); + ovm.UpdateSettings(); } /// diff --git a/win/CS/HandBrakeWPF/Views/MainView.xaml b/win/CS/HandBrakeWPF/Views/MainView.xaml index e257a4ea8..e0e1156fd 100644 --- a/win/CS/HandBrakeWPF/Views/MainView.xaml +++ b/win/CS/HandBrakeWPF/Views/MainView.xaml @@ -737,39 +737,25 @@ - + Header="{x:Static Properties:ResourcesUI.QueueView_DoNothing}" /> + + Header="{x:Static Properties:ResourcesUI.QueueView_Suspend}"/> + Header="{x:Static Properties:ResourcesUI.QueueView_Hibernate}" /> + Header="{x:Static Properties:ResourcesUI.QueueView_LockSystem}" /> + Header="{x:Static Properties:ResourcesUI.QueueView_Logoff}"/> + Header="{x:Static Properties:ResourcesUI.QueueView_QuitHandBrake}" /> diff --git a/win/CS/HandBrakeWPF/Views/QueueView.xaml b/win/CS/HandBrakeWPF/Views/QueueView.xaml index 414c29e30..127a25133 100644 --- a/win/CS/HandBrakeWPF/Views/QueueView.xaml +++ b/win/CS/HandBrakeWPF/Views/QueueView.xaml @@ -115,39 +115,25 @@ + Header="{x:Static Properties:ResourcesUI.QueueView_DoNothing}" /> + Header="{x:Static Properties:ResourcesUI.QueueView_Shutdown}" /> + Header="{x:Static Properties:ResourcesUI.QueueView_Suspend}" /> + Header="{x:Static Properties:ResourcesUI.QueueView_Hibernate}"/> + Header="{x:Static Properties:ResourcesUI.QueueView_LockSystem}" /> + Header="{x:Static Properties:ResourcesUI.QueueView_Logoff}"/> + Header="{x:Static Properties:ResourcesUI.QueueView_QuitHandBrake}"/> -- 2.40.0