mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-03 01:36:31 +02:00
[Keyboard Manager] Updated WinUI3 KBM and toggles (#45649)
## Running the Project **Option 1: Test via runner** 1. Check out branch `niels9001/kbm-ux-consolidation` 2. Build PowerToys project 3. Manually build `Modules/KeyboardManagerEditorUI` project separately 4. Run `runner` project 5. Ensure experimental features are enabled in general settings (should be on by default) 6. Launch keyboard manager via settings app **Option 2: Test via installer** 1. Install PowerToys via installer on azure pipeline 1. Launch keyboard manager ## Validation For each page (Text, Remappings, Programs, URLs): * Create shortcuts with variable options and ensure they run as expected * Delete shortcuts and ensure they no longer execute * Try to create invalid shortcuts to check for proper validation * Ensure created shortcuts appear in Power Toys Settings Keyboard manager page * Try toggling shortcuts * Try deleting shortcuts while toggled off ### UI * Any feedback on UI design appreciated as well <img width="1071" height="671" alt="image" src="https://github.com/user-attachments/assets/d2e81de0-6d92-4189-9a33-32e94cce74f7" /> <img width="2142" height="1341" alt="image" src="https://github.com/user-attachments/assets/0e4e5685-fdf1-4dfd-ba52-a2e5bc9a66db" /> Closes: #15870 Closes: #31902 Closes: #45302 Closes: #36227 Closes: #16093 Closes: #13409 Closes: #9919 Closes: #9482 Closes: #8798 Closes: #7054 Closes: #2733 Closes: #2027 Closes: #30167 --------- Co-authored-by: Hao Liu <liuhao3418@gmail.com> Co-authored-by: chenmy77 <162882040+chenmy77@users.noreply.github.com> Co-authored-by: Niels Laute <niels.laute@live.nl> Co-authored-by: Jay <65828559+Jay-o-Way@users.noreply.github.com> Co-authored-by: Jaylyn Barbee <51131738+Jaylyn-Barbee@users.noreply.github.com> Co-authored-by: Dustin L. Howett <duhowett@microsoft.com>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
// 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.Threading;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
using PowerToys.Interop;
|
||||
|
||||
namespace PowerToysExtension.Commands;
|
||||
|
||||
/// <summary>
|
||||
/// Opens the new Keyboard Manager editor.
|
||||
/// </summary>
|
||||
internal sealed partial class OpenNewKeyboardManagerEditorCommand : InvokableCommand
|
||||
{
|
||||
public OpenNewKeyboardManagerEditorCommand()
|
||||
{
|
||||
Name = "Open New Keyboard Manager Editor";
|
||||
}
|
||||
|
||||
public override CommandResult Invoke()
|
||||
{
|
||||
try
|
||||
{
|
||||
using var evt = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.OpenNewKeyboardManagerEvent());
|
||||
evt.Set();
|
||||
return CommandResult.Dismiss();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return CommandResult.ShowToast($"Failed to open New Keyboard Manager Editor: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,10 @@
|
||||
// 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.IO;
|
||||
using System.Text.Json;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
using PowerToysExtension.Commands;
|
||||
using PowerToysExtension.Helpers;
|
||||
@@ -18,6 +21,16 @@ internal sealed class KeyboardManagerModuleCommandProvider : ModuleCommandProvid
|
||||
var title = SettingsWindow.KBM.ModuleDisplayName();
|
||||
var icon = SettingsWindow.KBM.ModuleIcon();
|
||||
|
||||
if (IsUseNewEditorEnabled())
|
||||
{
|
||||
yield return new ListItem(new OpenNewKeyboardManagerEditorCommand())
|
||||
{
|
||||
Title = Resources.KeyboardManager_OpenNewEditor_Title,
|
||||
Subtitle = Resources.KeyboardManager_OpenNewEditor_Subtitle,
|
||||
Icon = icon,
|
||||
};
|
||||
}
|
||||
|
||||
yield return new ListItem(new OpenInSettingsCommand(SettingsWindow.KBM, title) { Id = "com.microsoft.powertoys.keyboardManager.openSettings" })
|
||||
{
|
||||
Title = title,
|
||||
@@ -25,4 +38,37 @@ internal sealed class KeyboardManagerModuleCommandProvider : ModuleCommandProvid
|
||||
Icon = icon,
|
||||
};
|
||||
}
|
||||
|
||||
private static bool IsUseNewEditorEnabled()
|
||||
{
|
||||
try
|
||||
{
|
||||
var settingsPath = Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
|
||||
"Microsoft",
|
||||
"PowerToys",
|
||||
"Keyboard Manager",
|
||||
"settings.json");
|
||||
|
||||
if (!File.Exists(settingsPath))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var json = File.ReadAllText(settingsPath);
|
||||
using var doc = JsonDocument.Parse(json);
|
||||
|
||||
if (doc.RootElement.TryGetProperty("properties", out var properties) &&
|
||||
properties.TryGetProperty("useNewEditor", out var useNewEditor))
|
||||
{
|
||||
return useNewEditor.GetBoolean();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// If we can't read the setting, default to not showing the command
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -861,6 +861,24 @@ namespace PowerToysExtension.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Keyboard Manager: Open Editor.
|
||||
/// </summary>
|
||||
internal static string KeyboardManager_OpenNewEditor_Title {
|
||||
get {
|
||||
return ResourceManager.GetString("KeyboardManager_OpenNewEditor_Title", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Open the Keyboard Manager remap editor.
|
||||
/// </summary>
|
||||
internal static string KeyboardManager_OpenNewEditor_Subtitle {
|
||||
get {
|
||||
return ResourceManager.GetString("KeyboardManager_OpenNewEditor_Subtitle", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Open Light Switch settings.
|
||||
/// </summary>
|
||||
|
||||
@@ -408,6 +408,12 @@
|
||||
<data name="KeyboardManager_Settings_Subtitle" xml:space="preserve">
|
||||
<value>Open Keyboard Manager settings</value>
|
||||
</data>
|
||||
<data name="KeyboardManager_OpenNewEditor_Title" xml:space="preserve">
|
||||
<value>Keyboard Manager: Open Editor</value>
|
||||
</data>
|
||||
<data name="KeyboardManager_OpenNewEditor_Subtitle" xml:space="preserve">
|
||||
<value>Open the Keyboard Manager remap editor</value>
|
||||
</data>
|
||||
<!-- Light Switch Module -->
|
||||
<data name="LightSwitch_Toggle_Title" xml:space="preserve">
|
||||
<value>Light Switch: Toggle theme</value>
|
||||
|
||||
Reference in New Issue
Block a user