diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml
index 2f5c2e5a9..ae930db70 100644
--- a/Flow.Launcher/Languages/en.xaml
+++ b/Flow.Launcher/Languages/en.xaml
@@ -365,6 +365,12 @@
Completed successfully
Enter the action keywords you like to use to start the plugin and use whitespace to divide them. Use * if you don't want to specify any, and the plugin will be triggered without any action keywords.
+
+ Search Delay Speed Setting
+ Select the search delay speed you like to use for the plugin. Select Default if you don't want to specify any, and the plugin will use default search delay speed.
+ Current search delay speed
+ New search delay speed
+
Custom Query Hotkey
Press a custom hotkey to open Flow Launcher and input the specified query automatically.
diff --git a/Flow.Launcher/SearchDelaySpeedWindow.xaml b/Flow.Launcher/SearchDelaySpeedWindow.xaml
new file mode 100644
index 000000000..1813ff6ab
--- /dev/null
+++ b/Flow.Launcher/SearchDelaySpeedWindow.xaml
@@ -0,0 +1,138 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Flow.Launcher/SearchDelaySpeedWindow.xaml.cs b/Flow.Launcher/SearchDelaySpeedWindow.xaml.cs
new file mode 100644
index 000000000..5889a1280
--- /dev/null
+++ b/Flow.Launcher/SearchDelaySpeedWindow.xaml.cs
@@ -0,0 +1,55 @@
+using System.Linq;
+using System.Windows;
+using Flow.Launcher.Plugin;
+using Flow.Launcher.SettingPages.ViewModels;
+using Flow.Launcher.ViewModel;
+using static Flow.Launcher.SettingPages.ViewModels.SettingsPaneGeneralViewModel;
+
+namespace Flow.Launcher;
+
+public partial class SearchDelaySpeedWindow : Window
+{
+ private readonly PluginViewModel _pluginViewModel;
+
+ public SearchDelaySpeedWindow(PluginViewModel pluginViewModel)
+ {
+ InitializeComponent();
+ _pluginViewModel = pluginViewModel;
+ }
+
+ private void SearchDelaySpeed_OnLoaded(object sender, RoutedEventArgs e)
+ {
+ tbOldSearchDelaySpeed.Text = _pluginViewModel.SearchDelaySpeedText;
+ var searchDelaySpeeds = DropdownDataGeneric.GetValues("SearchDelaySpeed");
+ SearchDelaySpeedData selected = null;
+ // Because default value is SearchDelaySpeeds.Slow, we need to get selected value before adding default value
+ if (_pluginViewModel.PluginSearchDelay != null)
+ {
+ selected = searchDelaySpeeds.FirstOrDefault(x => x.Value == _pluginViewModel.PluginSearchDelay);
+ }
+ // Add default value to the beginning of the list
+ // This value should be null
+ searchDelaySpeeds.Insert(0, new SearchDelaySpeedData { Display = App.API.GetTranslation(PluginViewModel.DefaultLocalizationKey), LocalizationKey = PluginViewModel.DefaultLocalizationKey });
+ selected ??= searchDelaySpeeds.FirstOrDefault();
+ tbDelay.ItemsSource = searchDelaySpeeds;
+ tbDelay.SelectedItem = selected;
+ tbDelay.Focus();
+ }
+
+ private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
+ {
+ Close();
+ }
+
+ private void btnDone_OnClick(object sender, RoutedEventArgs _)
+ {
+ // Update search delay speed
+ var selected = tbDelay.SelectedItem as SearchDelaySpeedData;
+ SearchDelaySpeeds? changedValue = selected?.LocalizationKey != PluginViewModel.DefaultLocalizationKey ? selected.Value : null;
+ _pluginViewModel.PluginSearchDelay = changedValue;
+
+ // Update search delay speed text and close window
+ _pluginViewModel.OnSearchDelaySpeedChanged();
+ Close();
+ }
+}
diff --git a/Flow.Launcher/SettingPages/ViewModels/DropdownDataGeneric.cs b/Flow.Launcher/SettingPages/ViewModels/DropdownDataGeneric.cs
index 15a814436..c8c119e94 100644
--- a/Flow.Launcher/SettingPages/ViewModels/DropdownDataGeneric.cs
+++ b/Flow.Launcher/SettingPages/ViewModels/DropdownDataGeneric.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using Flow.Launcher.Core.Resource;
using Flow.Launcher.Plugin;
namespace Flow.Launcher.SettingPages.ViewModels;
@@ -9,7 +8,7 @@ public class DropdownDataGeneric : BaseModel where TValue : Enum
{
public string Display { get; set; }
public TValue Value { get; private init; }
- private string LocalizationKey { get; init; }
+ public string LocalizationKey { get; set; }
public static List GetValues
(string keyPrefix) where TR : DropdownDataGeneric, new()
{
@@ -19,7 +18,7 @@ public class DropdownDataGeneric : BaseModel where TValue : Enum
foreach (var value in enumValues)
{
var key = keyPrefix + value;
- var display = InternationalizationManager.Instance.GetTranslation(key);
+ var display = App.API.GetTranslation(key);
data.Add(new TR { Display = display, Value = value, LocalizationKey = key });
}
@@ -30,7 +29,7 @@ public class DropdownDataGeneric : BaseModel where TValue : Enum
{
foreach (var item in options)
{
- item.Display = InternationalizationManager.Instance.GetTranslation(item.LocalizationKey);
+ item.Display = App.API.GetTranslation(item.LocalizationKey);
}
}
}
diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs
index 4a729b578..909011579 100644
--- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs
+++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs
@@ -150,7 +150,7 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
public SearchDelaySpeedData SearchDelaySpeed
{
get => SearchDelaySpeeds.FirstOrDefault(x => x.Value == Settings.SearchDelaySpeed) ??
- SearchDelaySpeeds.FirstOrDefault(x => x.Value == Flow.Launcher.Plugin.SearchDelaySpeeds.Medium) ??
+ SearchDelaySpeeds.FirstOrDefault(x => x.Value == Plugin.SearchDelaySpeeds.Medium) ??
SearchDelaySpeeds.FirstOrDefault();
set
{
diff --git a/Flow.Launcher/ViewModel/PluginViewModel.cs b/Flow.Launcher/ViewModel/PluginViewModel.cs
index e63336235..7ca776512 100644
--- a/Flow.Launcher/ViewModel/PluginViewModel.cs
+++ b/Flow.Launcher/ViewModel/PluginViewModel.cs
@@ -13,6 +13,8 @@ namespace Flow.Launcher.ViewModel
{
public partial class PluginViewModel : BaseModel
{
+ public const string DefaultLocalizationKey = "default";
+
private readonly PluginPair _pluginPair;
public PluginPair PluginPair
{
@@ -127,7 +129,7 @@ namespace Flow.Launcher.ViewModel
PluginPair.Metadata.AvgQueryTime + "ms";
public string ActionKeywordsText => string.Join(Query.ActionKeywordSeparator, PluginPair.Metadata.ActionKeywords);
public int Priority => PluginPair.Metadata.Priority;
- public string SearchDelaySpeedText => PluginPair.Metadata.SearchDelaySpeed == null ? App.API.GetTranslation("default") : App.API.GetTranslation($"SearchDelaySpeed{PluginPair.Metadata.SearchDelaySpeed}");
+ public string SearchDelaySpeedText => PluginPair.Metadata.SearchDelaySpeed == null ? App.API.GetTranslation(DefaultLocalizationKey) : App.API.GetTranslation($"SearchDelaySpeed{PluginPair.Metadata.SearchDelaySpeed}");
public Infrastructure.UserSettings.Plugin PluginSettingsObject{ get; init; }
public void OnActionKeywordsChanged()
@@ -135,6 +137,11 @@ namespace Flow.Launcher.ViewModel
OnPropertyChanged(nameof(ActionKeywordsText));
}
+ public void OnSearchDelaySpeedChanged()
+ {
+ OnPropertyChanged(nameof(SearchDelaySpeedText));
+ }
+
public void ChangePriority(int newPriority)
{
PluginPair.Metadata.Priority = newPriority;
@@ -180,8 +187,8 @@ namespace Flow.Launcher.ViewModel
[RelayCommand]
private void SetSearchDelaySpeed()
{
- /*var searchDelaySpeedWindow = new SearchDelaySpeedWindow(this);
- searchDelaySpeedWindow.ShowDialog();*/
+ var searchDelaySpeedWindow = new SearchDelaySpeedWindow(this);
+ searchDelaySpeedWindow.ShowDialog();
}
}
}