From d076119d72215edfd3388ebe0d4ee2256f17d586 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sat, 13 Jan 2018 20:30:44 +0000 Subject: WinGui: Reselect the last selected preset (if still available) when editing a queue task. Fix a bug on the summary task not rendering correctly when queue editing. --- .../ViewModels/Interfaces/IMainViewModel.cs | 4 +++- win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 28 +++++++++++++++------- win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs | 2 +- .../ViewModels/StaticPreviewViewModel.cs | 2 +- win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs | 12 +++------- 5 files changed, 28 insertions(+), 20 deletions(-) (limited to 'win/CS/HandBrakeWPF/ViewModels') diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs index bcc72b9dd..19b1c0001 100644 --- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs @@ -11,6 +11,8 @@ namespace HandBrakeWPF.ViewModels.Interfaces { using System.Windows; + using HandBrakeWPF.Services.Queue.Model; + using EncodeTask = HandBrakeWPF.Services.Encode.Model.EncodeTask; /// @@ -96,7 +98,7 @@ namespace HandBrakeWPF.ViewModels.Interfaces /// /// The task. /// - void EditQueueJob(EncodeTask task); + void EditQueueJob(QueueTask task); /// /// Shutdown this View diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index fd65c9c67..9fce1956c 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -87,7 +87,7 @@ namespace HandBrakeWPF.ViewModels private bool isEncoding; private bool showStatusWindow; private Preset selectedPreset; - private EncodeTask queueEditTask; + private QueueTask queueEditTask; private int lastEncodePercentage; private bool isPresetPanelShowing; private bool showSourceSelection; @@ -1504,7 +1504,7 @@ namespace HandBrakeWPF.ViewModels return false; } - QueueTask task = new QueueTask(new EncodeTask(this.CurrentTask), HBConfigurationFactory.Create(), this.ScannedSource.ScanPath); + QueueTask task = new QueueTask(new EncodeTask(this.CurrentTask), HBConfigurationFactory.Create(), this.ScannedSource.ScanPath, this.SelectedPreset); if (!this.queueProcessor.CheckForDestinationPathDuplicates(task.Task.Destination)) { @@ -1711,13 +1711,15 @@ namespace HandBrakeWPF.ViewModels /// /// Edit a Queue Task /// - /// + /// /// The task. /// - public void EditQueueJob(EncodeTask task) + public void EditQueueJob(QueueTask queueTask) { // Rescan the source to make sure it's still valid - this.queueEditTask = task; + EncodeTask task = queueTask.Task; + + this.queueEditTask = queueTask; this.scanService.Scan(task.Source, task.Title, QueueEditAction, HBConfigurationFactory.Create()); } @@ -2200,6 +2202,16 @@ namespace HandBrakeWPF.ViewModels /* TODO Fix this. */ Execute.OnUIThread(() => { + if (this.queueEditTask != null && this.selectedPreset.Name != this.queueEditTask.SelectedPresetKey) + { + Preset foundPreset = this.presetService.GetPreset(this.queueEditTask.SelectedPresetKey); + if (foundPreset != null) + { + this.selectedPreset = foundPreset; + this.NotifyOfPropertyChange(() => this.SelectedPreset); + } + } + // Copy all the Scan data into the UI scannedSource.CopyTo(this.ScannedSource); this.NotifyOfPropertyChange(() => this.ScannedSource); @@ -2207,7 +2219,7 @@ namespace HandBrakeWPF.ViewModels // Select the Users Title this.SelectedTitle = this.ScannedSource.Titles.FirstOrDefault(); - this.CurrentTask = new EncodeTask(queueEditTask); + this.CurrentTask = new EncodeTask(this.queueEditTask.Task); this.NotifyOfPropertyChange(() => this.CurrentTask); this.HasSource = true; @@ -2221,6 +2233,7 @@ namespace HandBrakeWPF.ViewModels this.SelectedEndPoint = end; // Update the Tab Controls + this.SummaryViewModel.UpdateTask(this.CurrentTask); this.PictureSettingsViewModel.UpdateTask(this.CurrentTask); this.VideoViewModel.UpdateTask(this.CurrentTask); this.FiltersViewModel.UpdateTask(this.CurrentTask); @@ -2229,8 +2242,7 @@ namespace HandBrakeWPF.ViewModels this.ChaptersViewModel.UpdateTask(this.CurrentTask); this.AdvancedViewModel.UpdateTask(this.CurrentTask); this.MetaDataViewModel.UpdateTask(this.CurrentTask); - this.SummaryViewModel.UpdateTask(this.CurrentTask); - + // Cleanup this.ShowStatusWindow = false; this.SourceLabel = this.SourceName; diff --git a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs index f2b2d7b9b..52a09def3 100644 --- a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs @@ -450,7 +450,7 @@ namespace HandBrakeWPF.ViewModels // Pass a copy of the job back to the Main Screen IMainViewModel mvm = IoC.Get(); - mvm.EditQueueJob(new EncodeTask(task.Task)); + mvm.EditQueueJob(task); } public void OpenSourceDirectory(QueueTask task) diff --git a/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs index d801dd256..8a61aa610 100644 --- a/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs @@ -605,7 +605,7 @@ namespace HandBrakeWPF.ViewModels encodeTask.SubtitleTracks.Remove(scanTrack); } - QueueTask task = new QueueTask(encodeTask, HBConfigurationFactory.Create(), this.ScannedSource.ScanPath); + QueueTask task = new QueueTask(encodeTask, HBConfigurationFactory.Create(), this.ScannedSource.ScanPath, null); ThreadPool.QueueUserWorkItem(this.CreatePreview, task); } diff --git a/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs index 90676cc0e..ac12baf2c 100644 --- a/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs @@ -212,12 +212,7 @@ namespace HandBrakeWPF.ViewModels { get { - return this.isMkv; - } - set - { - this.isMkv = value; - this.NotifyOfPropertyChange(() => this.IsMkv); + return this.SelectedOutputFormat == OutputFormat.Mkv; } } @@ -441,19 +436,18 @@ namespace HandBrakeWPF.ViewModels newExtension = ".m4v"; break; } - - this.IsMkv = false; } // Now disable controls that are not required. The Following are for MP4 only! if (newExtension == ".mkv") { - this.IsMkv = true; this.OptimizeMP4 = false; this.IPod5GSupport = false; this.AlignAVStart = false; } + this.NotifyOfPropertyChange(() => this.IsMkv); + // Update The browse file extension display if (Path.HasExtension(newExtension)) { -- cgit v1.2.3