Display Key Mappings in Settings (#2314)

* Move changes

* Display Key Mapping in Settings

* Fix display of empty keys list

Co-authored-by: Udit Singh <udsing@microsoft.com>
This commit is contained in:
Tomas Agustin Raies
2020-04-22 14:55:45 -07:00
committed by GitHub
parent ca3a436fe5
commit d941b31c45
16 changed files with 269 additions and 118 deletions

View File

@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation
// 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.
@@ -32,6 +32,9 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public bool PowerRename { get; set; }
[JsonPropertyName("Keyboard Manager")]
public bool KeyboardManager { get; set; }
public string ToJsonString()
{
return JsonSerializer.Serialize(this);

View File

@@ -7,12 +7,18 @@ using System.Text.Json.Serialization;
namespace Microsoft.PowerToys.Settings.UI.Lib
{
public class KeyboadManagerConfigModel
public class KeyboardManagerProfile
{
[JsonPropertyName("remapKeys")]
public RemapKeysDataModel RemapKeys { get; set; }
[JsonPropertyName("remapShortcuts")]
public ShortcutsKeyDataModel RemapShortcuts { get; set; }
public KeyboardManagerProfile()
{
RemapKeys = new RemapKeysDataModel();
RemapShortcuts = new ShortcutsKeyDataModel();
}
}
}

View File

@@ -2,6 +2,9 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Microsoft.PowerToys.Settings.UI.Lib.Utilities;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Serialization;
namespace Microsoft.PowerToys.Settings.UI.Lib
@@ -13,5 +16,24 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
[JsonPropertyName("newRemapKeys")]
public string NewRemapKeys { get; set; }
private List<string> MapKeys(string stringOfKeys)
{
return stringOfKeys
.Split(';')
.Select(uint.Parse)
.Select(Helper.GetKeyName)
.ToList();
}
public List<string> GetOriginalKeys()
{
return MapKeys(OriginalKeys);
}
public List<string> GetNewRemapKeys()
{
return MapKeys(NewRemapKeys);
}
}
}

View File

@@ -11,5 +11,10 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
{
[JsonPropertyName("inProcess")]
public List<KeysDataModel> InProcessRemapKeys { get; set; }
public RemapKeysDataModel()
{
InProcessRemapKeys = new List<KeysDataModel>();
}
}
}

View File

@@ -41,7 +41,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
$"Microsoft\\PowerToys\\{powertoy}\\{fileName}");
}
public static bool SettingsExists(string powertoy, string fileName = DefaultFileName)
public static bool SettingsExists(string powertoy = DefaultModuleName, string fileName = DefaultFileName)
{
return File.Exists(GetSettingsPath(powertoy, fileName));
}

View File

@@ -11,5 +11,10 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
{
[JsonPropertyName("global")]
public List<KeysDataModel> GlobalRemapShortcuts { get; set; }
public ShortcutsKeyDataModel()
{
GlobalRemapShortcuts = new List<KeysDataModel>();
}
}
}