mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 02:06:36 +02:00
_targets #40504_ Major refactoring for #40113 This moves a large swath of the codebase to a `.Core` project. "Core" doesn't have any explicit dependencies on "extensions", settings or the current `MainListPage`. It's just a filterable list of stuff. This should let us make this component a bit more reusable. This is half of a PR. As I did this, I noticed a particular bit of code for TopLevelVViewModels and CommandPaletteHost that was _very rough_. Solving it in this PR would make "move everything to a new project" much harder to review. So I'm submitting two PRs simultaneously, so we can see the changes separately, then merge together.
44 lines
1.9 KiB
C#
44 lines
1.9 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.CmdPal.Core.ViewModels.Messages;
|
|
using Microsoft.CommandPalette.Extensions;
|
|
using Microsoft.CommandPalette.Extensions.Toolkit;
|
|
|
|
namespace Microsoft.CmdPal.UI.ViewModels.BuiltinCommands;
|
|
|
|
/// <summary>
|
|
/// Built-in Provider for a top-level command which can quit the application. Invokes the <see cref="QuitCommand"/>, which sends a <see cref="QuitMessage"/>.
|
|
/// </summary>
|
|
public partial class BuiltInsCommandProvider : CommandProvider
|
|
{
|
|
private readonly OpenSettingsCommand openSettings = new();
|
|
private readonly QuitCommand quitCommand = new();
|
|
private readonly FallbackReloadItem _fallbackReloadItem = new();
|
|
private readonly FallbackLogItem _fallbackLogItem = new();
|
|
private readonly NewExtensionPage _newExtension = new();
|
|
|
|
public override ICommandItem[] TopLevelCommands() =>
|
|
[
|
|
new CommandItem(openSettings) { Subtitle = Properties.Resources.builtin_open_settings_subtitle },
|
|
new CommandItem(_newExtension) { Title = _newExtension.Title, Subtitle = Properties.Resources.builtin_new_extension_subtitle },
|
|
];
|
|
|
|
public override IFallbackCommandItem[] FallbackCommands() =>
|
|
[
|
|
new FallbackCommandItem(quitCommand, displayTitle: Properties.Resources.builtin_quit_subtitle) { Subtitle = Properties.Resources.builtin_quit_subtitle },
|
|
_fallbackReloadItem,
|
|
_fallbackLogItem,
|
|
];
|
|
|
|
public BuiltInsCommandProvider()
|
|
{
|
|
Id = "Core";
|
|
DisplayName = Properties.Resources.builtin_display_name;
|
|
Icon = IconHelpers.FromRelativePath("Assets\\StoreLogo.scale-200.png");
|
|
}
|
|
|
|
public override void InitializeWithHost(IExtensionHost host) => BuiltinsExtensionHost.Instance.Initialize(host);
|
|
}
|