From d79226267d254143685d21ad35e5695181fefc4a Mon Sep 17 00:00:00 2001 From: sr55 Date: Sat, 9 Jan 2010 23:23:33 +0000 Subject: [PATCH] WinGui: - Don't try set the quality slider when the preset doesn't use it. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3064 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/C#/Functions/PresetLoader.cs | 60 +++++++++++++++++--------------- win/C#/Functions/QueryParser.cs | 4 ++- 2 files changed, 34 insertions(+), 30 deletions(-) diff --git a/win/C#/Functions/PresetLoader.cs b/win/C#/Functions/PresetLoader.cs index b484b6958..5f0459040 100644 --- a/win/C#/Functions/PresetLoader.cs +++ b/win/C#/Functions/PresetLoader.cs @@ -155,40 +155,42 @@ namespace Handbrake.Functions // Quality - mainWindow.radio_cq.Checked = true; - if (presetQuery.VideoEncoder == "H.264 (x264)") + if (presetQuery.VideoQuality != -1) { - double cqStep = Properties.Settings.Default.x264cqstep; - int value; - double x264step = cqStep; - double presetValue = presetQuery.VideoQuality; - - double x = 51 / x264step; - - double calculated = presetValue / x264step; - calculated = x - calculated; - - int.TryParse(calculated.ToString(), out value); - - // This will sometimes occur when the preset was generated - // with a different granularity, so, round and try again. - if (value == 0) + mainWindow.radio_cq.Checked = true; + if (presetQuery.VideoEncoder == "H.264 (x264)") { - double val = Math.Round(calculated, 0); - int.TryParse(val.ToString(), out value); + double cqStep = Properties.Settings.Default.x264cqstep; + int value; + double x264step = cqStep; + double presetValue = presetQuery.VideoQuality; + + double x = 51/x264step; + + double calculated = presetValue/x264step; + calculated = x - calculated; + + int.TryParse(calculated.ToString(), out value); + + // This will sometimes occur when the preset was generated + // with a different granularity, so, round and try again. + if (value == 0) + { + double val = Math.Round(calculated, 0); + int.TryParse(val.ToString(), out value); + } + if (value <= mainWindow.slider_videoQuality.Maximum) + mainWindow.slider_videoQuality.Value = value; + } + else + { + int presetVal; + int.TryParse(presetQuery.VideoQuality.ToString(), out presetVal); + if (presetVal > mainWindow.slider_videoQuality.Minimum) + mainWindow.slider_videoQuality.Value = presetVal; } - if (value <= mainWindow.slider_videoQuality.Maximum) - mainWindow.slider_videoQuality.Value = value; - } - else - { - int presetVal; - int.TryParse(presetQuery.VideoQuality.ToString(), out presetVal); - if (presetVal > mainWindow.slider_videoQuality.Minimum) - mainWindow.slider_videoQuality.Value = presetVal; } - mainWindow.check_2PassEncode.CheckState = presetQuery.TwoPass ? CheckState.Checked : CheckState.Unchecked; mainWindow.drp_videoFramerate.Text = presetQuery.VideoFramerate; diff --git a/win/C#/Functions/QueryParser.cs b/win/C#/Functions/QueryParser.cs index 7230ad993..78a73b52b 100644 --- a/win/C#/Functions/QueryParser.cs +++ b/win/C#/Functions/QueryParser.cs @@ -329,7 +329,9 @@ namespace Handbrake.Functions { float qConvert = float.Parse(videoQuality.ToString().Replace("-q ", ""), Culture); thisQuery.VideoQuality = qConvert; - } + } + else + thisQuery.VideoQuality = -1; #endregion #region Audio Tab -- 2.40.0