Skip to content

Commit 5dd9e8d

Browse files
committed
Add plugin search delay settings panel
1 parent fc4b5c9 commit 5dd9e8d

File tree

9 files changed

+100
-7
lines changed

9 files changed

+100
-7
lines changed

Flow.Launcher.Infrastructure/UserSettings/PluginSettings.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public void UpdatePluginSettings(List<PluginMetadata> metadatas)
5151
}
5252
metadata.Disabled = settings.Disabled;
5353
metadata.Priority = settings.Priority;
54+
metadata.SearchDelayTime = settings.SearchDelayTime;
5455
}
5556
else
5657
{
@@ -59,9 +60,10 @@ public void UpdatePluginSettings(List<PluginMetadata> metadatas)
5960
ID = metadata.ID,
6061
Name = metadata.Name,
6162
Version = metadata.Version,
62-
ActionKeywords = metadata.ActionKeywords,
63+
ActionKeywords = metadata.ActionKeywords,
6364
Disabled = metadata.Disabled,
64-
Priority = metadata.Priority
65+
Priority = metadata.Priority,
66+
SearchDelayTime = metadata.SearchDelayTime,
6567
};
6668
}
6769
}
@@ -74,6 +76,7 @@ public class Plugin
7476
public string Version { get; set; }
7577
public List<string> ActionKeywords { get; set; } // a reference of the action keywords from plugin manager
7678
public int Priority { get; set; }
79+
public int SearchDelayTime { get; set; }
7780

7881
/// <summary>
7982
/// Used only to save the state of the plugin in settings

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,18 @@ public bool SearchQueryResultsWithDelay
287287
}
288288
public int SearchInputDelay { get; set; } = 120;
289289

290+
[JsonIgnore]
291+
public List<int> SearchInputDelayRange { get; } = new()
292+
{
293+
30, 60, 90, 120, 150, 180, 210, 240, 270, 300
294+
};
295+
296+
[JsonIgnore]
297+
public List<int> PluginSearchInputDelayRange { get; } = new()
298+
{
299+
0, 30, 60, 90, 120, 150
300+
};
301+
290302
[JsonConverter(typeof(JsonStringEnumConverter))]
291303
public SearchWindowScreens SearchWindowScreen { get; set; } = SearchWindowScreens.Cursor;
292304

Flow.Launcher.Plugin/PluginMetadata.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ internal set
3434

3535
public List<string> ActionKeywords { get; set; }
3636

37+
public int SearchDelayTime { get; set; }
38+
3739
public string IcoPath { get; set;}
3840

3941
public override string ToString()

Flow.Launcher/Languages/en.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
<system:String x:Key="currentActionKeywords">Current action keyword</system:String>
125125
<system:String x:Key="newActionKeyword">New action keyword</system:String>
126126
<system:String x:Key="actionKeywordsTooltip">Change Action Keywords</system:String>
127+
<system:String x:Key="pluginSearchDelayTooltip">Change Seach Delay Time</system:String>
127128
<system:String x:Key="currentPriority">Current Priority</system:String>
128129
<system:String x:Key="newPriority">New Priority</system:String>
129130
<system:String x:Key="priority">Priority</system:String>

Flow.Launcher/Resources/Controls/InstalledPluginDisplay.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@
9595
<StackPanel>
9696
<ContentControl Content="{Binding BottomPart1}" />
9797

