Standardizing built-in extension icon handling (#40606)

Just standardizing built-in extensions to use a `internal sealed class
Icons` for all their non-dynamic icons.

Looks like a LOT of changes, but it's icons all the way down.
This commit is contained in:
Michael Jolley
2025-07-15 14:33:25 -05:00
committed by GitHub
parent cc16b61eb7
commit b552f2ac1e
93 changed files with 371 additions and 245 deletions

View File

@@ -10,7 +10,6 @@ using System.Resources;
using System.Text;
using System.Threading.Tasks;
using Microsoft.CmdPal.Ext.WindowsSettings.Classes;
using Microsoft.CmdPal.Ext.WindowsSettings.Helpers;
using Microsoft.CmdPal.Ext.WindowsSettings.Properties;
using Microsoft.CommandPalette.Extensions;
using Microsoft.CommandPalette.Extensions.Toolkit;
@@ -27,7 +26,7 @@ internal sealed partial class CopySettingCommand : InvokableCommand
internal CopySettingCommand(WindowsSetting entry)
{
Name = Resources.CopyCommand;
Icon = new IconInfo("\xE8C8"); // Copy icon
Icon = Icons.CopyIcon;
_entry = entry;
}

View File

@@ -10,7 +10,6 @@ using System.Resources;
using System.Text;
using System.Threading.Tasks;
using Microsoft.CmdPal.Ext.WindowsSettings.Classes;
using Microsoft.CmdPal.Ext.WindowsSettings.Helpers;
using Microsoft.CmdPal.Ext.WindowsSettings.Properties;
using Microsoft.CommandPalette.Extensions;
using Microsoft.CommandPalette.Extensions.Toolkit;
@@ -27,7 +26,7 @@ internal sealed partial class OpenSettingsCommand : InvokableCommand
internal OpenSettingsCommand(WindowsSetting entry)
{
Name = Resources.OpenSettings;
Icon = new IconInfo("\xE8C8");
Icon = Icons.CopyIcon;
_entry = entry;
}

View File

@@ -8,7 +8,6 @@ using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Text;
using Microsoft.CmdPal.Ext.WindowsSettings.Commands;
using Microsoft.CmdPal.Ext.WindowsSettings.Helpers;
using Microsoft.CmdPal.Ext.WindowsSettings.Properties;
@@ -30,7 +29,7 @@ internal static class ResultHelper
{
var result = new ListItem(new OpenSettingsCommand(entry))
{
Icon = IconHelpers.FromRelativePath("Assets\\WindowsSettings.svg"),
Icon = Icons.WindowsSettingsIcon,
Subtitle = entry.JoinedFullSettingsPath,
Title = entry.Name,
MoreCommands = ContextMenuHelper.GetContextMenu(entry).ToArray(),

View File

@@ -0,0 +1,14 @@
// 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;
namespace Microsoft.CmdPal.Ext.WindowsSettings;
internal sealed class Icons
{
internal static IconInfo WindowsSettingsIcon { get; } = IconHelpers.FromRelativePath("Assets\\WindowsSettings.svg");
internal static IconInfo CopyIcon { get; } = new IconInfo("\xE8C8"); // Copy icon
}

View File

@@ -24,7 +24,7 @@ internal sealed partial class FallbackWindowsSettingsItem : FallbackCommandItem
public FallbackWindowsSettingsItem(Classes.WindowsSettings windowsSettings)
: base(new NoOpCommand(), Resources.settings_title)
{
Icon = IconHelpers.FromRelativePath("Assets\\WindowsSettings.svg");
Icon = Icons.WindowsSettingsIcon;
_windowsSettings = windowsSettings;
}
@@ -59,10 +59,10 @@ internal sealed partial class FallbackWindowsSettingsItem : FallbackCommandItem
Title = setting.Name;
Subtitle = setting.JoinedFullSettingsPath;
Icon = IconHelpers.FromRelativePath("Assets\\WindowsSettings.svg");
Icon = Icons.WindowsSettingsIcon;
Command = new OpenSettingsCommand(setting)
{
Icon = IconHelpers.FromRelativePath("Assets\\WindowsSettings.svg"),
Icon = Icons.WindowsSettingsIcon,
Name = setting.Name,
};
@@ -80,7 +80,7 @@ internal sealed partial class FallbackWindowsSettingsItem : FallbackCommandItem
// us to the Windows Settings search page, prepopulated with this search.
var settingsPage = new WindowsSettingsListPage(_windowsSettings, query);
Title = string.Format(CultureInfo.CurrentCulture, _title, query);
Icon = IconHelpers.FromRelativePath("Assets\\WindowsSettings.svg");
Icon = Icons.WindowsSettingsIcon;
Subtitle = _subtitle;
Command = settingsPage;

View File

@@ -19,7 +19,7 @@ internal sealed partial class WindowsSettingsListPage : DynamicListPage
public WindowsSettingsListPage(Classes.WindowsSettings windowsSettings)
{
Icon = IconHelpers.FromRelativePath("Assets\\WindowsSettings.svg");
Icon = Icons.WindowsSettingsIcon;
Name = Resources.settings_title;
Id = "com.microsoft.cmdpal.windowsSettings";
_windowsSettings = windowsSettings;

View File

@@ -24,7 +24,7 @@ public partial class WindowsSettingsCommandsProvider : CommandProvider
{
Id = "Windows.Settings";
DisplayName = Resources.WindowsSettingsProvider_DisplayName;
Icon = IconHelpers.FromRelativePath("Assets\\WindowsSettings.svg");
Icon = Icons.WindowsSettingsIcon;
_windowsSettings = JsonSettingsListHelper.ReadAllPossibleSettings();
_searchSettingsListItem = new CommandItem(new WindowsSettingsListPage(_windowsSettings))