From ab52859461f5142e5d6cb37a527b349708637931 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Mon, 12 Apr 2021 14:25:39 +1000 Subject: [PATCH 1/6] save cmd history to settings --- Plugins/Flow.Launcher.Plugin.Shell/Settings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Shell/Settings.cs b/Plugins/Flow.Launcher.Plugin.Shell/Settings.cs index 7294630bb5f..8c745f326da 100644 --- a/Plugins/Flow.Launcher.Plugin.Shell/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Shell/Settings.cs @@ -9,7 +9,7 @@ public class Settings public bool LeaveShellOpen { get; set; } public bool RunAsAdministrator { get; set; } = true; - public Dictionary Count = new Dictionary(); + public Dictionary Count { get; set; } = new Dictionary(); public void AddCmdHistory(string cmdName) { From 4abddb2597bae3345798d6931b20565e492e7f08 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Mon, 12 Apr 2021 17:32:48 +1000 Subject: [PATCH 2/6] rename variable Count to CommandHistory --- Plugins/Flow.Launcher.Plugin.Shell/Main.cs | 4 ++-- Plugins/Flow.Launcher.Plugin.Shell/Settings.cs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Shell/Main.cs b/Plugins/Flow.Launcher.Plugin.Shell/Main.cs index bd316a6bfd7..fce934afbea 100644 --- a/Plugins/Flow.Launcher.Plugin.Shell/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Shell/Main.cs @@ -102,7 +102,7 @@ public List Query(Query query) private List GetHistoryCmds(string cmd, Result result) { - IEnumerable history = _settings.Count.Where(o => o.Key.Contains(cmd)) + IEnumerable history = _settings.CommandHistory.Where(o => o.Key.Contains(cmd)) .OrderByDescending(o => o.Value) .Select(m => { @@ -148,7 +148,7 @@ private Result GetCurrentCmd(string cmd) private List ResultsFromlHistory() { - IEnumerable history = _settings.Count.OrderByDescending(o => o.Value) + IEnumerable history = _settings.CommandHistory.OrderByDescending(o => o.Value) .Select(m => new Result { Title = m.Key, diff --git a/Plugins/Flow.Launcher.Plugin.Shell/Settings.cs b/Plugins/Flow.Launcher.Plugin.Shell/Settings.cs index 8c745f326da..58ac41fc3a6 100644 --- a/Plugins/Flow.Launcher.Plugin.Shell/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Shell/Settings.cs @@ -9,17 +9,17 @@ public class Settings public bool LeaveShellOpen { get; set; } public bool RunAsAdministrator { get; set; } = true; - public Dictionary Count { get; set; } = new Dictionary(); + public Dictionary CommandHistory { get; set; } = new Dictionary(); public void AddCmdHistory(string cmdName) { - if (Count.ContainsKey(cmdName)) + if (CommandHistory.ContainsKey(cmdName)) { - Count[cmdName] += 1; + CommandHistory[cmdName] += 1; } else { - Count.Add(cmdName, 1); + CommandHistory.Add(cmdName, 1); } } } From 04156d7f83fdaaa8edcf6cc4c7b4a8dd791a8dde Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Mon, 12 Apr 2021 17:33:23 +1000 Subject: [PATCH 3/6] Shell plugin version bump --- Plugins/Flow.Launcher.Plugin.Shell/plugin.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Shell/plugin.json b/Plugins/Flow.Launcher.Plugin.Shell/plugin.json index 592dbdbbd04..80750477463 100644 --- a/Plugins/Flow.Launcher.Plugin.Shell/plugin.json +++ b/Plugins/Flow.Launcher.Plugin.Shell/plugin.json @@ -4,7 +4,7 @@ "Name": "Shell", "Description": "Provide executing commands from Flow Launcher", "Author": "qianlifeng", - "Version": "1.2.0", + "Version": "1.3.0", "Language": "csharp", "Website": "https://github.com/Flow-Launcher/Flow.Launcher", "ExecuteFileName": "Flow.Launcher.Plugin.Shell.dll", From 67097864faafb98ad9f621eca013799e6b2ac0b0 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Mon, 12 Apr 2021 19:06:44 +1000 Subject: [PATCH 4/6] add settings for number of most used cmds option --- .../Languages/en.xaml | 1 + .../Flow.Launcher.Plugin.Shell/Settings.cs | 7 ++++ .../ShellSetting.xaml | 3 ++ .../ShellSetting.xaml.cs | 42 ++++++++++++++++++- 4 files changed, 52 insertions(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Shell/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Shell/Languages/en.xaml index 8665e17bb7d..8b312bc93d5 100644 --- a/Plugins/Flow.Launcher.Plugin.Shell/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Shell/Languages/en.xaml @@ -12,4 +12,5 @@ execute command through command shell Run As Administrator Copy the command + Only show number of most used commands: \ No newline at end of file diff --git a/Plugins/Flow.Launcher.Plugin.Shell/Settings.cs b/Plugins/Flow.Launcher.Plugin.Shell/Settings.cs index 58ac41fc3a6..042fd0dd39f 100644 --- a/Plugins/Flow.Launcher.Plugin.Shell/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Shell/Settings.cs @@ -5,10 +5,17 @@ namespace Flow.Launcher.Plugin.Shell public class Settings { public Shell Shell { get; set; } = Shell.Cmd; + public bool ReplaceWinR { get; set; } = true; + public bool LeaveShellOpen { get; set; } + public bool RunAsAdministrator { get; set; } = true; + public bool ShowOnlyMostUsedCMDs { get; set; } + + public int ShowOnlyMostUsedCMDsNumber { get; set; } + public Dictionary CommandHistory { get; set; } = new Dictionary(); public void AddCmdHistory(string cmdName) diff --git a/Plugins/Flow.Launcher.Plugin.Shell/ShellSetting.xaml b/Plugins/Flow.Launcher.Plugin.Shell/ShellSetting.xaml index e27297e05ed..4cd4d8fa3a8 100644 --- a/Plugins/Flow.Launcher.Plugin.Shell/ShellSetting.xaml +++ b/Plugins/Flow.Launcher.Plugin.Shell/ShellSetting.xaml @@ -12,6 +12,7 @@ + @@ -21,5 +22,7 @@ PowerShell RunCommand + + diff --git a/Plugins/Flow.Launcher.Plugin.Shell/ShellSetting.xaml.cs b/Plugins/Flow.Launcher.Plugin.Shell/ShellSetting.xaml.cs index 82260fcad40..749e9ec80c9 100644 --- a/Plugins/Flow.Launcher.Plugin.Shell/ShellSetting.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Shell/ShellSetting.xaml.cs @@ -1,4 +1,5 @@ -using System.Windows; +using System.Collections.Generic; +using System.Windows; using System.Windows.Controls; namespace Flow.Launcher.Plugin.Shell @@ -16,9 +17,26 @@ public CMDSetting(Settings settings) private void CMDSetting_OnLoaded(object sender, RoutedEventArgs re) { ReplaceWinR.IsChecked = _settings.ReplaceWinR; + LeaveShellOpen.IsChecked = _settings.LeaveShellOpen; + AlwaysRunAsAdministrator.IsChecked = _settings.RunAsAdministrator; + LeaveShellOpen.IsEnabled = _settings.Shell != Shell.RunCommand; + + ShowOnlyMostUsedCMDs.IsChecked = _settings.ShowOnlyMostUsedCMDs; + + if ((bool)!ShowOnlyMostUsedCMDs.IsChecked) + ShowOnlyMostUsedCMDsNumber.IsEnabled = false; + + ShowOnlyMostUsedCMDsNumber.ItemsSource = new List() { 5, 10, 20 }; + + if (_settings.ShowOnlyMostUsedCMDsNumber == 0) + { + ShowOnlyMostUsedCMDsNumber.SelectedIndex = 0; + + _settings.ShowOnlyMostUsedCMDsNumber = (int)ShowOnlyMostUsedCMDsNumber.SelectedItem; + } LeaveShellOpen.Checked += (o, e) => { @@ -44,6 +62,7 @@ private void CMDSetting_OnLoaded(object sender, RoutedEventArgs re) { _settings.ReplaceWinR = true; }; + ReplaceWinR.Unchecked += (o, e) => { _settings.ReplaceWinR = false; @@ -55,6 +74,27 @@ private void CMDSetting_OnLoaded(object sender, RoutedEventArgs re) _settings.Shell = (Shell) ShellComboBox.SelectedIndex; LeaveShellOpen.IsEnabled = _settings.Shell != Shell.RunCommand; }; + + ShowOnlyMostUsedCMDs.Checked += (o, e) => + { + _settings.ShowOnlyMostUsedCMDs = true; + + ShowOnlyMostUsedCMDsNumber.IsEnabled = true; + }; + + ShowOnlyMostUsedCMDs.Unchecked += (o, e) => + { + _settings.ShowOnlyMostUsedCMDs = false; + + ShowOnlyMostUsedCMDsNumber.IsEnabled = false; + }; + + ShowOnlyMostUsedCMDsNumber.SelectedItem = _settings.ShowOnlyMostUsedCMDsNumber; + ShowOnlyMostUsedCMDsNumber.SelectionChanged += (o, e) => + { + _settings.ShowOnlyMostUsedCMDsNumber = (int)ShowOnlyMostUsedCMDsNumber.SelectedItem; + }; + } } } From f053139454d9609732f5aab0e2c021bbefd04ae7 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Mon, 12 Apr 2021 20:05:30 +1000 Subject: [PATCH 5/6] use most used cmds setting --- Plugins/Flow.Launcher.Plugin.Shell/Main.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Shell/Main.cs b/Plugins/Flow.Launcher.Plugin.Shell/Main.cs index fce934afbea..4ec1807939f 100644 --- a/Plugins/Flow.Launcher.Plugin.Shell/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Shell/Main.cs @@ -124,7 +124,11 @@ private List GetHistoryCmds(string cmd, Result result) } }; return ret; - }).Where(o => o != null).Take(4); + }).Where(o => o != null); + + if (_settings.ShowOnlyMostUsedCMDs) + return history.Take(_settings.ShowOnlyMostUsedCMDsNumber).ToList(); + return history.ToList(); } @@ -159,7 +163,11 @@ private List ResultsFromlHistory() Execute(Process.Start, PrepareProcessStartInfo(m.Key)); return true; } - }).Take(5); + }); + + if (_settings.ShowOnlyMostUsedCMDs) + return history.Take(_settings.ShowOnlyMostUsedCMDsNumber).ToList(); + return history.ToList(); } From 5791cd4bba6c27ef56834820e555cdbc03ecf965 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Mon, 12 Apr 2021 20:13:39 +1000 Subject: [PATCH 6/6] add tooltip for ShouldUsePinyin settings --- Flow.Launcher/Languages/en.xaml | 1 + Flow.Launcher/SettingWindow.xaml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index 7258e3a9106..6232492baf0 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -36,6 +36,7 @@ Hide tray icon Query Search Precision Should Use Pinyin + Allows using Pinyin to search. Pinyin is the standard system of romanized spelling for transliterating Chinese Plugin diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index 23b741575d3..651d7db09a2 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -63,7 +63,7 @@ - +