mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #2726 from Flow-Launcher/plugin-program-hide-uninstallers
Program plugin: add option to hide uninstallers from results
This commit is contained in:
commit
b497c697d8
5 changed files with 44 additions and 3 deletions
|
|
@ -32,6 +32,8 @@
|
|||
<system:String x:Key="flowlauncher_plugin_program_index_PATH_tooltip">When enabled, Flow will load programs from the PATH environment variable</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_program_enable_hidelnkpath">Hide app path</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_program_enable_hidelnkpath_tooltip">For executable files such as UWP or lnk, hide the file path from being visible</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_program_enable_hideuninstallers">Hide uninstallers</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_program_enable_hideuninstallers_tooltip">Hides programs with common uninstaller names, such as unins000.exe</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_program_enable_description">Search in Program Description</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_program_enable_description_tooltip">Flow will search program's description</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_program_suffixes_header">Suffixes</system:String>
|
||||
|
|
@ -92,4 +94,4 @@
|
|||
<system:String x:Key="flowlauncher_plugin_program_run_as_administrator_not_supported_message">This app is not intended to be run as administrator</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_program_run_failed">Unable to run {0}</system:String>
|
||||
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary>
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ using Flow.Launcher.Plugin.Program.Programs;
|
|||
using Flow.Launcher.Plugin.Program.Views;
|
||||
using Flow.Launcher.Plugin.Program.Views.Models;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Path = System.IO.Path;
|
||||
using Stopwatch = Flow.Launcher.Infrastructure.Stopwatch;
|
||||
|
||||
namespace Flow.Launcher.Plugin.Program
|
||||
|
|
@ -33,6 +34,17 @@ namespace Flow.Launcher.Plugin.Program
|
|||
private static readonly MemoryCacheOptions cacheOptions = new() { SizeLimit = 1560 };
|
||||
private static MemoryCache cache = new(cacheOptions);
|
||||
|
||||
private static readonly string[] commonUninstallerNames =
|
||||
{
|
||||
"uninst.exe",
|
||||
"unins000.exe",
|
||||
"uninst000.exe",
|
||||
"uninstall.exe"
|
||||
};
|
||||
// For cases when the uninstaller is named like "Uninstall Program Name.exe"
|
||||
private const string CommonUninstallerPrefix = "uninstall";
|
||||
private const string CommonUninstallerSuffix = ".exe";
|
||||
|
||||
static Main()
|
||||
{
|
||||
}
|
||||
|
|
@ -52,6 +64,7 @@ namespace Flow.Launcher.Plugin.Program
|
|||
.Concat(_uwps)
|
||||
.AsParallel()
|
||||
.WithCancellation(token)
|
||||
.Where(HideUninstallersFilter)
|
||||
.Where(p => p.Enabled)
|
||||
.Select(p => p.Result(query.Search, Context.API))
|
||||
.Where(r => r?.Score > 0)
|
||||
|
|
@ -68,6 +81,16 @@ namespace Flow.Launcher.Plugin.Program
|
|||
return result;
|
||||
}
|
||||
|
||||
private bool HideUninstallersFilter(IProgram program)
|
||||
{
|
||||
if (!_settings.HideUninstallers) return true;
|
||||
if (program is not Win32 win32) return true;
|
||||
var fileName = Path.GetFileName(win32.ExecutablePath);
|
||||
return !commonUninstallerNames.Contains(fileName, StringComparer.OrdinalIgnoreCase) &&
|
||||
!(fileName.StartsWith(CommonUninstallerPrefix, StringComparison.OrdinalIgnoreCase) &&
|
||||
fileName.EndsWith(CommonUninstallerSuffix, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
public async Task InitAsync(PluginInitContext context)
|
||||
{
|
||||
Context = context;
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ namespace Flow.Launcher.Plugin.Program
|
|||
// CustomSuffixes no longer contains custom suffixes
|
||||
// users has tweaked the settings
|
||||
// or this function has been executed once
|
||||
if (UseCustomSuffixes == true || ProgramSuffixes == null)
|
||||
if (UseCustomSuffixes == true || ProgramSuffixes == null)
|
||||
return;
|
||||
var suffixes = ProgramSuffixes.ToList();
|
||||
foreach(var item in BuiltinSuffixesStatus)
|
||||
|
|
@ -117,6 +117,7 @@ namespace Flow.Launcher.Plugin.Program
|
|||
public bool EnableStartMenuSource { get; set; } = true;
|
||||
public bool EnableDescription { get; set; } = false;
|
||||
public bool HideAppsPath { get; set; } = true;
|
||||
public bool HideUninstallers { get; set; } = false;
|
||||
public bool EnableRegistrySource { get; set; } = true;
|
||||
public bool EnablePathSource { get; set; } = false;
|
||||
public bool EnableUWP { get; set; } = true;
|
||||
|
|
|
|||
|
|
@ -85,6 +85,11 @@
|
|||
Content="{DynamicResource flowlauncher_plugin_program_enable_hidelnkpath}"
|
||||
IsChecked="{Binding HideAppsPath}"
|
||||
ToolTip="{DynamicResource flowlauncher_plugin_program_enable_hidelnkpath_tooltip}" />
|
||||
<CheckBox
|
||||
Margin="12 0 12 0"
|
||||
Content="{DynamicResource flowlauncher_plugin_program_enable_hideuninstallers}"
|
||||
IsChecked="{Binding HideUninstallers}"
|
||||
ToolTip="{DynamicResource flowlauncher_plugin_program_enable_hideuninstallers_tooltip}" />
|
||||
<CheckBox
|
||||
Name="DescriptionEnabled"
|
||||
Margin="12,0,12,0"
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ namespace Flow.Launcher.Plugin.Program.Views
|
|||
private ListSortDirection _lastDirection;
|
||||
|
||||
// We do not save all program sources to settings, so using
|
||||
// this as temporary holder for displaying all loaded programs sources.
|
||||
// this as temporary holder for displaying all loaded programs sources.
|
||||
internal static List<ProgramSource> ProgramSettingDisplayList { get; set; }
|
||||
|
||||
public bool EnableDescription
|
||||
|
|
@ -47,6 +47,16 @@ namespace Flow.Launcher.Plugin.Program.Views
|
|||
}
|
||||
}
|
||||
|
||||
public bool HideUninstallers
|
||||
{
|
||||
get => _settings.HideUninstallers;
|
||||
set
|
||||
{
|
||||
Main.ResetCache();
|
||||
_settings.HideUninstallers = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool EnableRegistrySource
|
||||
{
|
||||
get => _settings.EnableRegistrySource;
|
||||
|
|
|
|||
Loading…
Reference in a new issue