Add Icon for TimeDate extension in settings page. (#565)

1. Remove unused file
2. Fix Icon in Extensions setting page.
3. Fix save settings issue

---------

Co-authored-by: Yu Leng (from Dev Box) <yuleng@microsoft.com>
This commit is contained in:
moooyo
2025-03-18 21:25:02 +08:00
committed by GitHub
parent 6dcaa8dca4
commit 56f6f144bd
4 changed files with 9 additions and 23 deletions

View File

@@ -164,5 +164,7 @@ public class SettingsManager : JsonSettingsManager
// Load settings from file upon initialization
LoadSettings();
Settings.SettingsChanged += (s, a) => this.SaveSettings();
}
}

View File

@@ -16,7 +16,7 @@ internal sealed partial class TimeDateExtensionPage : DynamicListPage
public TimeDateExtensionPage(SettingsManager settingsManager)
{
Icon = new("\uEC92"); // DateTime icon
Icon = IconHelpers.FromRelativePath("Assets\\TimeDate.svg");
Title = Resources.Microsoft_plugin_timedate_main_page_title;
Name = Resources.Microsoft_plugin_timedate_main_page_name;
PlaceholderText = Resources.Microsoft_plugin_timedate_placeholder_text;

View File

@@ -15,20 +15,23 @@ namespace Microsoft.CmdPal.Ext.TimeDate;
public partial class TimeDateCommandsProvider : CommandProvider
{
private readonly CommandItem _command;
private readonly SettingsManager _settingsManager = new();
private static readonly SettingsManager _settingsManager = new();
private static readonly CompositeFormat MicrosoftPluginTimedatePluginDescription = System.Text.CompositeFormat.Parse(Resources.Microsoft_plugin_timedate_plugin_description);
private static readonly TimeDateExtensionPage _timeDateExtensionPage = new(_settingsManager);
public TimeDateCommandsProvider()
{
DisplayName = Resources.Microsoft_plugin_timedate_plugin_name;
_command = new CommandItem(new TimeDateExtensionPage(_settingsManager))
_command = new CommandItem(_timeDateExtensionPage)
{
Icon = IconHelpers.FromRelativePath("Assets\\TimeDate.svg"),
Icon = _timeDateExtensionPage.Icon,
Title = Resources.Microsoft_plugin_timedate_plugin_name,
Subtitle = GetTranslatedPluginDescription(),
MoreCommands = [new CommandContextItem(_settingsManager.Settings.SettingsPage)],
};
Icon = _timeDateExtensionPage.Icon;
}
private string GetTranslatedPluginDescription()

View File

@@ -1,19 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="HackerNewsExtension.app"/>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- The ID below informs the system that this application is compatible with OS features first introduced in Windows 10.
It is necessary to support features in unpackaged applications, for example the custom titlebar implementation.
For more info see https://docs.microsoft.com/windows/apps/windows-app-sdk/use-windows-app-sdk-run-time#declare-os-compatibility-in-your-application-manifest -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
</windowsSettings>
</application>
</assembly>