From 0464170f84054a57f6200084f02783e679c1f768 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sun, 27 May 2012 17:19:01 +0000 Subject: WinGui: Fix for the Constant Quality slider when changing the granularity without restarting the app. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4706 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs | 2 +- win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs | 60 ++++++++++++++-------- 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs index 951d8e3ac..6f9500e0d 100644 --- a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs @@ -1447,7 +1447,7 @@ namespace HandBrakeWPF.ViewModels // x264 step this.ConstantQualityGranularity.Clear(); - this.ConstantQualityGranularity.Add("1.0"); + this.ConstantQualityGranularity.Add("1.00"); this.ConstantQualityGranularity.Add("0.50"); this.ConstantQualityGranularity.Add("0.25"); this.ConstantQualityGranularity.Add("0.20"); diff --git a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs index bf7c76c55..a520bf202 100644 --- a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs @@ -216,8 +216,11 @@ namespace HandBrakeWPF.ViewModels } set { - this.qualityMax = value; - this.NotifyOfPropertyChange(() => this.QualityMax); + if (!qualityMax.Equals(value)) + { + this.qualityMax = value; + this.NotifyOfPropertyChange(() => this.QualityMax); + } } } @@ -232,8 +235,11 @@ namespace HandBrakeWPF.ViewModels } set { - this.qualityMin = value; - this.NotifyOfPropertyChange(() => this.QualityMin); + if (!qualityMin.Equals(value)) + { + this.qualityMin = value; + this.NotifyOfPropertyChange(() => this.QualityMin); + } } } @@ -251,6 +257,7 @@ namespace HandBrakeWPF.ViewModels this.rf = value; double cqStep = userSettingService.GetUserSetting(ASUserSettingConstants.X264Step); + this.SetQualitySliderBounds(); switch (this.SelectedVideoEncoder) { case VideoEncoder.FFMpeg: @@ -344,23 +351,8 @@ namespace HandBrakeWPF.ViewModels IAdvancedViewModel advancedViewModel = IoC.Get(); advancedViewModel.SetEncoder(this.Task.VideoEncoder); - // Update the Quality Slider - switch (this.SelectedVideoEncoder) - { - case VideoEncoder.FFMpeg: - case VideoEncoder.FFMpeg2: - this.QualityMin = 1; - this.QualityMax = 31; - break; - case VideoEncoder.X264: - this.QualityMin = 0; - this.QualityMax = (int)(51 / userSettingService.GetUserSetting(ASUserSettingConstants.X264Step)); - break; - case VideoEncoder.Theora: - this.QualityMin = 0; - this.QualityMax = 63; - break; - } + // Update the Quality Slider. Make sure the bounds are up to date with the users settings. + this.SetQualitySliderBounds(); } } @@ -448,6 +440,7 @@ namespace HandBrakeWPF.ViewModels double cqStep = userSettingService.GetUserSetting(ASUserSettingConstants.X264Step); double rfValue = 0; + this.SetQualitySliderBounds(); switch (this.SelectedVideoEncoder) { case VideoEncoder.FFMpeg: @@ -523,6 +516,31 @@ namespace HandBrakeWPF.ViewModels #endregion + /// + /// Set the bounds of the Constant Quality Slider + /// + private void SetQualitySliderBounds() + { + // Note Updating bounds to the same values won't trigger an update. + // The properties are smart enough to not take in equal values. + switch (this.SelectedVideoEncoder) + { + case VideoEncoder.FFMpeg: + case VideoEncoder.FFMpeg2: + this.QualityMin = 1; + this.QualityMax = 31; + break; + case VideoEncoder.X264: + this.QualityMin = 0; + this.QualityMax = (int)(51 / userSettingService.GetUserSetting(ASUserSettingConstants.X264Step)); + break; + case VideoEncoder.Theora: + this.QualityMin = 0; + this.QualityMax = 63; + break; + } + } + #region Advanced ///// ///// Gets or sets State. -- cgit v1.2.3