From 824befdef62d1e10710d75c7481f74e54d0ee6d4 Mon Sep 17 00:00:00 2001 From: Yusyuriv Date: Mon, 9 Dec 2024 02:33:19 +0600 Subject: [PATCH] Add preserve last action keyword options --- .../UserSettings/Settings.cs | 8 +++++--- Flow.Launcher/Languages/en.xaml | 2 ++ Flow.Launcher/ViewModel/MainViewModel.cs | 16 +++++++++++++--- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 0c7de10fd78..0bcc9368d22 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -62,7 +62,7 @@ public string Theme public double ItemHeightSize { get; set; } = 58; public double QueryBoxFontSize { get; set; } = 20; public double ResultItemFontSize { get; set; } = 16; - public double ResultSubItemFontSize { get; set; } = 13; + public double ResultSubItemFontSize { get; set; } = 13; public string QueryBoxFont { get; set; } = FontFamily.GenericSansSerif.Name; public string QueryBoxFontStyle { get; set; } public string QueryBoxFontWeight { get; set; } @@ -187,7 +187,7 @@ public CustomBrowserViewModel CustomBrowser public bool ShouldUsePinyin { get; set; } = false; public bool AlwaysPreview { get; set; } = false; - + public bool AlwaysStartEn { get; set; } = false; private SearchPrecisionScore _querySearchPrecision = SearchPrecisionScore.Regular; @@ -370,7 +370,9 @@ public enum LastQueryMode { Selected, Empty, - Preserved + Preserved, + ActionKeywordPreserved, + ActionKeywordSelected } public enum ColorSchemes diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index ffb03b63592..4c465d61f52 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -67,6 +67,8 @@ Preserve Last Query Select last Query Empty last Query + Preserve Last Action Keyword + Select Last Action Keyword Fixed Window Height The window height is not adjustable by dragging. Maximum results shown diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 626495cb68a..7260593dc28 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -771,7 +771,7 @@ public string VerifyOrSetDefaultHotkey(string hotkey, string defaultHotkey) public string Image => Constant.QueryTextBoxIconImagePath; public bool StartWithEnglishMode => Settings.AlwaysStartEn; - + #endregion #region Preview @@ -833,7 +833,7 @@ when CanExternalPreviewSelectedResult(out var path): } private void HidePreview() - { + { if (PluginManager.UseExternalPreview()) CloseExternalPreview(); @@ -912,7 +912,7 @@ when PluginManager.AllowAlwaysPreview() && CanExternalPreviewSelectedResult(out break; } } - + private void UpdatePreview() { switch (PluginManager.UseExternalPreview()) @@ -1401,6 +1401,16 @@ public async void Hide() await Task.Delay(100); LastQuerySelected = false; break; + case LastQueryMode.ActionKeywordPreserved or LastQueryMode.ActionKeywordSelected: + var newQuery = _lastQuery.ActionKeyword; + if (!string.IsNullOrEmpty(newQuery)) + newQuery += " "; + ChangeQueryText(newQuery); + if (Settings.UseAnimation) + await Task.Delay(100); + if (Settings.LastQueryMode == LastQueryMode.ActionKeywordSelected) + LastQuerySelected = false; + break; default: throw new ArgumentException($"wrong LastQueryMode: <{Settings.LastQueryMode}>"); }