mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
Adding fallback command for Windows Settings extension (#40331)
Two changes: - Added a new fallback command for Windows Settings extension. If only one setting or one exact match for the query was found, display that setting in the list and open that setting on <Enter>. If more than one setting was found, display a message to open Windows Settings to see the search results for your query.    - Modified the titles/subtitles of the extension to pull from Resources to aid in internationalization. Closes: #38548 and possibly #40308
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.CmdPal.Ext.WindowsSettings.Helpers;
|
||||
using Microsoft.CmdPal.Ext.WindowsSettings.Pages;
|
||||
using Microsoft.CmdPal.Ext.WindowsSettings.Properties;
|
||||
using Microsoft.CommandPalette.Extensions;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
@@ -17,6 +18,8 @@ public partial class WindowsSettingsCommandsProvider : CommandProvider
|
||||
private readonly WindowsSettings.Classes.WindowsSettings? _windowsSettings;
|
||||
#pragma warning restore CS8632 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
|
||||
|
||||
private readonly FallbackWindowsSettingsItem _fallback;
|
||||
|
||||
public WindowsSettingsCommandsProvider()
|
||||
{
|
||||
Id = "Windows.Settings";
|
||||
@@ -26,9 +29,10 @@ public partial class WindowsSettingsCommandsProvider : CommandProvider
|
||||
_windowsSettings = JsonSettingsListHelper.ReadAllPossibleSettings();
|
||||
_searchSettingsListItem = new CommandItem(new WindowsSettingsListPage(_windowsSettings))
|
||||
{
|
||||
Title = "Windows Settings",
|
||||
Subtitle = "Navigate to specific Windows settings",
|
||||
Title = Resources.settings_title,
|
||||
Subtitle = Resources.settings_subtitle,
|
||||
};
|
||||
_fallback = new(_windowsSettings);
|
||||
|
||||
UnsupportedSettingsHelper.FilterByBuild(_windowsSettings);
|
||||
|
||||
@@ -42,4 +46,6 @@ public partial class WindowsSettingsCommandsProvider : CommandProvider
|
||||
_searchSettingsListItem
|
||||
];
|
||||
}
|
||||
|
||||
public override IFallbackCommandItem[] FallbackCommands() => [_fallback];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user