summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorsr55 <[email protected]>2020-12-13 14:42:08 +0000
committersr55 <[email protected]>2020-12-13 14:48:53 +0000
commit7db0c342d286e0d884c3d7c0fcef51254d9fcd4f (patch)
tree38c3a2aa72db5b49ac0c9618465d910ba074f977 /win
parentb3237078a5c30afd02ea03866c0cfdc3428a43c3 (diff)
WinGui: Better handle disabled presets in the UI.
Diffstat (limited to 'win')
-rw-r--r--win/CS/HandBrake.Interop/Interop/Json/Presets/HBPreset.cs2
-rw-r--r--win/CS/HandBrakeWPF/Converters/PresetsMenuConverter.cs29
-rw-r--r--win/CS/HandBrakeWPF/Properties/Resources.Designer.cs9
-rw-r--r--win/CS/HandBrakeWPF/Properties/Resources.resx7
-rw-r--r--win/CS/HandBrakeWPF/Services/Presets/Model/PresetDisplayCategory.cs2
-rw-r--r--win/CS/HandBrakeWPF/Services/Presets/PresetService.cs26
6 files changed, 57 insertions, 18 deletions
diff --git a/win/CS/HandBrake.Interop/Interop/Json/Presets/HBPreset.cs b/win/CS/HandBrake.Interop/Interop/Json/Presets/HBPreset.cs
index 5753cf573..578bcfc50 100644
--- a/win/CS/HandBrake.Interop/Interop/Json/Presets/HBPreset.cs
+++ b/win/CS/HandBrake.Interop/Interop/Json/Presets/HBPreset.cs
@@ -411,5 +411,7 @@ namespace HandBrake.Interop.Interop.Json.Presets
/// Gets or sets a value indicating whether x 264 use advanced options.
/// </summary>
public bool x264UseAdvancedOptions { get; set; }
+
+ public bool PresetDisabled { get; set; }
}
} \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/Converters/PresetsMenuConverter.cs b/win/CS/HandBrakeWPF/Converters/PresetsMenuConverter.cs
index d3a114376..059860294 100644
--- a/win/CS/HandBrakeWPF/Converters/PresetsMenuConverter.cs
+++ b/win/CS/HandBrakeWPF/Converters/PresetsMenuConverter.cs
@@ -17,6 +17,7 @@ namespace HandBrakeWPF.Converters
using System.Windows.Controls;
using System.Windows.Data;
using HandBrakeWPF.Commands;
+ using HandBrakeWPF.Properties;
using HandBrakeWPF.Services.Presets.Interfaces;
using HandBrakeWPF.Services.Presets.Model;
@@ -75,28 +76,40 @@ namespace HandBrakeWPF.Converters
{
if (groupedMenu.ContainsKey(preset.Category))
{
- MenuItem newMeuItem = new MenuItem { Header = preset.Name, Tag = preset, Command = new PresetMenuSelectCommand(preset) };
+ MenuItem newMenuItem = new MenuItem { Header = preset.Name, Tag = preset, Command = new PresetMenuSelectCommand(preset), IsEnabled = !preset.IsPresetDisabled };
+
+ if (preset.IsPresetDisabled)
+ {
+ newMenuItem.Header = string.Format("{0} {1}", preset.Name, Resources.Preset_NotAvailable);
+ }
+
if (preset.IsDefault)
{
- newMeuItem.FontStyle = FontStyles.Italic;
- newMeuItem.FontSize = 14;
+ newMenuItem.FontStyle = FontStyles.Italic;
+ newMenuItem.FontSize = 14;
}
- groupedMenu[preset.Category].Items.Add(newMeuItem);
+ groupedMenu[preset.Category].Items.Add(newMenuItem);
}
else
{
MenuItem group = new MenuItem();
group.Header = preset.Category;
- MenuItem newMeuItem = new MenuItem { Header = preset.Name, Tag = preset, Command = new PresetMenuSelectCommand(preset) };
+ MenuItem newMenuItem = new MenuItem { Header = preset.Name, Tag = preset, Command = new PresetMenuSelectCommand(preset), IsEnabled = !preset.IsPresetDisabled };
+
+ if (preset.IsPresetDisabled)
+ {
+ newMenuItem.Header = string.Format("{0} {1}", preset.Name, Resources.Preset_NotAvailable);
+ }
+
if (preset.IsDefault)
{
- newMeuItem.FontStyle = FontStyles.Italic;
- newMeuItem.FontSize = 14;
+ newMenuItem.FontStyle = FontStyles.Italic;
+ newMenuItem.FontSize = 14;
}
- group.Items.Add(newMeuItem);
+ group.Items.Add(newMenuItem);
groupedMenu[preset.Category] = group;
}
}
diff --git a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs
index 38564b462..80075b8f7 100644
--- a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs
+++ b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs
@@ -4401,6 +4401,15 @@ namespace HandBrakeWPF.Properties {
}
/// <summary>
+ /// Looks up a localized string similar to (Not Available).
+ /// </summary>
+ public static string Preset_NotAvailable {
+ get {
+ return ResourceManager.GetString("Preset_NotAvailable", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Official.
/// </summary>
public static string Preset_Official {
diff --git a/win/CS/HandBrakeWPF/Properties/Resources.resx b/win/CS/HandBrakeWPF/Properties/Resources.resx
index a45cc583d..0d138e636 100644
--- a/win/CS/HandBrakeWPF/Properties/Resources.resx
+++ b/win/CS/HandBrakeWPF/Properties/Resources.resx
@@ -112,10 +112,10 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
- <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
- <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Video_EncoderExtraArgs" xml:space="preserve">
<value>The full list of encoder parameters:
@@ -2387,4 +2387,7 @@ Fields are limited to:
<data name="OptionsView_SimultaneousHardwareLimitNotice" xml:space="preserve">
<value>Notice: This is the upper limit of simultaneous jobs. Hardware limitations may take effect which lowers the actual number of simultaneous jobs during encoding.</value>
</data>
+ <data name="Preset_NotAvailable" xml:space="preserve">
+ <value>(Not Available)</value>
+ </data>
</root> \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/Services/Presets/Model/PresetDisplayCategory.cs b/win/CS/HandBrakeWPF/Services/Presets/Model/PresetDisplayCategory.cs
index 53e19bc62..096793d73 100644
--- a/win/CS/HandBrakeWPF/Services/Presets/Model/PresetDisplayCategory.cs
+++ b/win/CS/HandBrakeWPF/Services/Presets/Model/PresetDisplayCategory.cs
@@ -48,6 +48,8 @@ namespace HandBrakeWPF.Services.Presets.Model
}
}
+ public bool IsPresetDisabled => false;
+
public bool IsSelected
{
get => this.isSelected;
diff --git a/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs b/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs
index ab1e76d87..748e69a0a 100644
--- a/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs
+++ b/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs
@@ -17,6 +17,7 @@ namespace HandBrakeWPF.Services.Presets
using System.IO;
using System.Linq;
using System.Windows;
+ using System.Windows.Xps.Serialization;
using HandBrake.Interop.Interop;
using HandBrake.Interop.Interop.Json.Presets;
@@ -433,7 +434,7 @@ namespace HandBrakeWPF.Services.Presets
preset.IsBuildIn = true;
preset.Category = category.PresetName;
preset.Task.AllowedPassthruOptions = new AllowedPassthru(true); // We don't want to override the built-in preset
- preset.IsPresetDisabled = this.IsPresetDisabled(preset);
+ preset.IsPresetDisabled = this.IsPresetDisabled(preset) || hbpreset.PresetDisabled;
this.Add(preset, true);
}
@@ -826,37 +827,46 @@ namespace HandBrakeWPF.Services.Presets
private bool IsPresetDisabled(Preset preset)
{
- if (preset.Task.VideoEncoder == VideoEncoder.QuickSync && !SystemInfo.IsQsvAvailable)
+ if (preset.Task.VideoEncoder == VideoEncoder.QuickSyncH265)
+ {
+ Console.Write("tets");
+ }
+
+ bool isQsvEnabled = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.EnableQuickSyncEncoding);
+ bool isNvencEnabled = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.EnableNvencEncoder);
+ bool isVcnEnabled = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.EnableVceEncoder);
+
+ if (preset.Task.VideoEncoder == VideoEncoder.QuickSync && (!SystemInfo.IsQsvAvailable || !isQsvEnabled))
{
return true;
}
- if (preset.Task.VideoEncoder == VideoEncoder.QuickSyncH265 && !SystemInfo.IsQsvAvailableH265)
+ if (preset.Task.VideoEncoder == VideoEncoder.QuickSyncH265 && (!SystemInfo.IsQsvAvailableH265 || !isQsvEnabled))
{
return true;
}
- if (preset.Task.VideoEncoder == VideoEncoder.QuickSyncH26510b && !SystemInfo.IsQsvAvailableH265)
+ if (preset.Task.VideoEncoder == VideoEncoder.QuickSyncH26510b && (!SystemInfo.IsQsvAvailableH265 || !isQsvEnabled))
{
return true;
}
- if (preset.Task.VideoEncoder == VideoEncoder.VceH264 && !SystemInfo.IsVceH264Available)
+ if (preset.Task.VideoEncoder == VideoEncoder.VceH264 && (!SystemInfo.IsVceH264Available || !isVcnEnabled))
{
return true;
}
- if (preset.Task.VideoEncoder == VideoEncoder.VceH265 && !SystemInfo.IsVceH265Available)
+ if (preset.Task.VideoEncoder == VideoEncoder.VceH265 && (!SystemInfo.IsVceH265Available || !isVcnEnabled))
{
return true;
}
- if (preset.Task.VideoEncoder == VideoEncoder.NvencH264 && !SystemInfo.IsNVEncH264Available)
+ if (preset.Task.VideoEncoder == VideoEncoder.NvencH264 && (!SystemInfo.IsNVEncH264Available || !isNvencEnabled))
{
return true;
}
- if (preset.Task.VideoEncoder == VideoEncoder.NvencH265 && !SystemInfo.IsNVEncH265Available)
+ if (preset.Task.VideoEncoder == VideoEncoder.NvencH265 && (!SystemInfo.IsNVEncH265Available || !isNvencEnabled))
{
return true;
}