98+
<ContentControl Content="{Binding BottomPart2}" />
99+
98100
<Border
99101
BorderThickness="0 1 0 0"
100102
BorderBrush="{DynamicResource Color03B}"
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<UserControl
2+
x:Class="Flow.Launcher.Resources.Controls.InstalledPluginSearchDelay"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7+
xmlns:viewModel="clr-namespace:Flow.Launcher.ViewModel"
8+
d:DataContext="{d:DesignInstance viewModel:PluginViewModel}"
9+
d:DesignHeight="300"
10+
d:DesignWidth="300"
11+
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+
<DockPanel Margin="22 0 18 0" VerticalAlignment="Center">
21+
<TextBlock
22+
Margin="48 0 10 0"
23+
DockPanel.Dock="Left"
24+
Style="{StaticResource Glyph}">
25+
&#xE916;
26+
</TextBlock>
27+
<TextBlock
28+
HorizontalAlignment="Left"
29+
VerticalAlignment="Center"
30+
DockPanel.Dock="Left"
31+
Style="{DynamicResource SettingTitleLabel}"
32+
Text="{DynamicResource searchDelayTime}" />
33+
<ComboBox
34+
Width="100"
35+
Height="34"
36+
Margin="5 0 0 0"
37+
HorizontalAlignment="Right"
38+
Cursor="Hand"
39+
DockPanel.Dock="Right"
40+
FontWeight="Bold"
41+
ItemsSource="{Binding PluginSearchInputDelayRange}"
42+
SelectedItem="{Binding PluginSearchDelayTime}"
43+
ToolTip="{DynamicResource pluginSearchDelayTooltip}" />
44+
</DockPanel>
45+
</Border>
46+
</UserControl>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System.Windows.Controls;
2+
3+
namespace Flow.Launcher.Resources.Controls;
4+
5+
public partial class InstalledPluginSearchDelay : UserControl
6+
{
7+
public InstalledPluginSearchDelay()
8+
{
9+
InitializeComponent();
10+
}
11+
}

Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,7 @@ public bool PortableMode
139139
}
140140
}
141141

142-
public IEnumerable<int> SearchInputDelayRange => new List<int>()
143-
{
144-
30, 60, 90, 120, 150, 180, 210, 240, 270, 300
145-
};
142+
public IEnumerable<int> SearchInputDelayRange => Settings.SearchInputDelayRange;
146143

147144
public List<LastQueryModeData> LastQueryModes { get; } =
148145
DropdownDataGeneric<LastQueryMode>.GetValues<LastQueryModeData>("LastQuery");

Flow.Launcher/ViewModel/PluginViewModel.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
using CommunityToolkit.Mvvm.Input;
99
using Flow.Launcher.Core.Resource;
1010
using Flow.Launcher.Resources.Controls;
11+
using System.Collections.Generic;
12+
using CommunityToolkit.Mvvm.DependencyInjection;
13+
using Flow.Launcher.Infrastructure.UserSettings;
1114

1215
namespace Flow.Launcher.ViewModel
1316
{
@@ -81,14 +84,30 @@ public bool IsExpanded
8184
}
8285
}
8386

87+
public IEnumerable<int> PluginSearchInputDelayRange { get; } =
88+
Ioc.Default.GetRequiredService<Settings>().PluginSearchInputDelayRange;
89+
90+
public int PluginSearchDelayTime
91+
{
92+
get => PluginPair.Metadata.SearchDelayTime;
93+
set
94+
{
95+
PluginPair.Metadata.SearchDelayTime = value;
96+
PluginSettingsObject.SearchDelayTime = value;
97+
}
98+
}
99+
84100
private Control _settingControl;
85101
private bool _isExpanded;
86102

87103
private Control _bottomPart1;
88104
public Control BottomPart1 => IsExpanded ? _bottomPart1 ??= new InstalledPluginDisplayKeyword() : null;
89105

90106
private Control _bottomPart2;
91-
public Control BottomPart2 => IsExpanded ? _bottomPart2 ??= new InstalledPluginDisplayBottomData() : null;
107+
public Control BottomPart2 => IsExpanded ? _bottomPart2 ??= new InstalledPluginSearchDelay() : null;
108+
109+
private Control _bottomPart3;
110+
public Control BottomPart3 => IsExpanded ? _bottomPart3 ??= new InstalledPluginDisplayBottomData() : null;
92111

93112
public bool HasSettingControl => PluginPair.Plugin is ISettingProvider && (PluginPair.Plugin is not JsonRPCPluginBase jsonRPCPluginBase || jsonRPCPluginBase.NeedCreateSettingPanel());
94113
public Control SettingControl

0 commit comments

Comments
 (0)