[ColorPicker]Store color history in a separated file (#23146)

* [ColorPicker] Store color history in a separated file

* ColorPicker] Separated file for color history: use the list from the settings.json if there is no ColorHistory.json file (preventing loss of existing color history)

* Fix case when there is no history saved or no settings file at all.
This commit is contained in:
Laszlo Nemeth
2023-06-13 11:10:03 +02:00
committed by GitHub
parent 0adda35b4b
commit 06e4518742
3 changed files with 25 additions and 11 deletions

View File

@@ -16,7 +16,6 @@ namespace Microsoft.PowerToys.Settings.UI.Library
{
ActivationShortcut = new HotkeySettings(true, false, false, true, 0x43);
ChangeCursor = false;
ColorHistory = new List<string>();
ColorHistoryLimit = 20;
VisibleColorFormats = new Dictionary<string, KeyValuePair<bool, string>>();
VisibleColorFormats.Add("HEX", new KeyValuePair<bool, string>(true, ColorFormatHelper.GetDefaultFormat("HEX")));
@@ -50,6 +49,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
[JsonPropertyName("activationaction")]
public ColorPickerActivationAction ActivationAction { get; set; }
// Property ColorHistory is not used, the color history is saved separatedly in the colorHistory.json file
[JsonPropertyName("colorhistory")]
public List<string> ColorHistory { get; set; }

View File

@@ -56,7 +56,6 @@ namespace Microsoft.PowerToys.Settings.UI.Library
newSettings.Properties.ActivationShortcut = oldSettings.Properties.ActivationShortcut;
newSettings.Properties.ChangeCursor = oldSettings.Properties.ChangeCursor;
newSettings.Properties.ActivationAction = oldSettings.Properties.ActivationAction;
newSettings.Properties.ColorHistory = new List<string>(oldSettings.Properties.ColorHistory);
newSettings.Properties.ColorHistoryLimit = oldSettings.Properties.ColorHistoryLimit;
newSettings.Properties.ShowColorName = oldSettings.Properties.ShowColorName;
newSettings.Properties.ActivationShortcut = oldSettings.Properties.ActivationShortcut;