From b2532fc88e09977b2c62d4eec3b8ec1ec0dd43d6 Mon Sep 17 00:00:00 2001 From: "pp.stabrawa" Date: Fri, 27 Dec 2024 12:43:43 +0100 Subject: [PATCH 001/400] Order search result by window title --- .../Main.cs | 30 ++++++++----- .../ProcessHelper.cs | 44 ++++++++++++++++++- 2 files changed, 61 insertions(+), 13 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs b/Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs index be2a2dd66..03b563c9b 100644 --- a/Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using Flow.Launcher.Infrastructure; @@ -60,30 +60,33 @@ namespace Flow.Launcher.Plugin.ProcessKiller return menuOptions; } + private record RunningProcessInfo(string ProcessName, string MainWindowTitle); + private List CreateResultsFromQuery(Query query) { string termToSearch = query.Search; - var processlist = processHelper.GetMatchingProcesses(termToSearch); - - if (!processlist.Any()) + var processList = processHelper.GetMatchingProcesses(termToSearch); + var processWithNonEmptyMainWindowTitleList = processHelper.GetProcessesWithNonEmptyWindowTitle(); + + if (!processList.Any()) { return null; } var results = new List(); - foreach (var pr in processlist) + foreach (var pr in processList) { var p = pr.Process; var path = processHelper.TryGetProcessFilename(p); results.Add(new Result() { IcoPath = path, - Title = p.ProcessName + " - " + p.Id, + Title = processWithNonEmptyMainWindowTitleList.TryGetValue(p.Id, out var mainWindowTitle) ? mainWindowTitle : p.ProcessName + " - " + p.Id, SubTitle = path, TitleHighlightData = StringMatcher.FuzzySearch(termToSearch, p.ProcessName).MatchData, Score = pr.Score, - ContextData = p.ProcessName, + ContextData = new RunningProcessInfo(p.ProcessName, mainWindowTitle), AutoCompleteText = $"{_context.CurrentPluginMetadata.ActionKeyword}{Plugin.Query.TermSeparator}{p.ProcessName}", Action = (c) => { @@ -95,22 +98,25 @@ namespace Flow.Launcher.Plugin.ProcessKiller }); } - var sortedResults = results.OrderBy(x => x.Title).ToList(); + var sortedResults = results + .OrderBy(x => string.IsNullOrEmpty(((RunningProcessInfo)x.ContextData).MainWindowTitle)) + .ThenBy(x => x.Title) + .ToList(); // When there are multiple results AND all of them are instances of the same executable // add a quick option to kill them all at the top of the results. var firstResult = sortedResults.FirstOrDefault(x => !string.IsNullOrEmpty(x.SubTitle)); - if (processlist.Count > 1 && !string.IsNullOrEmpty(termToSearch) && sortedResults.All(r => r.SubTitle == firstResult?.SubTitle)) + if (processList.Count > 1 && !string.IsNullOrEmpty(termToSearch) && sortedResults.All(r => r.SubTitle == firstResult?.SubTitle)) { sortedResults.Insert(1, new Result() { IcoPath = firstResult?.IcoPath, - Title = string.Format(_context.API.GetTranslation("flowlauncher_plugin_processkiller_kill_all"), firstResult?.ContextData), - SubTitle = string.Format(_context.API.GetTranslation("flowlauncher_plugin_processkiller_kill_all_count"), processlist.Count), + Title = string.Format(_context.API.GetTranslation("flowlauncher_plugin_processkiller_kill_all"), ((RunningProcessInfo)firstResult?.ContextData).ProcessName), + SubTitle = string.Format(_context.API.GetTranslation("flowlauncher_plugin_processkiller_kill_all_count"), processList.Count), Score = 200, Action = (c) => { - foreach (var p in processlist) + foreach (var p in processList) { processHelper.TryKill(p.Process); } diff --git a/Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessHelper.cs b/Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessHelper.cs index 0acc39fbb..5cc94dfdf 100644 --- a/Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessHelper.cs +++ b/Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessHelper.cs @@ -1,4 +1,4 @@ -using Flow.Launcher.Infrastructure; +using Flow.Launcher.Infrastructure; using Flow.Launcher.Infrastructure.Logger; using System; using System.Collections.Generic; @@ -11,6 +11,20 @@ namespace Flow.Launcher.Plugin.ProcessKiller { internal class ProcessHelper { + [DllImport("user32.dll")] + private static extern bool EnumWindows(EnumWindowsProc enumProc, IntPtr lParam); + + private delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam); + + [DllImport("user32.dll", CharSet = CharSet.Unicode)] + private static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount); + + [DllImport("user32.dll")] + private static extern bool IsWindowVisible(IntPtr hWnd); + + [DllImport("user32.dll")] + private static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId); + private readonly HashSet _systemProcessList = new HashSet() { "conhost", @@ -60,6 +74,34 @@ namespace Flow.Launcher.Plugin.ProcessKiller return processlist; } + /// + /// Returns a dictionary of process IDs and their window titles for processes that have a visible main window with a non-empty title. + /// + public Dictionary GetProcessesWithNonEmptyWindowTitle() + { + var processDict = new Dictionary(); + EnumWindows((hWnd, lParam) => + { + StringBuilder windowTitle = new StringBuilder(); + GetWindowText(hWnd, windowTitle, windowTitle.Capacity); + + if (!string.IsNullOrWhiteSpace(windowTitle.ToString()) && IsWindowVisible(hWnd)) + { + GetWindowThreadProcessId(hWnd, out var processId); + var process = Process.GetProcessById((int)processId); + + if (!processDict.ContainsKey((int)processId)) + { + processDict.Add((int)processId, windowTitle.ToString()); + } + } + + return true; + }, IntPtr.Zero); + + return processDict; + } + /// /// Returns all non-system processes whose file path matches the given processPath /// From 9880c362fd7196b2fc7792f82b533fc80a945eed Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Wed, 19 Feb 2025 23:31:26 +0800 Subject: [PATCH 002/400] Remove useless settings control & project reference --- .../Flow.Launcher.Plugin.Url.csproj | 1 - Plugins/Flow.Launcher.Plugin.Url/Main.cs | 10 +--------- .../SettingsControl.xaml | 17 ----------------- .../SettingsControl.xaml.cs | 18 ------------------ 4 files changed, 1 insertion(+), 45 deletions(-) delete mode 100644 Plugins/Flow.Launcher.Plugin.Url/SettingsControl.xaml delete mode 100644 Plugins/Flow.Launcher.Plugin.Url/SettingsControl.xaml.cs diff --git a/Plugins/Flow.Launcher.Plugin.Url/Flow.Launcher.Plugin.Url.csproj b/Plugins/Flow.Launcher.Plugin.Url/Flow.Launcher.Plugin.Url.csproj index 3db0cd0cb..6d338733e 100644 --- a/Plugins/Flow.Launcher.Plugin.Url/Flow.Launcher.Plugin.Url.csproj +++ b/Plugins/Flow.Launcher.Plugin.Url/Flow.Launcher.Plugin.Url.csproj @@ -42,7 +42,6 @@ - diff --git a/Plugins/Flow.Launcher.Plugin.Url/Main.cs b/Plugins/Flow.Launcher.Plugin.Url/Main.cs index 80425a8ff..03516636d 100644 --- a/Plugins/Flow.Launcher.Plugin.Url/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Url/Main.cs @@ -1,11 +1,10 @@ using System; using System.Collections.Generic; using System.Text.RegularExpressions; -using System.Windows.Controls; namespace Flow.Launcher.Plugin.Url { - public class Main : ISettingProvider,IPlugin, IPluginI18n + public class Main : IPlugin, IPluginI18n { //based on https://gist.github.com/dperini/729294 private const string urlPattern = "^" + @@ -43,7 +42,6 @@ namespace Flow.Launcher.Plugin.Url Regex reg = new Regex(urlPattern, RegexOptions.Compiled | RegexOptions.IgnoreCase); private PluginInitContext context; private Settings _settings; - public List Query(Query query) { @@ -82,12 +80,6 @@ namespace Flow.Launcher.Plugin.Url return new List(0); } - - public Control CreateSettingPanel() - { - return new SettingsControl(context.API,_settings); - } - public bool IsURL(string raw) { raw = raw.ToLower(); diff --git a/Plugins/Flow.Launcher.Plugin.Url/SettingsControl.xaml b/Plugins/Flow.Launcher.Plugin.Url/SettingsControl.xaml deleted file mode 100644 index 8ff7b5ab5..000000000 --- a/Plugins/Flow.Launcher.Plugin.Url/SettingsControl.xaml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - diff --git a/Plugins/Flow.Launcher.Plugin.Url/SettingsControl.xaml.cs b/Plugins/Flow.Launcher.Plugin.Url/SettingsControl.xaml.cs deleted file mode 100644 index f68d1bb2d..000000000 --- a/Plugins/Flow.Launcher.Plugin.Url/SettingsControl.xaml.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Windows.Controls; - -namespace Flow.Launcher.Plugin.Url -{ - public partial class SettingsControl : UserControl - { - private Settings _settings; - private IPublicAPI _flowlauncherAPI; - - public SettingsControl(IPublicAPI flowlauncherAPI,Settings settings) - { - InitializeComponent(); - _settings = settings; - _flowlauncherAPI = flowlauncherAPI; - - } - } -} From 6e84326f57c45cc44e6ab6a756244d277c9ef884 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Wed, 19 Feb 2025 23:43:17 +0800 Subject: [PATCH 003/400] Reassign margins --- .../Resources/Controls/InstalledPluginDisplayKeyword.xaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Flow.Launcher/Resources/Controls/InstalledPluginDisplayKeyword.xaml b/Flow.Launcher/Resources/Controls/InstalledPluginDisplayKeyword.xaml index ff2f14c4b..a88b1a731 100644 --- a/Flow.Launcher/Resources/Controls/InstalledPluginDisplayKeyword.xaml +++ b/Flow.Launcher/Resources/Controls/InstalledPluginDisplayKeyword.xaml @@ -18,9 +18,9 @@ CornerRadius="0" Style="{DynamicResource SettingGroupBox}" Visibility="{Binding ActionKeywordsVisibility}"> - +  @@ -34,7 +34,6 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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(); } } } From e9c1cffd3304867f24d2cd2f2c609998c75755d3 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Mon, 31 Mar 2025 12:58:27 +0800 Subject: [PATCH 378/400] Code quality --- .../UserSettings/Settings.cs | 24 +++---------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index ab0a364d2..fed4b667b 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -320,28 +320,10 @@ namespace Flow.Launcher.Infrastructure.UserSettings public bool LeaveCmdOpen { get; set; } public bool HideWhenDeactivated { get; set; } = true; - bool _searchQueryResultsWithDelay { get; set; } - public bool SearchQueryResultsWithDelay - { - get => _searchQueryResultsWithDelay; - set - { - _searchQueryResultsWithDelay = value; - OnPropertyChanged(); - } - } - - SearchDelaySpeeds searchDelaySpeed { get; set; } = SearchDelaySpeeds.Medium; + public bool SearchQueryResultsWithDelay { get; set; } + [JsonConverter(typeof(JsonStringEnumConverter))] - public SearchDelaySpeeds SearchDelaySpeed - { - get => searchDelaySpeed; - set - { - searchDelaySpeed = value; - OnPropertyChanged(); - } - } + public SearchDelaySpeeds SearchDelaySpeed { get; set; } = SearchDelaySpeeds.Medium; [JsonConverter(typeof(JsonStringEnumConverter))] public SearchWindowScreens SearchWindowScreen { get; set; } = SearchWindowScreens.Cursor; From dec1e77b0ce7dd31aab99661b7505d3cf8bf2a7c Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Mon, 31 Mar 2025 13:04:41 +0800 Subject: [PATCH 379/400] Improve code comments --- Flow.Launcher/SearchDelaySpeedWindow.xaml.cs | 2 +- Flow.Launcher/ViewModel/MainViewModel.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Flow.Launcher/SearchDelaySpeedWindow.xaml.cs b/Flow.Launcher/SearchDelaySpeedWindow.xaml.cs index 5889a1280..cfbde8be2 100644 --- a/Flow.Launcher/SearchDelaySpeedWindow.xaml.cs +++ b/Flow.Launcher/SearchDelaySpeedWindow.xaml.cs @@ -28,7 +28,7 @@ public partial class SearchDelaySpeedWindow : Window selected = searchDelaySpeeds.FirstOrDefault(x => x.Value == _pluginViewModel.PluginSearchDelay); } // Add default value to the beginning of the list - // This value should be null + // When _pluginViewModel.PluginSearchDelay equals null, we will select this searchDelaySpeeds.Insert(0, new SearchDelaySpeedData { Display = App.API.GetTranslation(PluginViewModel.DefaultLocalizationKey), LocalizationKey = PluginViewModel.DefaultLocalizationKey }); selected ??= searchDelaySpeeds.FirstOrDefault(); tbDelay.ItemsSource = searchDelaySpeeds; diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 309cd67bb..f43931192 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -298,7 +298,7 @@ namespace Flow.Launcher.ViewModel { if (QueryResultsSelected()) { - // When we are requiring, we should not delay the query + // When we are re-querying, we should not delay the query _ = QueryResultsAsync(false, isReQuery: true); } } @@ -306,7 +306,7 @@ namespace Flow.Launcher.ViewModel public void ReQuery(bool reselect) { BackToQueryResults(); - // When we are requiring, we should not delay the query + // When we are re-querying, we should not delay the query _ = QueryResultsAsync(false, isReQuery: true, reSelect: reselect); } @@ -660,7 +660,7 @@ namespace Flow.Launcher.ViewModel } else if (isReQuery) { - // When we are requiring, we should not delay the query + // When we are re-querying, we should not delay the query await QueryAsync(false, isReQuery: true); } From c4cd51c3126db130864d40ce05898962526a6d70 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Mon, 31 Mar 2025 13:26:09 +0800 Subject: [PATCH 380/400] Change to search delay time --- .../UserSettings/PluginSettings.cs | 12 +++---- .../UserSettings/Settings.cs | 2 +- Flow.Launcher.Plugin/PluginMetadata.cs | 4 +-- Flow.Launcher.Plugin/SearchDelaySpeeds.cs | 32 ----------------- Flow.Launcher.Plugin/SearchDelayTime.cs | 32 +++++++++++++++++ Flow.Launcher/Languages/en.xaml | 26 +++++++------- .../Controls/InstalledPluginSearchDelay.xaml | 8 ++--- Flow.Launcher/SearchDelaySpeedWindow.xaml | 16 ++++----- Flow.Launcher/SearchDelaySpeedWindow.xaml.cs | 36 +++++++++---------- .../SettingsPaneGeneralViewModel.cs | 20 +++++------ .../Views/SettingsPaneGeneral.xaml | 8 ++--- Flow.Launcher/ViewModel/MainViewModel.cs | 13 ++++--- Flow.Launcher/ViewModel/PluginViewModel.cs | 22 ++++++------ .../plugin.json | 2 +- 14 files changed, 115 insertions(+), 118 deletions(-) delete mode 100644 Flow.Launcher.Plugin/SearchDelaySpeeds.cs create mode 100644 Flow.Launcher.Plugin/SearchDelayTime.cs diff --git a/Flow.Launcher.Infrastructure/UserSettings/PluginSettings.cs b/Flow.Launcher.Infrastructure/UserSettings/PluginSettings.cs index d1c047495..da92a3583 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/PluginSettings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/PluginSettings.cs @@ -51,7 +51,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings settings.Version = metadata.Version; } settings.DefaultActionKeywords = metadata.ActionKeywords; // metadata provides default values - settings.DefaultSearchDelaySpeed = metadata.SearchDelaySpeed; // metadata provides default values + settings.DefaultSearchDelayTime = metadata.SearchDelayTime; // metadata provides default values // update metadata values with settings if (settings.ActionKeywords?.Count > 0) @@ -66,7 +66,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings } metadata.Disabled = settings.Disabled; metadata.Priority = settings.Priority; - metadata.SearchDelaySpeed = settings.SearchDelaySpeed; + metadata.SearchDelayTime = settings.SearchDelayTime; } else { @@ -80,8 +80,8 @@ namespace Flow.Launcher.Infrastructure.UserSettings ActionKeywords = metadata.ActionKeywords, // use default value Disabled = metadata.Disabled, Priority = metadata.Priority, - DefaultSearchDelaySpeed = metadata.SearchDelaySpeed, // metadata provides default values - SearchDelaySpeed = metadata.SearchDelaySpeed, // use default value + DefaultSearchDelayTime = metadata.SearchDelayTime, // metadata provides default values + SearchDelayTime = metadata.SearchDelayTime, // use default value }; } } @@ -120,10 +120,10 @@ namespace Flow.Launcher.Infrastructure.UserSettings public int Priority { get; set; } [JsonIgnore] - public SearchDelaySpeeds? DefaultSearchDelaySpeed { get; set; } + public SearchDelayTime? DefaultSearchDelayTime { get; set; } [JsonConverter(typeof(JsonStringEnumConverter))] - public SearchDelaySpeeds? SearchDelaySpeed { get; set; } + public SearchDelayTime? SearchDelayTime { get; set; } /// /// Used only to save the state of the plugin in settings diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index fed4b667b..fcfbe8ca0 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -323,7 +323,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings public bool SearchQueryResultsWithDelay { get; set; } [JsonConverter(typeof(JsonStringEnumConverter))] - public SearchDelaySpeeds SearchDelaySpeed { get; set; } = SearchDelaySpeeds.Medium; + public SearchDelayTime SearchDelayTime { get; set; } = SearchDelayTime.Medium; [JsonConverter(typeof(JsonStringEnumConverter))] public SearchWindowScreens SearchWindowScreen { get; set; } = SearchWindowScreens.Cursor; diff --git a/Flow.Launcher.Plugin/PluginMetadata.cs b/Flow.Launcher.Plugin/PluginMetadata.cs index 42b623717..1496765ce 100644 --- a/Flow.Launcher.Plugin/PluginMetadata.cs +++ b/Flow.Launcher.Plugin/PluginMetadata.cs @@ -99,10 +99,10 @@ namespace Flow.Launcher.Plugin public bool HideActionKeywordPanel { get; set; } /// - /// Plugin search delay speed. Null means use default search delay. + /// Plugin search delay time. Null means use default search delay time. /// [JsonConverter(typeof(JsonStringEnumConverter))] - public SearchDelaySpeeds? SearchDelaySpeed { get; set; } = null; + public SearchDelayTime? SearchDelayTime { get; set; } = null; /// /// Plugin icon path. diff --git a/Flow.Launcher.Plugin/SearchDelaySpeeds.cs b/Flow.Launcher.Plugin/SearchDelaySpeeds.cs deleted file mode 100644 index 543f8b3f6..000000000 --- a/Flow.Launcher.Plugin/SearchDelaySpeeds.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace Flow.Launcher.Plugin; - -/// -/// Enum for search delay speeds -/// -public enum SearchDelaySpeeds -{ - /// - /// Slow search delay speed. 50ms. - /// - Slow, - - /// - /// Moderately slow search delay speed. 100ms. - /// - ModeratelySlow, - - /// - /// Medium search delay speed. 150ms. Default value. - /// - Medium, - - /// - /// Moderately fast search delay speed. 200ms. - /// - ModeratelyFast, - - /// - /// Fast search delay speed. 250ms. - /// - Fast -} diff --git a/Flow.Launcher.Plugin/SearchDelayTime.cs b/Flow.Launcher.Plugin/SearchDelayTime.cs new file mode 100644 index 000000000..8dae5997e --- /dev/null +++ b/Flow.Launcher.Plugin/SearchDelayTime.cs @@ -0,0 +1,32 @@ +namespace Flow.Launcher.Plugin; + +/// +/// Enum for search delay time +/// +public enum SearchDelayTime +{ + /// + /// Long search delay time. 250ms. + /// + Long, + + /// + /// Moderately long search delay time. 200ms. + /// + ModeratelyLong, + + /// + /// Medium search delay time. 150ms. Default value. + /// + Medium, + + /// + /// Moderately short search delay time. 100ms. + /// + ModeratelyShort, + + /// + /// Short search delay time. 50ms. + /// + Short +} diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index ae930db70..e6a764d48 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -104,13 +104,13 @@ Shadow effect is not allowed while current theme has blur effect enabled Search Delay Delay for a while to search when typing. This reduces interface jumpiness and result load. - Default Search Delay Speed - Plugins default delay time after which search results appear when typing is stopped. Default is medium. - Slow - Moderately slow - Medium - Moderately fast - Fast + Default Search Delay Time + Plugin default delay time after which search results appear when typing is stopped. Default is "Medium". + Long + Moderately long + Medium + Moderately short + Short Search Plugin @@ -127,8 +127,8 @@ Current action keyword New action keyword Change Action Keywords - Plugin seach delay speed - Change Plugin Seach Delay Speed + Plugin seach delay time + Change Plugin Seach Delay Time Current Priority New Priority Priority @@ -366,10 +366,10 @@ 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 + Search Delay Time Setting + Select the search delay time you like to use for the plugin. Select "{0}" if you don't want to specify any, and the plugin will use default search delay time. + Current search delay time + New search delay time Custom Query Hotkey diff --git a/Flow.Launcher/Resources/Controls/InstalledPluginSearchDelay.xaml b/Flow.Launcher/Resources/Controls/InstalledPluginSearchDelay.xaml index bd2f9a7c9..0fd98bfac 100644 --- a/Flow.Launcher/Resources/Controls/InstalledPluginSearchDelay.xaml +++ b/Flow.Launcher/Resources/Controls/InstalledPluginSearchDelay.xaml @@ -32,18 +32,18 @@ VerticalAlignment="Center" DockPanel.Dock="Left" Style="{DynamicResource SettingTitleLabel}" - Text="{DynamicResource pluginSearchDelaySpeed}" /> + Text="{DynamicResource pluginSearchDelayTime}" />