summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsr55 <[email protected]>2019-05-12 10:43:33 +0100
committersr55 <[email protected]>2019-05-12 10:43:33 +0100
commit0d0b684d6a02dd0ebfab97129cc53e7188cbcdc5 (patch)
tree564a70c9d0a4db64e9cf1db47f246244a5137ed4
parent50f8adb4efdf43eba77d92d8ef86eacee21fe201 (diff)
WinGui: Improvements for #2090
- Support upgrading presets from 1.2.2 and later. Preset importer required some fixes to allow this to operate. - Changed Import Presets function to ignore built-in presets when the user tries to import the presets.json file. Cuts down on the volume of errors they'll get doing so.
-rw-r--r--win/CS/HandBrakeWPF/Model/Filters/FilterPreset.cs4
-rw-r--r--win/CS/HandBrakeWPF/Model/Filters/FilterTune.cs4
-rw-r--r--win/CS/HandBrakeWPF/Properties/Resources.Designer.cs11
-rw-r--r--win/CS/HandBrakeWPF/Properties/Resources.resx5
-rw-r--r--win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs20
-rw-r--r--win/CS/HandBrakeWPF/Services/Presets/PresetService.cs22
6 files changed, 58 insertions, 8 deletions
diff --git a/win/CS/HandBrakeWPF/Model/Filters/FilterPreset.cs b/win/CS/HandBrakeWPF/Model/Filters/FilterPreset.cs
index 538a96439..a0ac286bb 100644
--- a/win/CS/HandBrakeWPF/Model/Filters/FilterPreset.cs
+++ b/win/CS/HandBrakeWPF/Model/Filters/FilterPreset.cs
@@ -25,8 +25,8 @@ namespace HandBrakeWPF.Model.Filters
public FilterPreset(HBPresetTune presetTune)
{
- this.DisplayName = presetTune.Name;
- this.Key = presetTune.ShortName;
+ this.DisplayName = presetTune?.Name;
+ this.Key = presetTune?.ShortName;
}
public string DisplayName { get; set; }
diff --git a/win/CS/HandBrakeWPF/Model/Filters/FilterTune.cs b/win/CS/HandBrakeWPF/Model/Filters/FilterTune.cs
index a14e55f8f..a67edc183 100644
--- a/win/CS/HandBrakeWPF/Model/Filters/FilterTune.cs
+++ b/win/CS/HandBrakeWPF/Model/Filters/FilterTune.cs
@@ -25,8 +25,8 @@ namespace HandBrakeWPF.Model.Filters
public FilterTune(HBPresetTune presetTune)
{
- this.DisplayName = presetTune.Name;
- this.Key = presetTune.ShortName;
+ this.DisplayName = presetTune?.Name;
+ this.Key = presetTune?.ShortName;
}
public string DisplayName { get; set; }
diff --git a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs
index 8c460eca0..e67762dc5 100644
--- a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs
+++ b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs
@@ -3738,6 +3738,17 @@ namespace HandBrakeWPF.Properties {
}
/// <summary>
+ /// Looks up a localized string similar to Your presets file contained built-in presets. The import function does not support importing these. Please use &apos;Presets Menu -&gt; Reset Built In-Presets&apos; to restore the standard presets.
+ ///
+ ///Where supported, any user presets will have been imported..
+ /// </summary>
+ public static string PresetService_ImportingBuiltInWarning {
+ get {
+ return ResourceManager.GetString("PresetService_ImportingBuiltInWarning", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Unable to load presets..
/// </summary>
public static string PresetService_UnableToLoad {
diff --git a/win/CS/HandBrakeWPF/Properties/Resources.resx b/win/CS/HandBrakeWPF/Properties/Resources.resx
index d7d5dedcb..4aa9ec7fb 100644
--- a/win/CS/HandBrakeWPF/Properties/Resources.resx
+++ b/win/CS/HandBrakeWPF/Properties/Resources.resx
@@ -1991,4 +1991,9 @@ Non-Live Options: {date} {time} {creation-date} {creation-time} {quality} {bitra
<data name="Queue_RecoveryPossible" xml:space="preserve">
<value>Queue Recovery Possible</value>
</data>
+ <data name="PresetService_ImportingBuiltInWarning" xml:space="preserve">
+ <value>Your presets file contained built-in presets. The import function does not support importing these. Please use 'Presets Menu -&gt; Reset Built In-Presets' to restore the standard presets.
+
+Where supported, any user presets will have been imported.</value>
+ </data>
</root> \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs b/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs
index 91efcc7f9..a199c1cad 100644
--- a/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs
+++ b/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs
@@ -103,8 +103,24 @@ namespace HandBrakeWPF.Services.Presets.Factories
/* Filter Settings */
preset.Task.Grayscale = importedPreset.VideoGrayScale;
- preset.Task.DeblockPreset = new FilterPreset(HandBrakeFilterHelpers.GetFilterPresets((int)hb_filter_ids.HB_FILTER_DEBLOCK).FirstOrDefault(s => s.ShortName == importedPreset.PictureDeblockPreset));
- preset.Task.DeblockTune = new FilterTune(HandBrakeFilterHelpers.GetFilterTunes((int)hb_filter_ids.HB_FILTER_DEBLOCK).FirstOrDefault(s => s.ShortName == importedPreset.PictureDeblockTune));
+ if (!string.IsNullOrEmpty(importedPreset.PictureDeblockPreset))
+ {
+ preset.Task.DeblockPreset = new FilterPreset(HandBrakeFilterHelpers.GetFilterPresets((int)hb_filter_ids.HB_FILTER_DEBLOCK).FirstOrDefault(s => s.ShortName == importedPreset.PictureDeblockPreset));
+ }
+ else
+ {
+ preset.Task.DeblockPreset = new FilterPreset("Off", "off");
+ }
+
+ if (!string.IsNullOrEmpty(importedPreset.PictureDeblockTune))
+ {
+ preset.Task.DeblockTune = new FilterTune(HandBrakeFilterHelpers.GetFilterTunes((int)hb_filter_ids.HB_FILTER_DEBLOCK).FirstOrDefault(s => s.ShortName == importedPreset.PictureDeblockTune));
+ }
+ else
+ {
+ preset.Task.DeblockTune = new FilterTune("Off", "off");
+ }
+
preset.Task.CustomDeblock = importedPreset.PictureDeblockCustom;
if (importedPreset.PictureSharpenFilter != null)
diff --git a/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs b/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs
index 56bbbf8d0..ad8c6b7e7 100644
--- a/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs
+++ b/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs
@@ -192,6 +192,7 @@ namespace HandBrakeWPF.Services.Presets
// HBPreset Handling
if (container.PresetList != null)
{
+ bool containsBuildInPreset = false;
foreach (var objectPreset in container.PresetList)
{
PresetCategory category = JsonConvert.DeserializeObject<PresetCategory>(objectPreset.ToString());
@@ -200,10 +201,14 @@ namespace HandBrakeWPF.Services.Presets
foreach (HBPreset hbPreset in category.ChildrenArray)
{
Preset preset = this.ConvertHbPreset(hbPreset);
- if (preset != null)
+ if (preset != null && !preset.IsBuildIn)
{
this.AddOrUpdateImportedPreset(preset);
}
+ else
+ {
+ containsBuildInPreset = true;
+ }
}
}
else
@@ -212,13 +217,26 @@ namespace HandBrakeWPF.Services.Presets
if (hbPreset != null)
{
Preset preset = this.ConvertHbPreset(hbPreset);
- if (preset != null)
+ if (preset != null && !preset.IsBuildIn)
{
this.AddOrUpdateImportedPreset(preset);
}
+ else
+ {
+ containsBuildInPreset = true;
+ }
}
}
}
+
+ if (containsBuildInPreset)
+ {
+ this.errorService.ShowMessageBox(
+ Properties.Resources.PresetService_ImportingBuiltInWarning,
+ Properties.Resources.Warning,
+ MessageBoxButton.OK,
+ MessageBoxImage.Warning);
+ }
}
}
}