mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Add Setting Filter
This commit is contained in:
parent
5fa244c806
commit
0136c570fa
5 changed files with 172 additions and 56 deletions
|
|
@ -1,6 +1,23 @@
|
|||
namespace Flow.Launcher.Converters;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
public class StringEqualityToVisibilityConverter
|
||||
namespace Flow.Launcher.Converters
|
||||
{
|
||||
|
||||
public class StringEqualityToVisibilityConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null || parameter == null)
|
||||
return Visibility.Collapsed;
|
||||
|
||||
return value.ToString() == parameter.ToString() ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,10 +7,14 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:ui="http://schemas.modernwpf.com/2019"
|
||||
xmlns:viewModel="clr-namespace:Flow.Launcher.ViewModel"
|
||||
xmlns:converters="clr-namespace:Flow.Launcher.Converters"
|
||||
d:DataContext="{d:DesignInstance viewModel:PluginViewModel}"
|
||||
d:DesignHeight="300"
|
||||
d:DesignWidth="300"
|
||||
mc:Ignorable="d">
|
||||
<UserControl.Resources>
|
||||
<converters:StringEqualityToVisibilityConverter x:Key="StringEqualityToVisibilityConverter" />
|
||||
</UserControl.Resources>
|
||||
<Expander
|
||||
Padding="0"
|
||||
BorderThickness="0"
|
||||
|
|
@ -91,36 +95,48 @@
|
|||
<StackPanel
|
||||
x:Name="PriorityControl"
|
||||
Orientation="Horizontal"
|
||||
Visibility="Visible">
|
||||
Visibility="{Binding DataContext.CurrentDisplayMode,
|
||||
RelativeSource={RelativeSource AncestorType=ListBox},
|
||||
Converter={StaticResource StringEqualityToVisibilityConverter},
|
||||
ConverterParameter=Priority}">
|
||||
<TextBlock
|
||||
Margin="0 0 8 0"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="13"
|
||||
Foreground="{DynamicResource Color08B}"
|
||||
Text="{DynamicResource priority}" />
|
||||
Margin="0 0 8 0"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="13"
|
||||
Foreground="{DynamicResource Color08B}"
|
||||
Text="{DynamicResource priority}" />
|
||||
<ui:NumberBox
|
||||
Margin="0 0 8 0"
|
||||
Maximum="999"
|
||||
Minimum="0"
|
||||
Value="{Binding Priority, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
SpinButtonPlacementMode="Inline" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel
|
||||
x:Name="SearchDelayControl"
|
||||
Orientation="Horizontal"
|
||||
Visibility="Collapsed">
|
||||
Visibility="{Binding DataContext.CurrentDisplayMode,
|
||||
RelativeSource={RelativeSource AncestorType=ListBox},
|
||||
Converter={StaticResource StringEqualityToVisibilityConverter},
|
||||
ConverterParameter=SearchDelay}">
|
||||
<TextBox
|
||||
Width="120"
|
||||
Height="34"
|
||||
Margin="0 0 8 0" />
|
||||
</StackPanel>
|
||||
|
||||
<ui:ToggleSwitch
|
||||
x:Name="OnOffControl"
|
||||
Margin="0 0 8 0"
|
||||
IsOn="{Binding PluginState}"
|
||||
OffContent="{DynamicResource disable}"
|
||||
OnContent="{DynamicResource enable}"
|
||||
Visibility="Collapsed" />
|
||||
</StackPanel>
|
||||
Visibility="{Binding DataContext.CurrentDisplayMode,
|
||||
RelativeSource={RelativeSource AncestorType=ListBox},
|
||||
Converter={StaticResource StringEqualityToVisibilityConverter},
|
||||
ConverterParameter=OnOff}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Expander.Header>
|
||||
|
|
|
|||
|
|
@ -14,6 +14,75 @@ public class SettingsPanePluginsViewModel : BaseModel
|
|||
{
|
||||
private readonly Settings _settings;
|
||||
|
||||
private bool _isOnOffSelected = true;
|
||||
public bool IsOnOffSelected
|
||||
{
|
||||
get => _isOnOffSelected;
|
||||
set
|
||||
{
|
||||
if (_isOnOffSelected != value)
|
||||
{
|
||||
_isOnOffSelected = value;
|
||||
OnPropertyChanged(nameof(IsOnOffSelected));
|
||||
UpdateDisplayMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isPrioritySelected;
|
||||
public bool IsPrioritySelected
|
||||
{
|
||||
get => _isPrioritySelected;
|
||||
set
|
||||
{
|
||||
if (_isPrioritySelected != value)
|
||||
{
|
||||
_isPrioritySelected = value;
|
||||
OnPropertyChanged(nameof(IsPrioritySelected));
|
||||
UpdateDisplayMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isSearchDelaySelected;
|
||||
public bool IsSearchDelaySelected
|
||||
{
|
||||
get => _isSearchDelaySelected;
|
||||
set
|
||||
{
|
||||
if (_isSearchDelaySelected != value)
|
||||
{
|
||||
_isSearchDelaySelected = value;
|
||||
OnPropertyChanged(nameof(IsSearchDelaySelected));
|
||||
UpdateDisplayMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string _currentDisplayMode = "OnOff";
|
||||
public string CurrentDisplayMode
|
||||
{
|
||||
get => _currentDisplayMode;
|
||||
set
|
||||
{
|
||||
if (_currentDisplayMode != value)
|
||||
{
|
||||
_currentDisplayMode = value;
|
||||
OnPropertyChanged(nameof(CurrentDisplayMode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateDisplayMode()
|
||||
{
|
||||
if (IsOnOffSelected)
|
||||
CurrentDisplayMode = "OnOff";
|
||||
else if (IsPrioritySelected)
|
||||
CurrentDisplayMode = "Priority";
|
||||
else if (IsSearchDelaySelected)
|
||||
CurrentDisplayMode = "SearchDelay";
|
||||
}
|
||||
|
||||
public SettingsPanePluginsViewModel(Settings settings)
|
||||
{
|
||||
_settings = settings;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
xmlns:ui="http://schemas.modernwpf.com/2019"
|
||||
xmlns:converters="clr-namespace:Flow.Launcher.Converters"
|
||||
xmlns:viewModels="clr-namespace:Flow.Launcher.SettingPages.ViewModels"
|
||||
xmlns:cc="clr-namespace:Flow.Launcher.Resources.Controls"
|
||||
Title="Plugins"
|
||||
|
|
@ -17,6 +18,7 @@
|
|||
mc:Ignorable="d">
|
||||
<ui:Page.Resources>
|
||||
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
|
||||
<converters:StringEqualityToVisibilityConverter x:Key="StringEqualityToVisibilityConverter" />
|
||||
</ui:Page.Resources>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
|
|
@ -31,51 +33,51 @@
|
|||
Style="{StaticResource PageTitle}"
|
||||
Text="{DynamicResource plugins}"
|
||||
TextAlignment="Left" />
|
||||
<TextBox
|
||||
Name="PluginFilterTextbox"
|
||||
Width="150"
|
||||
Height="34"
|
||||
Margin="0 5 26 0"
|
||||
HorizontalAlignment="Right"
|
||||
ContextMenu="{StaticResource TextBoxContextMenu}"
|
||||
<StackPanel
|
||||
DockPanel.Dock="Right"
|
||||
FontSize="14"
|
||||
Text="{Binding FilterText, UpdateSourceTrigger=PropertyChanged}"
|
||||
TextAlignment="Left"
|
||||
ToolTip="{DynamicResource searchpluginToolTip}"
|
||||
ToolTipService.InitialShowDelay="200"
|
||||
ToolTipService.Placement="Top">
|
||||
<TextBox.Style>
|
||||
<Style BasedOn="{StaticResource DefaultTextBoxStyle}" TargetType="TextBox">
|
||||
<Style.Resources>
|
||||
<VisualBrush
|
||||
x:Key="CueBannerBrush"
|
||||
AlignmentX="Left"
|
||||
AlignmentY="Center"
|
||||
Stretch="None">
|
||||
<VisualBrush.Visual>
|
||||
<Label
|
||||
Padding="10 0 0 0"
|
||||
Content="{DynamicResource searchplugin}"
|
||||
Foreground="{DynamicResource CustomContextDisabled}" />
|
||||
</VisualBrush.Visual>
|
||||
</VisualBrush>
|
||||
</Style.Resources>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="Text" Value="{x:Static sys:String.Empty}">
|
||||
<Setter Property="Background" Value="{StaticResource CueBannerBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="Text" Value="{x:Null}">
|
||||
<Setter Property="Background" Value="{StaticResource CueBannerBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsKeyboardFocused" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource Color02B}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</TextBox.Style>
|
||||
</TextBox>
|
||||
Orientation="Horizontal"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center">
|
||||
<RadioButton
|
||||
x:Name="OnOffToggle"
|
||||
Content="OnOff"
|
||||
Height="34"
|
||||
Margin="0 0 8 0"
|
||||
IsChecked="{Binding IsOnOffSelected, Mode=TwoWay}"
|
||||
GroupName="PluginToggleGroup"
|
||||
Style="{StaticResource {x:Type ToggleButton}}" />
|
||||
<RadioButton
|
||||
x:Name="PriorityToggle"
|
||||
Content="Priority"
|
||||
Height="34"
|
||||
Margin="0 0 8 0"
|
||||
IsChecked="{Binding IsPrioritySelected, Mode=TwoWay}"
|
||||
GroupName="PluginToggleGroup"
|
||||
Style="{StaticResource {x:Type ToggleButton}}" />
|
||||
<RadioButton
|
||||
x:Name="SearchDelayToggle"
|
||||
Content="Search Delay"
|
||||
Height="34"
|
||||
Margin="0 0 8 0"
|
||||
IsChecked="{Binding IsSearchDelaySelected, Mode=TwoWay}"
|
||||
GroupName="PluginToggleGroup"
|
||||
Style="{StaticResource {x:Type ToggleButton}}" />
|
||||
<TextBox
|
||||
Name="PluginFilterTextbox"
|
||||
Width="150"
|
||||
Height="34"
|
||||
Margin="0 0 26 0"
|
||||
ContextMenu="{StaticResource TextBoxContextMenu}"
|
||||
FontSize="14"
|
||||
Text="{Binding FilterText, UpdateSourceTrigger=PropertyChanged}"
|
||||
TextAlignment="Left"
|
||||
ToolTip="{DynamicResource searchpluginToolTip}"
|
||||
ToolTipService.InitialShowDelay="200"
|
||||
ToolTipService.Placement="Top">
|
||||
</TextBox>
|
||||
</StackPanel>
|
||||
</DockPanel>
|
||||
|
||||
<Border Grid.Row="1" Grid.Column="0" Background="{DynamicResource Color01B}">
|
||||
<ListBox
|
||||
Margin="5 0 7 10"
|
||||
|
|
|
|||
|
|
@ -127,7 +127,19 @@ namespace Flow.Launcher.ViewModel
|
|||
App.API.GetTranslation("plugin_query_time") + " " +
|
||||
PluginPair.Metadata.AvgQueryTime + "ms";
|
||||
public string ActionKeywordsText => string.Join(Query.ActionKeywordSeparator, PluginPair.Metadata.ActionKeywords);
|
||||
public int Priority => PluginPair.Metadata.Priority;
|
||||
//public int Priority => PluginPair.Metadata.Priority;
|
||||
private int _priority;
|
||||
public int Priority
|
||||
{
|
||||
get => PluginPair.Metadata.Priority;
|
||||
set
|
||||
{
|
||||
if (PluginPair.Metadata.Priority != value)
|
||||
{
|
||||
ChangePriority(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
public string SearchDelayTimeText => PluginPair.Metadata.SearchDelayTime == null ?
|
||||
App.API.GetTranslation("default") :
|
||||
App.API.GetTranslation($"SearchDelayTime{PluginPair.Metadata.SearchDelayTime}");
|
||||
|
|
|
|||
Loading…
Reference in a new issue