mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-03 09:46:54 +02:00
[Keyboard Manager] Remove service enable/disable separate from module, fix editor clear shortcut (#46530)
Two changes to shortcuts here: 1) Remove toggling the KBM service with a shortcut or via command palette 2) Ensure that shortcut is disabled for editor when shortcut is cleared
This commit is contained in:
@@ -1,24 +0,0 @@
|
||||
// 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 Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
using PowerToysExtension.Helpers;
|
||||
using PowerToysExtension.Properties;
|
||||
|
||||
namespace PowerToysExtension.Commands;
|
||||
|
||||
internal sealed partial class ToggleKeyboardManagerListeningCommand : InvokableCommand
|
||||
{
|
||||
public ToggleKeyboardManagerListeningCommand()
|
||||
{
|
||||
Name = "Toggle Keyboard Manager active state";
|
||||
}
|
||||
|
||||
public override CommandResult Invoke()
|
||||
{
|
||||
return KeyboardManagerStateService.TryToggleListening()
|
||||
? CommandResult.KeepOpen()
|
||||
: CommandResult.ShowToast(Resources.ResourceManager.GetString("KeyboardManager_ToggleListening_Error", Resources.Culture) ?? "Keyboard Manager is unavailable. Try enabling it in PowerToys settings.");
|
||||
}
|
||||
}
|
||||
@@ -43,21 +43,6 @@ internal static class KeyboardManagerStateService
|
||||
return false;
|
||||
}
|
||||
|
||||
internal static bool TryToggleListening()
|
||||
{
|
||||
try
|
||||
{
|
||||
using var evt = EventWaitHandle.OpenExisting(Constants.ToggleKeyboardManagerActiveEvent());
|
||||
var signaled = evt.Set();
|
||||
PollStatus();
|
||||
return signaled;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void PollStatus()
|
||||
{
|
||||
var isListening = IsListening();
|
||||
|
||||
@@ -14,11 +14,6 @@ internal static class PowerToysResourcesHelper
|
||||
|
||||
internal static IconInfo IconFromSettingsIcon(string fileName) => IconHelpers.FromRelativePath($"{SettingsIconRoot}{fileName}");
|
||||
|
||||
internal static IconInfo KeyboardManagerListeningIcon(bool isListening) => IconHelpers.FromRelativePath(
|
||||
isListening
|
||||
? $"{AssetsRoot}KeyboardManager\\KeyboardManagerListeningOn.svg"
|
||||
: $"{AssetsRoot}KeyboardManager\\KeyboardManagerListeningOff.svg");
|
||||
|
||||
#if DEBUG
|
||||
public static IconInfo ProviderIcon() => IconFromSettingsIcon("PowerToys.dark.png");
|
||||
#else
|
||||
|
||||
@@ -22,19 +22,6 @@ internal sealed class KeyboardManagerModuleCommandProvider : ModuleCommandProvid
|
||||
var title = module.ModuleDisplayName();
|
||||
var icon = module.ModuleIcon();
|
||||
|
||||
if (ModuleEnablementService.IsModuleEnabled(module))
|
||||
{
|
||||
var isListening = KeyboardManagerStateService.IsListening();
|
||||
yield return new ListItem(new ToggleKeyboardManagerListeningCommand() { Id = "com.microsoft.powertoys.keyboardManager.toggleListening" })
|
||||
{
|
||||
Title = GetResourceString("KeyboardManager_ToggleListening_Title", "Keyboard Manager: Toggle active state"),
|
||||
Subtitle = isListening
|
||||
? GetResourceString("KeyboardManager_ToggleListening_On_Subtitle", "Keyboard Manager is active. Invoke to stop listening.")
|
||||
: GetResourceString("KeyboardManager_ToggleListening_Off_Subtitle", "Keyboard Manager is paused. Invoke to start listening."),
|
||||
Icon = PowerToysResourcesHelper.KeyboardManagerListeningIcon(isListening),
|
||||
};
|
||||
}
|
||||
|
||||
if (IsUseNewEditorEnabled())
|
||||
{
|
||||
yield return new ListItem(new OpenNewKeyboardManagerEditorCommand() { Id = "com.microsoft.powertoys.keyboardManager.openNewEditor" })
|
||||
|
||||
@@ -414,18 +414,6 @@
|
||||
<data name="KeyboardManager_OpenNewEditor_Subtitle" xml:space="preserve">
|
||||
<value>Open the Keyboard Manager remap editor</value>
|
||||
</data>
|
||||
<data name="KeyboardManager_ToggleListening_Title" xml:space="preserve">
|
||||
<value>Keyboard Manager: Toggle active state</value>
|
||||
</data>
|
||||
<data name="KeyboardManager_ToggleListening_On_Subtitle" xml:space="preserve">
|
||||
<value>Keyboard Manager is active. Invoke to stop listening.</value>
|
||||
</data>
|
||||
<data name="KeyboardManager_ToggleListening_Off_Subtitle" xml:space="preserve">
|
||||
<value>Keyboard Manager is paused. Invoke to start listening.</value>
|
||||
</data>
|
||||
<data name="KeyboardManager_ToggleListening_Error" xml:space="preserve">
|
||||
<value>Keyboard Manager is unavailable. Try enabling it in PowerToys settings.</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