plugin/pkiller: improve kill-all option

- better title, add count of matches in subtitle, use process icon
- hide option when executable path is empty
This commit is contained in:
Ioannis G 2020-10-11 23:55:35 +03:00
parent 01f98b16fa
commit b1ca71b3aa
No known key found for this signature in database
GPG key ID: EAC0E4E5E36AC49E
2 changed files with 8 additions and 6 deletions

View file

@ -5,7 +5,8 @@
<system:String x:Key="flowlauncher_plugin_processkiller_plugin_name">Process Killer</system:String> <system:String x:Key="flowlauncher_plugin_processkiller_plugin_name">Process Killer</system:String>
<system:String x:Key="flowlauncher_plugin_processkiller_plugin_description">Kill running processes from Flow Launcher</system:String> <system:String x:Key="flowlauncher_plugin_processkiller_plugin_description">Kill running processes from Flow Launcher</system:String>
<system:String x:Key="flowlauncher_plugin_processkiller_kill_all">kill all "{0}" processes</system:String> <system:String x:Key="flowlauncher_plugin_processkiller_kill_all">kill all instances of "{0}"</system:String>
<system:String x:Key="flowlauncher_plugin_processkiller_kill_all_count">kill {0} processes</system:String>
<system:String x:Key="flowlauncher_plugin_processkiller_kill_instances">kill all instances</system:String> <system:String x:Key="flowlauncher_plugin_processkiller_kill_instances">kill all instances</system:String>
</ResourceDictionary> </ResourceDictionary>

View file

@ -89,6 +89,7 @@ namespace Flow.Launcher.Plugin.ProcessKiller
SubTitle = path, SubTitle = path,
TitleHighlightData = StringMatcher.FuzzySearch(termToSearch, p.ProcessName).MatchData, TitleHighlightData = StringMatcher.FuzzySearch(termToSearch, p.ProcessName).MatchData,
Score = pr.Score, Score = pr.Score,
ContextData = p.ProcessName,
Action = (c) => Action = (c) =>
{ {
processHelper.TryKill(p); processHelper.TryKill(p);
@ -101,14 +102,14 @@ namespace Flow.Launcher.Plugin.ProcessKiller
// When there are multiple results AND all of them are instances of the same executable // 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. // add a quick option to kill them all at the top of the results.
var firstResult = sortedResults.FirstOrDefault()?.SubTitle; var firstResult = sortedResults.FirstOrDefault(x => !string.IsNullOrEmpty(x.SubTitle));
if (processlist.Count > 1 && !string.IsNullOrEmpty(termToSearch) && sortedResults.All(r => r.SubTitle == firstResult)) if (processlist.Count > 1 && !string.IsNullOrEmpty(termToSearch) && sortedResults.All(r => r.SubTitle == firstResult?.SubTitle))
{ {
sortedResults.Insert(1, new Result() sortedResults.Insert(1, new Result()
{ {
IcoPath = "Images/app.png", IcoPath = firstResult?.IcoPath,
Title = string.Format(_context.API.GetTranslation("flowlauncher_plugin_processkiller_kill_all"), termToSearch), Title = string.Format(_context.API.GetTranslation("flowlauncher_plugin_processkiller_kill_all"), firstResult?.ContextData),
SubTitle = "", SubTitle = string.Format(_context.API.GetTranslation("flowlauncher_plugin_processkiller_kill_all_count"), processlist.Count),
Score = 200, Score = 200,
Action = (c) => Action = (c) =>
{ {