Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Flow.Launcher/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<system:String x:Key="hideNotifyIcon">Hide tray icon</system:String>
<system:String x:Key="querySearchPrecision">Query Search Precision</system:String>
<system:String x:Key="ShouldUsePinyin">Should Use Pinyin</system:String>
<system:String x:Key="ShouldUsePinyinToolTip">Allows using Pinyin to search. Pinyin is the standard system of romanized spelling for transliterating Chinese</system:String>

<!--Setting Plugin-->
<system:String x:Key="plugin">Plugin</system:String>
Expand Down
2 changes: 1 addition & 1 deletion Flow.Launcher/SettingWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<ui:ToggleSwitch Margin="10" IsOn="{Binding AutoUpdates}">
<TextBlock Text="{DynamicResource autoUpdates}" />
</ui:ToggleSwitch>
<CheckBox Margin="10" IsChecked="{Binding ShouldUsePinyin}">
<CheckBox Margin="10" IsChecked="{Binding ShouldUsePinyin}" ToolTip="{DynamicResource ShouldUsePinyinToolTip}">
<TextBlock Text="{DynamicResource ShouldUsePinyin}" />
</CheckBox>
<StackPanel Margin="10" Orientation="Horizontal">
Expand Down
1 change: 1 addition & 0 deletions Plugins/Flow.Launcher.Plugin.Shell/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
<system:String x:Key="flowlauncher_plugin_cmd_execute_through_shell">execute command through command shell</system:String>
<system:String x:Key="flowlauncher_plugin_cmd_run_as_administrator">Run As Administrator</system:String>
<system:String x:Key="flowlauncher_plugin_cmd_copy">Copy the command</system:String>
<system:String x:Key="flowlauncher_plugin_cmd_history">Only show number of most used commands:</system:String>
</ResourceDictionary>
16 changes: 12 additions & 4 deletions Plugins/Flow.Launcher.Plugin.Shell/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public List<Result> Query(Query query)

private List<Result> GetHistoryCmds(string cmd, Result result)
{
IEnumerable<Result> history = _settings.Count.Where(o => o.Key.Contains(cmd))
IEnumerable<Result> history = _settings.CommandHistory.Where(o => o.Key.Contains(cmd))
.OrderByDescending(o => o.Value)
.Select(m =>
{
Expand All @@ -124,7 +124,11 @@ private List<Result> 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();
}

Expand All @@ -148,7 +152,7 @@ private Result GetCurrentCmd(string cmd)

private List<Result> ResultsFromlHistory()
{
IEnumerable<Result> history = _settings.Count.OrderByDescending(o => o.Value)
IEnumerable<Result> history = _settings.CommandHistory.OrderByDescending(o => o.Value)
.Select(m => new Result
{
Title = m.Key,
Expand All @@ -159,7 +163,11 @@ private List<Result> ResultsFromlHistory()
Execute(Process.Start, PrepareProcessStartInfo(m.Key));
return true;
}
}).Take(5);
});

if (_settings.ShowOnlyMostUsedCMDs)
return history.Take(_settings.ShowOnlyMostUsedCMDsNumber).ToList();

return history.ToList();
}

Expand Down
15 changes: 11 additions & 4 deletions Plugins/Flow.Launcher.Plugin.Shell/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,28 @@ 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 Dictionary<string, int> Count = new Dictionary<string, int>();
public bool ShowOnlyMostUsedCMDs { get; set; }

public int ShowOnlyMostUsedCMDsNumber { get; set; }

public Dictionary<string, int> CommandHistory { get; set; } = new Dictionary<string, int>();

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);
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions Plugins/Flow.Launcher.Plugin.Shell/ShellSetting.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<CheckBox Grid.Row="0" x:Name="ReplaceWinR" Content="{DynamicResource flowlauncher_plugin_cmd_relace_winr}" Margin="10" HorizontalAlignment="Left"/>
<CheckBox Grid.Row="1" x:Name="LeaveShellOpen" Content="{DynamicResource flowlauncher_plugin_cmd_leave_cmd_open}" Margin="10" HorizontalAlignment="Left"/>
Expand All @@ -21,5 +22,7 @@
<ComboBoxItem>PowerShell</ComboBoxItem>
<ComboBoxItem>RunCommand</ComboBoxItem>
</ComboBox>
<CheckBox Grid.Row ="4" x:Name="ShowOnlyMostUsedCMDs" Content="{DynamicResource flowlauncher_plugin_cmd_history}" Margin="10 10 0 0"/>
<ComboBox Grid.Row="4" x:Name="ShowOnlyMostUsedCMDsNumber" Margin="330 20 10 10" HorizontalAlignment="Left" />
</Grid>
</UserControl>
42 changes: 41 additions & 1 deletion Plugins/Flow.Launcher.Plugin.Shell/ShellSetting.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Windows;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;

namespace Flow.Launcher.Plugin.Shell
Expand All @@ -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<int>() { 5, 10, 20 };

if (_settings.ShowOnlyMostUsedCMDsNumber == 0)
{
ShowOnlyMostUsedCMDsNumber.SelectedIndex = 0;

_settings.ShowOnlyMostUsedCMDsNumber = (int)ShowOnlyMostUsedCMDsNumber.SelectedItem;
}

LeaveShellOpen.Checked += (o, e) =>
{
Expand All @@ -44,6 +62,7 @@ private void CMDSetting_OnLoaded(object sender, RoutedEventArgs re)
{
_settings.ReplaceWinR = true;
};

ReplaceWinR.Unchecked += (o, e) =>
{
_settings.ReplaceWinR = false;
Expand All @@ -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;
};

}
}
}
2 changes: 1 addition & 1 deletion Plugins/Flow.Launcher.Plugin.Shell/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down