mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +02:00
## Summary of the Pull Request Adds keyboard shortcuts to `IndexerListItem` commands to mirror those in **All Apps**. - Introduces a new `KeyChords` class that defines and manages key chords for all actions within individual projects, improving code organization and maintainability (similar to the `Icons` class). - Adds a `WellKnownKeyChords` class in the shared project that defines common shortcuts to be used consistently across the entire app. - Updates `IndexerListItem` to include new command context items with `RequestedShortcut` properties for: - Show in folder (`Ctrl+Shift+E`) - Copy path (`Ctrl+Shift+C`) - Open path in console (`Ctrl+Shift+R`) - Updates `AppListItem`, `UWPApplication`, and `Win32Program` to use the new key chord properties from the `KeyChords` class, ensuring consistency and maintainability. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist - [ ] Closes: #xxx - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end-user-facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx <!-- Provide a more detailed description of the PR, other things fixed, or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed
52 lines
2.3 KiB
C#
52 lines
2.3 KiB
C#
// 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;
|
|
using Microsoft.CommandPalette.Extensions.Toolkit;
|
|
|
|
using Windows.System;
|
|
|
|
namespace Microsoft.CmdPal.Common.Helpers;
|
|
|
|
/// <summary>
|
|
/// Well-known key chords used in the Command Palette and extensions.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Assigned key chords should not conflict with system or application shortcuts.
|
|
/// However, the key chords in this class are not guaranteed to be unique and may conflict
|
|
/// with each other, especially when commands appear together in the same menu.
|
|
/// </remarks>
|
|
public static class WellKnownKeyChords
|
|
{
|
|
/// <summary>
|
|
/// Gets the well-known key chord for opening the file location. Shortcut: Ctrl+Shift+E.
|
|
/// </summary>
|
|
public static KeyChord OpenFileLocation { get; } = KeyChordHelpers.FromModifiers(ctrl: true, shift: true, vkey: (int)VirtualKey.E);
|
|
|
|
/// <summary>
|
|
/// Gets the well-known key chord for copying the file path. Shortcut: Ctrl+Shift+C.
|
|
/// </summary>
|
|
public static KeyChord CopyFilePath { get; } = KeyChordHelpers.FromModifiers(ctrl: true, shift: true, vkey: (int)VirtualKey.C);
|
|
|
|
/// <summary>
|
|
/// Gets the well-known key chord for opening the current location in a console. Shortcut: Ctrl+Shift+R.
|
|
/// </summary>
|
|
public static KeyChord OpenInConsole { get; } = KeyChordHelpers.FromModifiers(ctrl: true, shift: true, vkey: (int)VirtualKey.R);
|
|
|
|
/// <summary>
|
|
/// Gets the well-known key chord for running the selected item as administrator. Shortcut: Ctrl+Shift+Enter.
|
|
/// </summary>
|
|
public static KeyChord RunAsAdministrator { get; } = KeyChordHelpers.FromModifiers(ctrl: true, shift: true, vkey: (int)VirtualKey.Enter);
|
|
|
|
/// <summary>
|
|
/// Gets the well-known key chord for running the selected item as a different user. Shortcut: Ctrl+Shift+U.
|
|
/// </summary>
|
|
public static KeyChord RunAsDifferentUser { get; } = KeyChordHelpers.FromModifiers(ctrl: true, shift: true, vkey: (int)VirtualKey.U);
|
|
|
|
/// <summary>
|
|
/// Gets the well-known key chord for toggling the pin state. Shortcut: Ctrl+P.
|
|
/// </summary>
|
|
public static KeyChord TogglePin { get; } = KeyChordHelpers.FromModifiers(ctrl: true, vkey: (int)VirtualKey.P);
|
|
}
|