mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-15 19:27:56 +01:00
plugin manager search (#12560)
This commit is contained in:
committed by
GitHub
parent
05f12dcdf1
commit
29d3f47d47
@@ -9,9 +9,11 @@ using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text.Json;
|
||||
using System.Windows.Input;
|
||||
using ManagedCommon;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Helpers;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.ViewModels.Commands;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
||||
{
|
||||
@@ -25,6 +27,8 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
||||
private bool _isPrimaryMonitorPositionRadioButtonChecked;
|
||||
private bool _isFocusPositionRadioButtonChecked;
|
||||
|
||||
private string _searchText;
|
||||
|
||||
private GeneralSettings GeneralSettingsConfig { get; set; }
|
||||
|
||||
private PowerLauncherSettings settings;
|
||||
@@ -99,6 +103,8 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
||||
{
|
||||
plugin.PropertyChanged += OnPluginInfoChange;
|
||||
}
|
||||
|
||||
SearchPluginsCommand = new RelayCommand(SearchPlugins);
|
||||
}
|
||||
|
||||
private void OnPluginInfoChange(object sender, PropertyChangedEventArgs e)
|
||||
@@ -304,6 +310,25 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public string SearchText
|
||||
{
|
||||
get
|
||||
{
|
||||
return _searchText;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_searchText != value)
|
||||
{
|
||||
_searchText = value;
|
||||
OnPropertyChanged(nameof(SearchText));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand SearchPluginsCommand { get; }
|
||||
|
||||
public HotkeySettings OpenPowerLauncher
|
||||
{
|
||||
get
|
||||
@@ -452,5 +477,20 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
||||
{
|
||||
return this.settings.Equals(settings);
|
||||
}
|
||||
|
||||
public void SearchPlugins()
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(SearchText))
|
||||
{
|
||||
var plugins = settings.Plugins.Where(p => p.Name.StartsWith(SearchText, StringComparison.OrdinalIgnoreCase) || p.Name.IndexOf($" {SearchText}", StringComparison.OrdinalIgnoreCase) > 0);
|
||||
_plugins = new ObservableCollection<PowerLauncherPluginViewModel>(plugins.Select(x => new PowerLauncherPluginViewModel(x, isDark)));
|
||||
}
|
||||
else
|
||||
{
|
||||
_plugins = null;
|
||||
}
|
||||
|
||||
OnPropertyChanged(nameof(Plugins));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1394,4 +1394,7 @@ From there, simply click on a Markdown file or SVG icon in the File Explorer and
|
||||
<data name="ColorPicker_ColorFormat_ToggleSwitch.AutomationProperties.Name" xml:space="preserve">
|
||||
<value>Show format in editor</value>
|
||||
</data>
|
||||
<data name="PowerLauncher_SearchList.PlaceholderText" xml:space="preserve">
|
||||
<value>Search this list</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -5,6 +5,8 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
||||
xmlns:ic="using:Microsoft.Xaml.Interactions.Core"
|
||||
xmlns:i="using:Microsoft.Xaml.Interactivity"
|
||||
x:Class="Microsoft.PowerToys.Settings.UI.Views.PowerLauncherPage"
|
||||
xmlns:controls="using:Microsoft.PowerToys.Settings.UI.Controls"
|
||||
xmlns:converters="using:Microsoft.Toolkit.Uwp.UI.Converters"
|
||||
@@ -24,7 +26,7 @@
|
||||
|
||||
<StackPanel Orientation="Vertical">
|
||||
<ToggleSwitch x:Uid="PowerLauncher_EnablePowerLauncher"
|
||||
IsOn="{x:Bind Mode=TwoWay, Path=ViewModel.EnablePowerLauncher}"/>
|
||||
IsOn="{x:Bind Mode=TwoWay, Path=ViewModel.EnablePowerLauncher}" />
|
||||
|
||||
<TextBlock x:Uid="Shortcuts"
|
||||
Style="{StaticResource SettingsGroupTitleStyle}"
|
||||
@@ -177,6 +179,17 @@
|
||||
Opacity="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher, Converter={StaticResource ModuleEnabledToOpacityConverter}}"
|
||||
TextWrapping="Wrap"/>
|
||||
|
||||
<AutoSuggestBox x:Uid="PowerLauncher_SearchList"
|
||||
QueryIcon="Find"
|
||||
Text="{x:Bind ViewModel.SearchText, Mode=TwoWay}"
|
||||
Margin="{StaticResource SmallTopMargin}">
|
||||
<i:Interaction.Behaviors>
|
||||
<ic:EventTriggerBehavior EventName="TextChanged">
|
||||
<ic:InvokeCommandAction Command="{x:Bind ViewModel.SearchPluginsCommand}" />
|
||||
</ic:EventTriggerBehavior>
|
||||
</i:Interaction.Behaviors>
|
||||
</AutoSuggestBox>
|
||||
|
||||
<TextBlock x:Uid="Run_AllPluginsDisabled"
|
||||
Foreground="{ThemeResource SystemControlErrorTextForegroundBrush}"
|
||||
Visibility="{x:Bind ViewModel.ShowAllPluginsDisabledWarning, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"
|
||||
@@ -187,8 +200,8 @@
|
||||
Visibility="{x:Bind ViewModel.ShowPluginsLoadingMessage, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"
|
||||
TextWrapping="Wrap"
|
||||
Margin="{StaticResource SmallTopMargin}"/>
|
||||
|
||||
<ListView ItemsSource="{x:Bind Path=ViewModel.Plugins, Mode=OneWay}"
|
||||
MinHeight="512"
|
||||
IsItemClickEnabled="True"
|
||||
SelectionChanged="PluginsListView_SelectionChanged"
|
||||
x:Name="PluginsListView"
|
||||
|
||||
Reference in New Issue
Block a user