mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
added shortcut guide settings (#2247)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
|
||||
public SndModuleSettings(T settings)
|
||||
{
|
||||
powertoys = settings;
|
||||
this.powertoys = settings;
|
||||
}
|
||||
|
||||
public string ToJsonString()
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user