From 516dd2582431002cd475b540c41b41eab5379483 Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Wed, 1 Dec 2021 13:19:19 -0500 Subject: [PATCH 01/28] Initial --- Flow.Launcher/MainWindow.xaml.cs | 9 ++++++++- Flow.Launcher/ViewModel/MainViewModel.cs | 9 +++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index ba0b63a5211..83d657b22df 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -442,7 +442,14 @@ private void OnKeyDown(object sender, KeyEventArgs e) e.Handled = true; break; case Key.Up: - _viewModel.SelectPrevItemCommand.Execute(null); + if (string.IsNullOrEmpty(QueryTextBox.Text)) + { + _viewModel.CycleHistory(); + } + else + { + _viewModel.SelectPrevItemCommand.Execute(null); + } e.Handled = true; break; case Key.PageDown: diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 1d666426f7a..860af6262dd 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -706,6 +706,15 @@ public void ToggleFlowLauncher() } } + public void CycleHistory() + { + if (!HistorySelected()) + { + ChangeQueryText(_history.Items.Last().Query.ToString()); + } + + } + public void Show() { if (_settings.UseSound) From b520d662c1a997f0fb1e117698ecf413d917abfb Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sat, 4 Dec 2021 21:51:34 +1100 Subject: [PATCH 02/28] add check for no history --- Flow.Launcher/ViewModel/MainViewModel.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 860af6262dd..f167f21df84 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -708,11 +708,8 @@ public void ToggleFlowLauncher() public void CycleHistory() { - if (!HistorySelected()) - { + if (!HistorySelected() && _history.Items.Count > 0) ChangeQueryText(_history.Items.Last().Query.ToString()); - } - } public void Show() From 4f3ed19c88c00f92cf0db1307e94565a508a882a Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Sat, 11 Dec 2021 14:43:23 -0500 Subject: [PATCH 03/28] Cycle through entire history --- Flow.Launcher/MainWindow.xaml.cs | 9 +-------- Flow.Launcher/ViewModel/MainViewModel.cs | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 83d657b22df..4d9bc7c041c 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -442,14 +442,7 @@ private void OnKeyDown(object sender, KeyEventArgs e) e.Handled = true; break; case Key.Up: - if (string.IsNullOrEmpty(QueryTextBox.Text)) - { - _viewModel.CycleHistory(); - } - else - { - _viewModel.SelectPrevItemCommand.Execute(null); - } + _viewModel.CycleHistory(); e.Handled = true; break; case Key.PageDown: diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index f167f21df84..945550b4461 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -33,6 +33,7 @@ public class MainViewModel : BaseModel, ISavable private bool _isQueryRunning; private Query _lastQuery; private string _queryTextBeforeLeaveResults; + private int _lastHistory = 1; private readonly FlowLauncherJsonStorage _historyItemsStorage; private readonly FlowLauncherJsonStorage _userSelectedRecordStorage; @@ -708,8 +709,19 @@ public void ToggleFlowLauncher() public void CycleHistory() { - if (!HistorySelected() && _history.Items.Count > 0) - ChangeQueryText(_history.Items.Last().Query.ToString()); + var results = SelectedResults; + + if (SelectedIsFromQueryResults() && _history.Items.Count > 0 && (results.SelectedIndex == 0 || results != null)) + { + ChangeQueryText(_history.Items[_history.Items.Count - _lastHistory].Query.ToString()); + _lastHistory++; + } + else + { + _lastHistory = 1; + SelectPrevItemCommand.Execute(null); + } + } public void Show() From 53f05f42ded672f75e7917998243a5853ec7b89f Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Sat, 11 Dec 2021 14:58:36 -0500 Subject: [PATCH 04/28] Fix condiitonal --- Flow.Launcher/ViewModel/MainViewModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index a1c43edb8dc..4273ac47399 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -737,7 +737,7 @@ public void CycleHistory() { var results = SelectedResults; - if (SelectedIsFromQueryResults() && _history.Items.Count > 0 && (results.SelectedIndex == 0 || results != null)) + if (SelectedIsFromQueryResults() && _history.Items.Count > 0 && (results.SelectedIndex == 0 || results == null)) { ChangeQueryText(_history.Items[_history.Items.Count - _lastHistory].Query.ToString()); _lastHistory++; From 76c410a3b23712bf1a04d10681cdbc9a86377556 Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Sat, 11 Dec 2021 15:10:33 -0500 Subject: [PATCH 05/28] Explicitly that result is not history or context items --- Flow.Launcher/ViewModel/MainViewModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 4273ac47399..c5cbd03078a 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -737,7 +737,7 @@ public void CycleHistory() { var results = SelectedResults; - if (SelectedIsFromQueryResults() && _history.Items.Count > 0 && (results.SelectedIndex == 0 || results == null)) + if (!HistorySelected() && !ContextMenuSelected() && _history.Items.Count > 0 && (results.SelectedIndex <= 0 || results == null )) { ChangeQueryText(_history.Items[_history.Items.Count - _lastHistory].Query.ToString()); _lastHistory++; From 747abac28a6a0366533efbdfdc4209cb9e3b5d5e Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Sat, 11 Dec 2021 15:29:37 -0500 Subject: [PATCH 06/28] reset history index on hide --- Flow.Launcher/ViewModel/MainViewModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index c5cbd03078a..5ca04e5211c 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -793,7 +793,7 @@ public async void Hide() default: throw new ArgumentException($"wrong LastQueryMode: <{_settings.LastQueryMode}>"); } - + _lastHistory = 1; MainWindowVisibilityStatus = false; MainWindowVisibility = Visibility.Collapsed; } From 54821ff6b0e85785b2e78c0e5cd2084189db23ee Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Sat, 11 Dec 2021 15:30:21 -0500 Subject: [PATCH 07/28] shell like keybind --- Flow.Launcher/MainWindow.xaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index 129ceeea502..b95a1315d99 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -90,6 +90,10 @@ Key="H" Command="{Binding LoadHistoryCommand}" Modifiers="Ctrl" /> + Date: Sun, 12 Dec 2021 03:36:10 -0500 Subject: [PATCH 08/28] Better variable naming --- Flow.Launcher/ViewModel/MainViewModel.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 5ca04e5211c..de8d3c8dfb8 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -33,7 +33,7 @@ public class MainViewModel : BaseModel, ISavable private bool _isQueryRunning; private Query _lastQuery; private string _queryTextBeforeLeaveResults; - private int _lastHistory = 1; + private int _lastHistoryIndex = 1; private readonly FlowLauncherJsonStorage _historyItemsStorage; private readonly FlowLauncherJsonStorage _userSelectedRecordStorage; @@ -739,12 +739,12 @@ public void CycleHistory() if (!HistorySelected() && !ContextMenuSelected() && _history.Items.Count > 0 && (results.SelectedIndex <= 0 || results == null )) { - ChangeQueryText(_history.Items[_history.Items.Count - _lastHistory].Query.ToString()); - _lastHistory++; + ChangeQueryText(_history.Items[_history.Items.Count - _lastHistoryIndex].Query.ToString()); + _lastHistoryIndex++; } else { - _lastHistory = 1; + _lastHistoryIndex = 1; SelectPrevItemCommand.Execute(null); } @@ -793,7 +793,7 @@ public async void Hide() default: throw new ArgumentException($"wrong LastQueryMode: <{_settings.LastQueryMode}>"); } - _lastHistory = 1; + _lastHistoryIndex = 1; MainWindowVisibilityStatus = false; MainWindowVisibility = Visibility.Collapsed; } From cab029646247a1c6cb2fd06fb027f47183271379 Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Sun, 12 Dec 2021 03:39:42 -0500 Subject: [PATCH 09/28] Dont reset history index when selection changes --- Flow.Launcher/ViewModel/MainViewModel.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index de8d3c8dfb8..c3343907b1d 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -744,7 +744,6 @@ public void CycleHistory() } else { - _lastHistoryIndex = 1; SelectPrevItemCommand.Execute(null); } From 072989988ebfe7821fa5148ccc25bbfb15f908ec Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Mon, 13 Dec 2021 06:05:29 -0500 Subject: [PATCH 10/28] cycle with alt modifer and empty query --- Flow.Launcher/MainWindow.xaml | 2 + Flow.Launcher/MainWindow.xaml.cs | 2 +- Flow.Launcher/ViewModel/MainViewModel.cs | 48 ++++++++++++++++++++---- 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index b95a1315d99..aad5983c2ad 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -86,6 +86,8 @@ Modifiers="Ctrl" /> + + _historyItemsStorage; private readonly FlowLauncherJsonStorage _userSelectedRecordStorage; private readonly FlowLauncherJsonStorage _topMostRecordStorage; internal readonly Settings _settings; private readonly History _history; + private int _lastHistoryIndex = 1; private readonly UserSelectedRecord _userSelectedRecord; private readonly TopMostRecord _topMostRecord; @@ -190,6 +191,39 @@ private void InitializeKeyCommands() SelectFirstResultCommand = new RelayCommand(_ => SelectedResults.SelectFirstResult()); + ReverseHistory = new RelayCommand(_ => { + CycleHistoryIndex(); + if (_lastHistoryIndex < _history.Items.Count) + { + _lastHistoryIndex++; + } + + }); + + ForwardHistory = new RelayCommand(_ => { + CycleHistoryIndex(); + if (_lastHistoryIndex > 1) + { + _lastHistoryIndex--; + } + + }); + + InsertLastQuery = new RelayCommand(_ => { + var results = SelectedResults; + + if (_queryText == String.Empty) + { + ChangeQueryText(_history.Items[_history.Items.Count - 1].Query.ToString()); + _lastHistoryIndex++; + } + else + { + SelectPrevItemCommand.Execute(null); + } + + }); + StartHelpCommand = new RelayCommand(_ => { SearchWeb.NewTabInBrowser("https://github.com/Flow-Launcher/Flow.Launcher/wiki/Flow-Launcher/"); @@ -410,6 +444,9 @@ private ResultsViewModel SelectedResults public ICommand ReloadPluginDataCommand { get; set; } public ICommand ClearQueryCommand { get; private set; } public ICommand AutocompleteQueryCommand { get; set; } + public ICommand ReverseHistory { get; set; } + public ICommand ForwardHistory { get; set; } + public ICommand InsertLastQuery { get; set; } public string OpenResultCommandModifiers { get; private set; } @@ -733,20 +770,17 @@ public void ToggleFlowLauncher() } } - public void CycleHistory() + public void CycleHistoryIndex() { - var results = SelectedResults; + if (!HistorySelected() && !ContextMenuSelected() && _history.Items.Count > 0) + { - if (!HistorySelected() && !ContextMenuSelected() && _history.Items.Count > 0 && (results.SelectedIndex <= 0 || results == null )) - { ChangeQueryText(_history.Items[_history.Items.Count - _lastHistoryIndex].Query.ToString()); - _lastHistoryIndex++; } else { SelectPrevItemCommand.Execute(null); } - } public void Show() From 387698be0c2fd9fb2c6a2f59bcd7ed1de1fba573 Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Mon, 13 Dec 2021 06:12:46 -0500 Subject: [PATCH 11/28] Dont insert history if in history/context menus --- Flow.Launcher/ViewModel/MainViewModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index b7ce4629907..129849f4a11 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -212,7 +212,7 @@ private void InitializeKeyCommands() InsertLastQuery = new RelayCommand(_ => { var results = SelectedResults; - if (_queryText == String.Empty) + if (_queryText == String.Empty && !HistorySelected() && !ContextMenuSelected()) { ChangeQueryText(_history.Items[_history.Items.Count - 1].Query.ToString()); _lastHistoryIndex++; From 8775dc884de819fd9c2fece77f10ffcae7529678 Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Mon, 13 Dec 2021 18:02:59 -0500 Subject: [PATCH 12/28] Fix cycling --- Flow.Launcher/ViewModel/MainViewModel.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 129849f4a11..03895c75772 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -192,16 +192,19 @@ private void InitializeKeyCommands() SelectFirstResultCommand = new RelayCommand(_ => SelectedResults.SelectFirstResult()); ReverseHistory = new RelayCommand(_ => { - CycleHistoryIndex(); + + ChangeQueryText(_history.Items[_history.Items.Count - _lastHistoryIndex].Query.ToString()); + if (_lastHistoryIndex < _history.Items.Count) { _lastHistoryIndex++; } - }); ForwardHistory = new RelayCommand(_ => { - CycleHistoryIndex(); + + ChangeQueryText(_history.Items[_history.Items.Count - _lastHistoryIndex].Query.ToString()); + if (_lastHistoryIndex > 1) { _lastHistoryIndex--; From 2ece980fa8b2acbe87277ad65f56be7908b0a144 Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Mon, 13 Dec 2021 18:03:22 -0500 Subject: [PATCH 13/28] Move history index --- Flow.Launcher/ViewModel/MainViewModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 03895c75772..a91e6cc4249 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -218,7 +218,7 @@ private void InitializeKeyCommands() if (_queryText == String.Empty && !HistorySelected() && !ContextMenuSelected()) { ChangeQueryText(_history.Items[_history.Items.Count - 1].Query.ToString()); - _lastHistoryIndex++; + _lastHistoryIndex = 1; } else { From 9141fbfd05e7f70acae7a68421ab9b15495e9bdc Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Mon, 13 Dec 2021 18:03:33 -0500 Subject: [PATCH 14/28] Remove unused function --- Flow.Launcher/ViewModel/MainViewModel.cs | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index a91e6cc4249..e0d2c8cf8cd 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -773,19 +773,6 @@ public void ToggleFlowLauncher() } } - public void CycleHistoryIndex() - { - if (!HistorySelected() && !ContextMenuSelected() && _history.Items.Count > 0) - { - - ChangeQueryText(_history.Items[_history.Items.Count - _lastHistoryIndex].Query.ToString()); - } - else - { - SelectPrevItemCommand.Execute(null); - } - } - public void Show() { if (_settings.UseSound) From d74878c319bb03a44101fd075195e7bd860a8ac7 Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Mon, 13 Dec 2021 18:04:30 -0500 Subject: [PATCH 15/28] set to correct index --- Flow.Launcher/ViewModel/MainViewModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index e0d2c8cf8cd..3c84fde8abf 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -218,7 +218,7 @@ private void InitializeKeyCommands() if (_queryText == String.Empty && !HistorySelected() && !ContextMenuSelected()) { ChangeQueryText(_history.Items[_history.Items.Count - 1].Query.ToString()); - _lastHistoryIndex = 1; + _lastHistoryIndex = 2; } else { From 1ec7867c7e4b35ad3b54eab4ca119f6ec5d32657 Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Mon, 13 Dec 2021 18:46:30 -0500 Subject: [PATCH 16/28] Add modifiers to settings --- .../UserSettings/Settings.cs | 1 + Flow.Launcher/MainWindow.xaml | 4 ++-- Flow.Launcher/SettingWindow.xaml | 22 +++++++++++++++++++ Flow.Launcher/ViewModel/MainViewModel.cs | 8 +++++++ .../ViewModel/SettingWindowViewModel.cs | 1 + 5 files changed, 34 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 6bf9c2ff010..ac83105a20c 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -15,6 +15,7 @@ public class Settings : BaseModel private string language = "en"; public string Hotkey { get; set; } = $"{KeyConstant.Alt} + {KeyConstant.Space}"; public string OpenResultModifiers { get; set; } = KeyConstant.Alt; + public string CycleHistoryModifiers { get; set; } = KeyConstant.Alt; public string ColorScheme { get; set; } = "System"; public bool ShowOpenResultHotkey { get; set; } = true; public double WindowSize { get; set; } = 580; diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index aad5983c2ad..7c86ba69288 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -86,8 +86,8 @@ Modifiers="Ctrl" /> - - + + + + + + + + + + + diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 3c84fde8abf..e42fbba06ce 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -29,6 +29,7 @@ public class MainViewModel : BaseModel, ISavable #region Private Fields private const string DefaultOpenResultModifiers = "Alt"; + private const string DefaultCycleHistoryModifiers = "Alt"; private bool _isQueryRunning; private Query _lastQuery; @@ -88,6 +89,7 @@ public MainViewModel(Settings settings) RegisterResultsUpdatedEvent(); SetOpenResultModifiers(); + SetCycleHistoryModifiers(); } private void RegisterViewUpdate() @@ -452,6 +454,7 @@ private ResultsViewModel SelectedResults public ICommand InsertLastQuery { get; set; } public string OpenResultCommandModifiers { get; private set; } + public string CycleHistoryModifiers { get; private set; } public string Image => Constant.QueryTextBoxIconImagePath; @@ -761,6 +764,11 @@ private void SetOpenResultModifiers() OpenResultCommandModifiers = _settings.OpenResultModifiers ?? DefaultOpenResultModifiers; } + private void SetCycleHistoryModifiers() + { + CycleHistoryModifiers = _settings.CycleHistoryModifiers ?? DefaultCycleHistoryModifiers; + } + public void ToggleFlowLauncher() { if (!MainWindowVisibilityStatus) diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index 342c85da202..8ca5db9e3fc 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -166,6 +166,7 @@ public List QuerySearchPrecisionStrings } public List OpenResultModifiersList => new List { KeyConstant.Alt, KeyConstant.Ctrl, $"{KeyConstant.Ctrl}+{KeyConstant.Alt}" }; + public List CycleHistoryModifiersList => new List { KeyConstant.Alt, KeyConstant.Ctrl, $"{KeyConstant.Ctrl}+{KeyConstant.Alt}" }; private Internationalization _translater => InternationalizationManager.Instance; public List Languages => _translater.LoadAvailableLanguages(); public IEnumerable MaxResultsRange => Enumerable.Range(2, 16); From 1312fdaec75e45fa874af54e747a6b1e045ff618 Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Tue, 14 Dec 2021 18:34:33 -0500 Subject: [PATCH 17/28] Remove setings from general --- Flow.Launcher/SettingWindow.xaml | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index 7db0877daf1..fde69aaf2fc 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -627,29 +627,6 @@ - - - - - - - - - - From 70b0a54802f34f6b4fe79e309b91c1aa7452f091 Mon Sep 17 00:00:00 2001 From: DB p Date: Wed, 15 Dec 2021 10:22:37 +0900 Subject: [PATCH 18/28] Add modifiers to Hotkey Tab in settings --- Flow.Launcher/Languages/en.xaml | 2 ++ Flow.Launcher/SettingWindow.xaml | 33 ++++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index 0c6bb05c6f7..71fdb247b54 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -104,6 +104,8 @@ Select a modifier key to open selected result via keyboard. Show Hotkey Show result selection hotkey with results. + Cycle History Modifiers + You can switch to the previously entered query using up, down + modifier. Custom Query Hotkey Query Delete diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index fde69aaf2fc..b55cf362ea2 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -1988,7 +1988,7 @@ - + @@ -2064,7 +2064,7 @@ Style="{StaticResource SettingSeparatorStyle}" /> @@ -2083,6 +2083,35 @@ Style="{DynamicResource SideControlCheckBox}" /> + + + + + + + + + + + + + From 357843594daf5b848227e89741c4c8e0a7ba2110 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Wed, 22 Dec 2021 07:22:11 +1100 Subject: [PATCH 19/28] add check against empty history items --- Flow.Launcher/ViewModel/MainViewModel.cs | 27 ++++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index e42fbba06ce..44402246505 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -195,21 +195,27 @@ private void InitializeKeyCommands() ReverseHistory = new RelayCommand(_ => { - ChangeQueryText(_history.Items[_history.Items.Count - _lastHistoryIndex].Query.ToString()); - - if (_lastHistoryIndex < _history.Items.Count) + if (_history.Items.Count > 0) { - _lastHistoryIndex++; + ChangeQueryText(_history.Items[_history.Items.Count - _lastHistoryIndex].Query.ToString()); + + if (_lastHistoryIndex < _history.Items.Count) + { + _lastHistoryIndex++; + } } }); ForwardHistory = new RelayCommand(_ => { - ChangeQueryText(_history.Items[_history.Items.Count - _lastHistoryIndex].Query.ToString()); - - if (_lastHistoryIndex > 1) + if (_history.Items.Count > 0) { - _lastHistoryIndex--; + ChangeQueryText(_history.Items[_history.Items.Count - _lastHistoryIndex].Query.ToString()); + + if (_lastHistoryIndex > 1) + { + _lastHistoryIndex--; + } } }); @@ -217,7 +223,10 @@ private void InitializeKeyCommands() InsertLastQuery = new RelayCommand(_ => { var results = SelectedResults; - if (_queryText == String.Empty && !HistorySelected() && !ContextMenuSelected()) + if (_history.Items.Count > 0 + && _queryText == String.Empty + && !HistorySelected() + && !ContextMenuSelected()) { ChangeQueryText(_history.Items[_history.Items.Count - 1].Query.ToString()); _lastHistoryIndex = 2; From aecb105fa7692c1df6885a91352402536c86cb43 Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Tue, 21 Dec 2021 17:01:49 -0500 Subject: [PATCH 20/28] Update Flow.Launcher/ViewModel/MainViewModel.cs Co-authored-by: Jeremy Wu --- Flow.Launcher/ViewModel/MainViewModel.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 44402246505..df3e7f63591 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -35,7 +35,6 @@ public class MainViewModel : BaseModel, ISavable private Query _lastQuery; private string _queryTextBeforeLeaveResults; - private readonly FlowLauncherJsonStorage _historyItemsStorage; private readonly FlowLauncherJsonStorage _userSelectedRecordStorage; private readonly FlowLauncherJsonStorage _topMostRecordStorage; From 302a8b83b40de0e108e09e5cdb9f584d25ce9f2b Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Wed, 22 Dec 2021 13:26:07 -0500 Subject: [PATCH 21/28] Use more descriptive function name --- Flow.Launcher/ViewModel/MainViewModel.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index df3e7f63591..8d86a92c991 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -219,7 +219,7 @@ private void InitializeKeyCommands() }); - InsertLastQuery = new RelayCommand(_ => { + ReverseHistoryOnEmptyQuery = new RelayCommand(_ => { var results = SelectedResults; if (_history.Items.Count > 0 @@ -459,7 +459,7 @@ private ResultsViewModel SelectedResults public ICommand AutocompleteQueryCommand { get; set; } public ICommand ReverseHistory { get; set; } public ICommand ForwardHistory { get; set; } - public ICommand InsertLastQuery { get; set; } + public ICommand ReverseHistoryOnEmptyQuery { get; set; } public string OpenResultCommandModifiers { get; private set; } public string CycleHistoryModifiers { get; private set; } From 7897d4a34ffe43e145fbf48355cca23eca64c11d Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Wed, 22 Dec 2021 13:26:32 -0500 Subject: [PATCH 22/28] Remove underscore from var name --- Flow.Launcher/ViewModel/MainViewModel.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 8d86a92c991..b86aecd0346 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -40,7 +40,7 @@ public class MainViewModel : BaseModel, ISavable private readonly FlowLauncherJsonStorage _topMostRecordStorage; internal readonly Settings _settings; private readonly History _history; - private int _lastHistoryIndex = 1; + private int lasthistoryindex = 1; private readonly UserSelectedRecord _userSelectedRecord; private readonly TopMostRecord _topMostRecord; @@ -196,11 +196,11 @@ private void InitializeKeyCommands() if (_history.Items.Count > 0) { - ChangeQueryText(_history.Items[_history.Items.Count - _lastHistoryIndex].Query.ToString()); + ChangeQueryText(_history.Items[_history.Items.Count - lasthistoryindex].Query.ToString()); - if (_lastHistoryIndex < _history.Items.Count) + if (lasthistoryindex < _history.Items.Count) { - _lastHistoryIndex++; + lasthistoryindex++; } } }); @@ -209,11 +209,11 @@ private void InitializeKeyCommands() if (_history.Items.Count > 0) { - ChangeQueryText(_history.Items[_history.Items.Count - _lastHistoryIndex].Query.ToString()); + ChangeQueryText(_history.Items[_history.Items.Count - lasthistoryindex].Query.ToString()); - if (_lastHistoryIndex > 1) + if (lasthistoryindex > 1) { - _lastHistoryIndex--; + lasthistoryindex--; } } @@ -228,7 +228,7 @@ private void InitializeKeyCommands() && !ContextMenuSelected()) { ChangeQueryText(_history.Items[_history.Items.Count - 1].Query.ToString()); - _lastHistoryIndex = 2; + lasthistoryindex = 2; } else { @@ -832,7 +832,7 @@ public async void Hide() default: throw new ArgumentException($"wrong LastQueryMode: <{_settings.LastQueryMode}>"); } - _lastHistoryIndex = 1; + lasthistoryindex = 1; MainWindowVisibilityStatus = false; MainWindowVisibility = Visibility.Collapsed; } From a9878c98795d0604a2a5bca5ae95e6939c2e910d Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Wed, 22 Dec 2021 13:34:28 -0500 Subject: [PATCH 23/28] Update changed function name --- Flow.Launcher/MainWindow.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 6151656c5dd..19745d4d144 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -456,7 +456,7 @@ private void OnKeyDown(object sender, KeyEventArgs e) e.Handled = true; break; case Key.Up: - _viewModel.InsertLastQuery.Execute(null); + _viewModel.ReverseHistoryOnEmptyQuery.Execute(null); e.Handled = true; break; case Key.PageDown: From c8b1c31753be2a1e041f91d9d23903df96908081 Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Wed, 22 Dec 2021 14:12:14 -0500 Subject: [PATCH 24/28] Check history count before changing index --- Flow.Launcher/ViewModel/MainViewModel.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index b86aecd0346..8a459895168 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -228,7 +228,12 @@ private void InitializeKeyCommands() && !ContextMenuSelected()) { ChangeQueryText(_history.Items[_history.Items.Count - 1].Query.ToString()); - lasthistoryindex = 2; + // Set index to next item if user attempts to continue cycling history + if (_history.Items.Count > 1) + { + lasthistoryindex = 2; + } + } else { From 8b39a83a7b8c0da497224902f3306fe8fe6c4fc4 Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Wed, 22 Dec 2021 14:15:43 -0500 Subject: [PATCH 25/28] Increase index instead of explicitly defining --- Flow.Launcher/ViewModel/MainViewModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 8a459895168..5e85fad7719 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -231,7 +231,7 @@ private void InitializeKeyCommands() // Set index to next item if user attempts to continue cycling history if (_history.Items.Count > 1) { - lasthistoryindex = 2; + lasthistoryindex++; } } From e67afcb47f5dd96860db04c812986ac4beee4fae Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Wed, 22 Dec 2021 14:17:27 -0500 Subject: [PATCH 26/28] Reset index on cleared query --- Flow.Launcher/ViewModel/MainViewModel.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 5e85fad7719..5cfbf45f1a7 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -585,6 +585,7 @@ private async void QueryResults() { Results.Clear(); Results.Visbility = Visibility.Collapsed; + lasthistoryindex = 1; return; } From c6d5525dec46631db6cf587573d6ecc55c8b9419 Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Wed, 22 Dec 2021 14:36:38 -0500 Subject: [PATCH 27/28] Use predefined function --- Flow.Launcher/ViewModel/MainViewModel.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 5cfbf45f1a7..18ba698ccc0 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -227,13 +227,7 @@ private void InitializeKeyCommands() && !HistorySelected() && !ContextMenuSelected()) { - ChangeQueryText(_history.Items[_history.Items.Count - 1].Query.ToString()); - // Set index to next item if user attempts to continue cycling history - if (_history.Items.Count > 1) - { - lasthistoryindex++; - } - + ReverseHistory.Execute(null); } else { From 43b22725d43205ec8eb4715a46848671d5a9db12 Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Tue, 25 Jan 2022 02:02:48 -0500 Subject: [PATCH 28/28] Remove modifier option from settings GUI --- Flow.Launcher/SettingWindow.xaml | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index 3e2692a2589..59a86f7569e 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -2001,7 +2001,7 @@ - + @@ -2077,7 +2077,7 @@ Style="{StaticResource SettingSeparatorStyle}" /> @@ -2097,34 +2097,6 @@ - - - - - - - - - - - -