diff --git a/Plugins/Flow.Launcher.Plugin.ProcessKiller/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.ProcessKiller/Languages/en.xaml index e7a136114..ea6e54fef 100644 --- a/Plugins/Flow.Launcher.Plugin.ProcessKiller/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.ProcessKiller/Languages/en.xaml @@ -1,6 +1,7 @@ - + Process Killer Kill running processes from Flow Launcher @@ -9,4 +10,6 @@ kill {0} processes kill all instances + Put processes with visible windows on the top + \ No newline at end of file diff --git a/Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs b/Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs index b44ecd99c..9ab1502a2 100644 --- a/Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs @@ -1,18 +1,27 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Windows.Controls; +using Flow.Launcher.Plugin.ProcessKiller.ViewModels; +using Flow.Launcher.Plugin.ProcessKiller.Views; namespace Flow.Launcher.Plugin.ProcessKiller { - public class Main : IPlugin, IPluginI18n, IContextMenu + public class Main : IPlugin, IPluginI18n, IContextMenu, ISettingProvider { private readonly ProcessHelper processHelper = new(); private static PluginInitContext _context; + internal Settings Settings; + + private SettingsViewModel _viewModel; + public void Init(PluginInitContext context) { _context = context; + Settings = context.API.LoadSettingJsonStorage(); + _viewModel = new SettingsViewModel(Settings); } public List Query(Query query) @@ -83,7 +92,7 @@ namespace Flow.Launcher.Plugin.ProcessKiller { // Add score to prioritize processes with visible windows // And use window title for those processes - processlist.Add(new ProcessResult(p, 200, windowTitle, null, progressNameIdTitle)); + processlist.Add(new ProcessResult(p, Settings.PutVisibleWindowProcessesTop ? 200 : 0, windowTitle, null, progressNameIdTitle)); } else { @@ -107,7 +116,10 @@ namespace Flow.Launcher.Plugin.ProcessKiller { // Add score to prioritize processes with visible windows // And use window title for those processes - score += 200; + if (Settings.PutVisibleWindowProcessesTop) + { + score += 200; + } processlist.Add(new ProcessResult(p, score, windowTitle, score == windowTitleMatch.Score ? windowTitleMatch : null, progressNameIdTitle)); } @@ -176,5 +188,10 @@ namespace Flow.Launcher.Plugin.ProcessKiller return sortedResults; } + + public Control CreateSettingPanel() + { + return new SettingsControl(_viewModel); + } } } diff --git a/Plugins/Flow.Launcher.Plugin.ProcessKiller/Settings.cs b/Plugins/Flow.Launcher.Plugin.ProcessKiller/Settings.cs new file mode 100644 index 000000000..916bc6a39 --- /dev/null +++ b/Plugins/Flow.Launcher.Plugin.ProcessKiller/Settings.cs @@ -0,0 +1,7 @@ +namespace Flow.Launcher.Plugin.ProcessKiller +{ + public class Settings + { + public bool PutVisibleWindowProcessesTop { get; set; } = false; + } +} diff --git a/Plugins/Flow.Launcher.Plugin.ProcessKiller/ViewModels/SettingsViewModel.cs b/Plugins/Flow.Launcher.Plugin.ProcessKiller/ViewModels/SettingsViewModel.cs new file mode 100644 index 000000000..bacf1ba08 --- /dev/null +++ b/Plugins/Flow.Launcher.Plugin.ProcessKiller/ViewModels/SettingsViewModel.cs @@ -0,0 +1,18 @@ +namespace Flow.Launcher.Plugin.ProcessKiller.ViewModels +{ + public class SettingsViewModel + { + public Settings Settings { get; set; } + + public SettingsViewModel(Settings settings) + { + Settings = settings; + } + + public bool PutVisibleWindowProcessesTop + { + get => Settings.PutVisibleWindowProcessesTop; + set => Settings.PutVisibleWindowProcessesTop = value; + } + } +} diff --git a/Plugins/Flow.Launcher.Plugin.ProcessKiller/Views/SettingsControl.xaml b/Plugins/Flow.Launcher.Plugin.ProcessKiller/Views/SettingsControl.xaml new file mode 100644 index 000000000..d15d6c3e0 --- /dev/null +++ b/Plugins/Flow.Launcher.Plugin.ProcessKiller/Views/SettingsControl.xaml @@ -0,0 +1,22 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Plugins/Flow.Launcher.Plugin.ProcessKiller/Views/SettingsControl.xaml.cs b/Plugins/Flow.Launcher.Plugin.ProcessKiller/Views/SettingsControl.xaml.cs new file mode 100644 index 000000000..ad7229417 --- /dev/null +++ b/Plugins/Flow.Launcher.Plugin.ProcessKiller/Views/SettingsControl.xaml.cs @@ -0,0 +1,18 @@ +using System.Windows.Controls; +using Flow.Launcher.Plugin.ProcessKiller.ViewModels; + +namespace Flow.Launcher.Plugin.ProcessKiller.Views; + +public partial class SettingsControl : UserControl +{ + private readonly SettingsViewModel _viewModel; + + public SettingsControl(SettingsViewModel viewModel) + { + InitializeComponent(); + + _viewModel = viewModel; + + DataContext = viewModel; + } +}