Merge pull request #1669 from VictoriousRaptor/DisablePATHByDefault

Add option to enable/disable UWP indexing
This commit is contained in:
VictoriousRaptor 2022-12-22 13:17:05 +08:00 committed by GitHub
commit bade0fcf59
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 41 additions and 11 deletions

View file

@ -22,6 +22,8 @@
<system:String x:Key="flowlauncher_plugin_program_indexing">Indexing</system:String>
<system:String x:Key="flowlauncher_plugin_program_index_source">Index Sources</system:String>
<system:String x:Key="flowlauncher_plugin_program_index_option">Options</system:String>
<system:String x:Key="flowlauncher_plugin_program_index_uwp">UWP Apps</system:String>
<system:String x:Key="flowlauncher_plugin_program_index_uwp_tooltip">When enabled, Flow will load UWP Applications</system:String>
<system:String x:Key="flowlauncher_plugin_program_index_start">Start Menu</system:String>
<system:String x:Key="flowlauncher_plugin_program_index_start_tooltip">When enabled, Flow will load programs from the start menu</system:String>
<system:String x:Key="flowlauncher_plugin_program_index_registry">Registry</system:String>

View file

@ -5,7 +5,6 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Controls;
using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure.Logger;
using Flow.Launcher.Infrastructure.Storage;
using Flow.Launcher.Plugin.Program.Programs;
@ -115,9 +114,7 @@ namespace Flow.Launcher.Plugin.Program
public static void IndexUwpPrograms()
{
var windows10 = new Version(10, 0);
var support = Environment.OSVersion.Version.Major >= windows10.Major;
var applications = support ? UWP.All() : Array.Empty<UWP.Application>();
var applications = UWP.All(_settings);
_uwps = applications;
ResetCache();
}

View file

@ -199,11 +199,10 @@ namespace Flow.Launcher.Plugin.Program.Programs
},
};
public static Application[] All()
public static Application[] All(Settings settings)
{
var windows10 = new Version(10, 0);
var support = Environment.OSVersion.Version.Major >= windows10.Major;
if (support)
var support = SupportUWP();
if (support && settings.EnableUWP)
{
var applications = CurrentUserPackages().AsParallel().SelectMany(p =>
{
@ -241,6 +240,13 @@ namespace Flow.Launcher.Plugin.Program.Programs
}
}
public static bool SupportUWP()
{
var windows10 = new Version(10, 0);
var support = Environment.OSVersion.Version.Major >= windows10.Major;
return support;
}
private static IEnumerable<Package> CurrentUserPackages()
{
var u = WindowsIdentity.GetCurrent().User;

View file

@ -119,6 +119,7 @@ namespace Flow.Launcher.Plugin.Program
public bool HideAppsPath { get; set; } = true;
public bool EnableRegistrySource { get; set; } = true;
public bool EnablePathSource { get; set; } = false;
public bool EnableUWP { get; set; } = true;
public string CustomizedExplorer { get; set; } = Explorer;
public string CustomizedArgs { get; set; } = ExplorerArgs;

View file

@ -7,6 +7,9 @@
Height="520"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
mc:Ignorable="d">
<UserControl.Resources>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
</UserControl.Resources>
<Grid Margin="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
@ -27,6 +30,13 @@
Margin="0,0,14,0"
HorizontalAlignment="Right"
DockPanel.Dock="Right">
<CheckBox
Name="UWPEnabled"
Margin="12,0,12,0"
Visibility="{Binding ShowUWPCheckbox, Converter={StaticResource BooleanToVisibilityConverter}}"
Content="{DynamicResource flowlauncher_plugin_program_index_uwp}"
IsChecked="{Binding EnableUWP}"
ToolTip="{DynamicResource flowlauncher_plugin_program_index_uwp_tooltip}" />
<CheckBox
Name="StartMenuEnabled"
Margin="12,0,12,0"
@ -39,7 +49,6 @@
Content="{DynamicResource flowlauncher_plugin_program_index_registry}"
IsChecked="{Binding EnableRegistrySource}"
ToolTip="{DynamicResource flowlauncher_plugin_program_index_registry_tooltip}" />
<CheckBox
Name="PATHEnabled"
Margin="12,0,12,0"

View file

@ -77,6 +77,16 @@ namespace Flow.Launcher.Plugin.Program.Views
}
}
public bool EnableUWP
{
get => _settings.EnableUWP;
set
{
_settings.EnableUWP = value;
ReIndexing();
}
}
public string CustomizedExplorerPath
{
get => _settings.CustomizedExplorer;
@ -89,6 +99,8 @@ namespace Flow.Launcher.Plugin.Program.Views
set => _settings.CustomizedArgs = value;
}
public bool ShowUWPCheckbox => UWP.SupportUWP();
public ProgramSetting(PluginInitContext context, Settings settings, Win32[] win32s, UWP.Application[] uwps)
{
this.context = context;
@ -383,8 +395,11 @@ namespace Flow.Launcher.Plugin.Program.Views
private void programSourceView_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
var selectedProgramSource = programSourceView.SelectedItem as ProgramSource;
EditProgramSource(selectedProgramSource);
if (((FrameworkElement)e.OriginalSource).DataContext is ProgramSource)
{
var selectedProgramSource = programSourceView.SelectedItem as ProgramSource;
EditProgramSource(selectedProgramSource);
}
}
private bool IsAllItemsUserAdded(List<ProgramSource> items)