Skip to content

Commit f7b1190

Browse files
committed
Add global search panel
1 parent afce702 commit f7b1190

File tree

4 files changed

+105
-37
lines changed

4 files changed

+105
-37
lines changed

Flow.Launcher/ActionKeywords.xaml.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,25 @@ private void ReplaceActionKeyword(string id, IReadOnlyList<string> removedAction
7777
{
7878
foreach (var actionKeyword in removedActionKeywords)
7979
{
80-
App.API.RemoveActionKeyword(id, actionKeyword);
80+
if (actionKeyword == Query.GlobalPluginWildcardSign)
81+
{
82+
pluginViewModel.GlobalSearch = false;
83+
}
84+
else
85+
{
86+
App.API.RemoveActionKeyword(id, actionKeyword);
87+
}
8188
}
8289
foreach (var actionKeyword in addedActionKeywords)
8390
{
84-
App.API.AddActionKeyword(id, actionKeyword);
91+
if (actionKeyword == Query.GlobalPluginWildcardSign)
92+
{
93+
pluginViewModel.GlobalSearch = true;
94+
}
95+
else
96+
{
97+
App.API.AddActionKeyword(id, actionKeyword);
98+
}
8599
}
86100

87101
// Update action keywords text and close window

Flow.Launcher/Languages/en.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
<system:String x:Key="disable">Off</system:String>
115115
<system:String x:Key="actionKeywordsTitle">Action keyword Setting</system:String>
116116
<system:String x:Key="actionKeywords">Action keyword</system:String>
117+
<system:String x:Key="globalSearch">Global search</system:String>
117118
<system:String x:Key="currentActionKeywords">Current action keyword</system:String>
118119
<system:String x:Key="newActionKeyword">New action keyword</system:String>
119120
<system:String x:Key="actionKeywordsTooltip">Change Action Keywords</system:String>

Flow.Launcher/Resources/Controls/InstalledPluginDisplayKeyword.xaml

Lines changed: 71 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,80 @@
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7+
xmlns:ui="http://schemas.modernwpf.com/2019"
78
xmlns:viewModel="clr-namespace:Flow.Launcher.ViewModel"
89
d:DataContext="{d:DesignInstance viewModel:PluginViewModel}"
910
d:DesignHeight="300"
1011
d:DesignWidth="300"
1112
mc:Ignorable="d">
12-
<Border
13-
Width="Auto"
14-
Height="52"
15-
Margin="0"
16-
Padding="0"
17-
BorderThickness="0 1 0 0"
18-
CornerRadius="0"
19-
Style="{DynamicResource SettingGroupBox}"
20-
Visibility="{Binding ActionKeywordsVisibility}">
21-
<DockPanel Margin="22 0 18 0" VerticalAlignment="Center">
22-
<TextBlock
23-
Margin="48 0 10 0"
24-
DockPanel.Dock="Left"
25-
Style="{StaticResource Glyph}">
26-
&#xe819;
27-
</TextBlock>
28-
<TextBlock
29-
HorizontalAlignment="Left"
30-
VerticalAlignment="Center"
31-
DockPanel.Dock="Left"
32-
Style="{DynamicResource SettingTitleLabel}"
33-
Text="{DynamicResource actionKeywords}" />
34-
<Button
35-
Width="100"
36-
Height="34"
37-
Margin="5 0 0 0"
38-
HorizontalAlignment="Right"
39-
Command="{Binding SetActionKeywordsCommand}"
40-
Content="{Binding ActionKeywordsText}"
41-
Cursor="Hand"
42-
DockPanel.Dock="Right"
43-
FontWeight="Bold"
44-
ToolTip="{DynamicResource actionKeywordsTooltip}" />
45-
</DockPanel>
46-
</Border>
13+
<StackPanel Orientation="Vertical">
14+
<Border
15+
Width="Auto"
16+
Height="52"
17+
Margin="0"
18+
Padding="0"
19+
BorderThickness="0 1 0 0"
20+
CornerRadius="0"
21+
Style="{DynamicResource SettingGroupBox}"
22+
Visibility="{Binding ActionKeywordsVisibility}">
23+
<DockPanel Margin="22 0 18 0" VerticalAlignment="Center">
24+
<TextBlock
25+
Margin="48 0 10 0"
26+
DockPanel.Dock="Left"
27+
Style="{StaticResource Glyph}">
28+
&#xe819;
29+
</TextBlock>
30+
<TextBlock
31+
HorizontalAlignment="Left"
32+
VerticalAlignment="Center"
33+
DockPanel.Dock="Left"
34+
Style="{DynamicResource SettingTitleLabel}"
35+
Text="{DynamicResource actionKeywords}" />
36+
<Button
37+
Width="100"
38+
Height="34"
39+
Margin="5 0 0 0"
40+
HorizontalAlignment="Right"
41+
Command="{Binding SetActionKeywordsCommand}"
42+
Content="{Binding ActionKeywordsText}"
43+
Cursor="Hand"
44+
DockPanel.Dock="Right"
45+
FontWeight="Bold"
46+
ToolTip="{DynamicResource actionKeywordsTooltip}" />
47+
</DockPanel>
48+
</Border>
49+
<Border
50+
Width="Auto"
51+
Height="52"
52+
Margin="0"
53+
Padding="0"
54+
BorderThickness="0 1 0 0"
55+
CornerRadius="0"
56+
Style="{DynamicResource SettingGroupBox}"
57+
Visibility="{Binding ActionKeywordsVisibility}">
58+
<DockPanel Margin="22 0 18 0" VerticalAlignment="Center">
59+
<TextBlock
60+
Margin="48 0 10 0"
61+
DockPanel.Dock="Left"
62+
Style="{StaticResource Glyph}">
63+
&#xE774;
64+
</TextBlock>
65+
<TextBlock
66+
HorizontalAlignment="Left"
67+
VerticalAlignment="Center"
68+
DockPanel.Dock="Left"
69+
Style="{DynamicResource SettingTitleLabel}"
70+
Text="{DynamicResource globalSearch}" />
71+
<ui:ToggleSwitch
72+
Height="34"
73+
Margin="5 0 0 0"
74+
HorizontalAlignment="Right"
75+
Cursor="Hand"
76+
DockPanel.Dock="Right"
77+
IsOn="{Binding GlobalSearch}"
78+
OffContent="{DynamicResource disable}"
79+
OnContent="{DynamicResource enable}" />
80+
</DockPanel>
81+
</Border>
82+
</StackPanel>
4783
</UserControl>

Flow.Launcher/ViewModel/PluginViewModel.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,23 @@ public Control SettingControl
105105
public string Version => InternationalizationManager.Instance.GetTranslation("plugin_query_version") + " " + PluginPair.Metadata.Version;
106106
public string InitAndQueryTime => InternationalizationManager.Instance.GetTranslation("plugin_init_time") + " " + PluginPair.Metadata.InitTime + "ms, " + InternationalizationManager.Instance.GetTranslation("plugin_query_time") + " " + PluginPair.Metadata.AvgQueryTime + "ms";
107107
public string ActionKeywordsText => string.Join(Query.ActionKeywordSeparator, PluginPair.Metadata.ActionKeywords);
108+
public bool GlobalSearch
109+
{
110+
get => PluginPair.Metadata.ActionKeywords.Contains(Query.GlobalPluginWildcardSign);
111+
set
112+
{
113+
if (value)
114+
{
115+
App.API.AddActionKeyword(PluginPair.Metadata.ID, Query.GlobalPluginWildcardSign);
116+
}
117+
else
118+
{
119+
App.API.RemoveActionKeyword(PluginPair.Metadata.ID, Query.GlobalPluginWildcardSign);
120+
}
121+
OnPropertyChanged();
122+
OnActionKeywordsChanged();
123+
}
124+
}
108125
public int Priority => PluginPair.Metadata.Priority;
109126
public Infrastructure.UserSettings.Plugin PluginSettingsObject { get; set; }
110127

0 commit comments

Comments
 (0)