mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 18:57:19 +02:00
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:
@@ -25,7 +25,7 @@ public partial class CalculatorCommandProvider : CommandProvider
|
||||
{
|
||||
Id = "Calculator";
|
||||
DisplayName = Resources.calculator_display_name;
|
||||
Icon = CalculatorIcons.ProviderIcon;
|
||||
Icon = Icons.CalculatorIcon;
|
||||
Settings = settings.Settings;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +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;
|
||||
|
||||
namespace Microsoft.CmdPal.Ext.Calc.Helper;
|
||||
|
||||
public static class CalculatorIcons
|
||||
{
|
||||
public static IconInfo ResultIcon => new("\uE94E");
|
||||
|
||||
public static IconInfo SaveIcon => new("\uE74E");
|
||||
|
||||
public static IconInfo ErrorIcon => new("\uE783");
|
||||
|
||||
public static IconInfo ProviderIcon => IconHelpers.FromRelativePath("Assets\\Calculator.svg");
|
||||
}
|
||||
@@ -47,7 +47,7 @@ internal static class ErrorHandler
|
||||
{
|
||||
Title = Properties.Resources.calculator_calculation_failed_title,
|
||||
Subtitle = errorMessage,
|
||||
Icon = CalculatorIcons.ErrorIcon,
|
||||
Icon = Icons.ErrorIcon,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public static class ResultHelper
|
||||
return new ListItem(saveCommand)
|
||||
{
|
||||
// Using CurrentCulture since this is user facing
|
||||
Icon = CalculatorIcons.ResultIcon,
|
||||
Icon = Icons.ResultIcon,
|
||||
Title = result,
|
||||
Subtitle = query,
|
||||
TextToSuggest = result,
|
||||
|
||||
@@ -18,7 +18,7 @@ public sealed partial class SaveCommand : InvokableCommand
|
||||
public SaveCommand(string result)
|
||||
{
|
||||
Name = Resources.calculator_save_command_name;
|
||||
Icon = CalculatorIcons.SaveIcon;
|
||||
Icon = Icons.SaveIcon;
|
||||
_result = result;
|
||||
}
|
||||
|
||||
|
||||
18
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Icons.cs
Normal file
18
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Icons.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
// 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.Calc;
|
||||
|
||||
internal sealed class Icons
|
||||
{
|
||||
internal static IconInfo CalculatorIcon => IconHelpers.FromRelativePath("Assets\\Calculator.svg");
|
||||
|
||||
internal static IconInfo ResultIcon => new("\uE94E"); // CalculatorEqualTo icon
|
||||
|
||||
internal static IconInfo SaveIcon => new("\uE74E"); // Save icon
|
||||
|
||||
internal static IconInfo ErrorIcon => new("\uE783"); // Error icon
|
||||
}
|
||||
@@ -35,7 +35,7 @@ public sealed partial class CalculatorListPage : DynamicListPage
|
||||
public CalculatorListPage(SettingsManager settings)
|
||||
{
|
||||
_settingsManager = settings;
|
||||
Icon = CalculatorIcons.ProviderIcon;
|
||||
Icon = Icons.CalculatorIcon;
|
||||
Name = Resources.calculator_title;
|
||||
PlaceholderText = Resources.calculator_placeholder_text;
|
||||
Id = "com.microsoft.cmdpal.calculator";
|
||||
@@ -43,11 +43,11 @@ public sealed partial class CalculatorListPage : DynamicListPage
|
||||
_emptyItem = new ListItem(new NoOpCommand())
|
||||
{
|
||||
Title = Resources.calculator_placeholder_text,
|
||||
Icon = CalculatorIcons.ResultIcon,
|
||||
Icon = Icons.ResultIcon,
|
||||
};
|
||||
EmptyContent = new CommandItem(new NoOpCommand())
|
||||
{
|
||||
Icon = CalculatorIcons.ProviderIcon,
|
||||
Icon = Icons.CalculatorIcon,
|
||||
Title = Resources.calculator_placeholder_text,
|
||||
};
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ public sealed partial class FallbackCalculatorItem : FallbackCommandItem
|
||||
_copyCommand.Name = string.Empty;
|
||||
Title = string.Empty;
|
||||
Subtitle = Resources.calculator_placeholder_text;
|
||||
Icon = CalculatorIcons.ProviderIcon;
|
||||
Icon = Icons.CalculatorIcon;
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user