added shortcut guide settings (#2247)

This commit is contained in:
Lavius Motileng
2020-04-20 06:03:26 -07:00
committed by GitHub
parent 0417b6266a
commit cae77ae291
14 changed files with 450 additions and 49 deletions

View File

@@ -0,0 +1,29 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Microsoft.PowerToys.Settings.UI.Lib
{
// Represents the configuration property of the settings that store Double type.
public class DoubleProperty
{
public DoubleProperty()
{
this.Value = 0.0;
}
// Gets or sets the double value of the settings configuration.
[JsonPropertyName("value")]
public double Value { get; set; }
// Returns a JSON version of the class settings configuration class.
public override string ToString()
{
return JsonSerializer.Serialize(this);
}
}
}

View File

@@ -2,6 +2,7 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Microsoft.PowerToys.Settings.UI.Lib
@@ -14,7 +15,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
this.ImageResizer = false;
this.FileExplorerPreview = false;
this.PowerRename = false;
this.ShortcutGuide = true;
this.ShortcutGuide = false;
}
[JsonPropertyName("FancyZones")]
@@ -30,5 +31,10 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public bool ShortcutGuide { get; set; }
public bool PowerRename { get; set; }
public string ToJsonString()
{
return JsonSerializer.Serialize(this);
}
}
}

View File

@@ -11,6 +11,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public static class SettingsUtils
{
private const string DefaultFileName = "settings.json";
private const string DefaultModuleName = "";
public static bool SettingsFolderExists(string powertoy)
{
@@ -49,14 +50,14 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
/// Get a Deserialized object of the json settings string.
/// </summary>
/// <returns>Deserialized json settings object.</returns>
public static T GetSettings<T>(string powertoy, string fileName = DefaultFileName)
public static T GetSettings<T>(string powertoy = DefaultModuleName, string fileName = DefaultFileName)
{
var jsonSettingsString = File.ReadAllText(GetSettingsPath(powertoy, fileName));
return JsonSerializer.Deserialize<T>(jsonSettingsString);
}
// Save settings to a json file.
public static void SaveSettings(string jsonSettings, string powertoy, string fileName = DefaultFileName)
public static void SaveSettings(string jsonSettings, string powertoy = DefaultModuleName, string fileName = DefaultFileName)
{
try
{

View File

@@ -0,0 +1,31 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json.Serialization;
namespace Microsoft.PowerToys.Settings.UI.Lib
{
public class ShortcutGuideProperties
{
public ShortcutGuideProperties()
{
OverlayOpacity = new IntProperty();
PressTime = new IntProperty();
Theme = new StringProperty();
}
[JsonPropertyName("overlay_opacity")]
public IntProperty OverlayOpacity { get; set; }
[JsonPropertyName("press_time")]
public IntProperty PressTime { get; set; }
[JsonPropertyName("theme")]
public StringProperty Theme { get; set; }
}
}

View File

@@ -0,0 +1,36 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Microsoft.PowerToys.Settings.UI.Lib
{
public class ShortcutGuideSettings
{
public ShortcutGuideSettings()
{
Name = "Shortcut Guide";
Properties = new ShortcutGuideProperties();
Version = "1.0";
}
[JsonPropertyName("name")]
public string Name { get; set; }
[JsonPropertyName("properties")]
public ShortcutGuideProperties Properties { get; set; }
[JsonPropertyName("version")]
public string Version { get; set; }
public string ToJsonString()
{
return JsonSerializer.Serialize(this);
}
}
}

View File

@@ -15,7 +15,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public SndModuleSettings(T settings)
{
powertoys = settings;
this.powertoys = settings;
}
public string ToJsonString()

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Microsoft.PowerToys.Settings.UI.Lib
{
public class SndShortcutGuideSettings
{
[JsonPropertyName("Shortcut Guide")]
public ShortcutGuideSettings ShortcutGuide { get; set; }
public SndShortcutGuideSettings(ShortcutGuideSettings settings)
{
this.ShortcutGuide = settings;
}
public string ToJsonString()
{
return JsonSerializer.Serialize(this);
}
}
}