From 5373cd373646ceb069c35715f086481f30cae34b Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sat, 17 Dec 2022 21:29:25 +0800 Subject: [PATCH 1/5] Disable PATH programs by default --- Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs | 2 +- Plugins/Flow.Launcher.Plugin.Program/Settings.cs | 2 +- .../Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index e89970fb4bd..f8c2206101e 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -620,7 +620,7 @@ public static Win32[] All(Settings settings) autoIndexPrograms = autoIndexPrograms.Concat(startMenu); } - if (settings.EnablePATHSource) + if (settings.EnablePathSource) { var path = PATHPrograms(settings.GetSuffixes(), protocols, commonParents); programs = programs.Concat(path); diff --git a/Plugins/Flow.Launcher.Plugin.Program/Settings.cs b/Plugins/Flow.Launcher.Plugin.Program/Settings.cs index e3e8b99b9b2..34da42f1f48 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Settings.cs @@ -118,7 +118,7 @@ private void RemoveRedundantSuffixes() public bool EnableDescription { get; set; } = false; public bool HideAppsPath { get; set; } = true; public bool EnableRegistrySource { get; set; } = true; - public bool EnablePATHSource { get; set; } = true; + public bool EnablePathSource { get; set; } = false; public string CustomizedExplorer { get; set; } = Explorer; public string CustomizedArgs { get; set; } = ExplorerArgs; diff --git a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs index 7da224b698f..4abb39225ea 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs @@ -69,10 +69,10 @@ public bool EnableStartMenuSource public bool EnablePATHSource { - get => _settings.EnablePATHSource; + get => _settings.EnablePathSource; set { - _settings.EnablePATHSource = value; + _settings.EnablePathSource = value; ReIndexing(); } } From 1d77d45fe276e691abe0042080aa039ca2279b21 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sat, 17 Dec 2022 22:00:04 +0800 Subject: [PATCH 2/5] Add an option to enable/dsiable UWP indexing --- .../Languages/en.xaml | 2 ++ Plugins/Flow.Launcher.Plugin.Program/Main.cs | 5 +---- .../Programs/UWP.cs | 18 ++++++++++++++---- .../Flow.Launcher.Plugin.Program/Settings.cs | 1 + .../Views/ProgramSetting.xaml | 11 ++++++++++- .../Views/ProgramSetting.xaml.cs | 12 ++++++++++++ 6 files changed, 40 insertions(+), 9 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml index 8d642b60053..fb663f1a4b5 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml @@ -22,6 +22,8 @@ Indexing Index Sources Options + UWP Apps + When enabled, Flow will load UWP Applications Start Menu When enabled, Flow will load programs from the start menu Registry diff --git a/Plugins/Flow.Launcher.Plugin.Program/Main.cs b/Plugins/Flow.Launcher.Plugin.Program/Main.cs index c94c1dca2a9..340d882dac4 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Main.cs @@ -5,7 +5,6 @@ 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 @@ public static void IndexWin32Programs() 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(); + var applications = UWP.All(_settings); _uwps = applications; ResetCache(); } diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs index 28641dd003c..35f0814a738 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs @@ -199,11 +199,14 @@ private PackageVersion GetPackageVersionFromManifest(XmlNode xmlRoot) }, }; - 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) + { + settings.EnableUWP = false; + } + if (settings.EnableUWP) { var applications = CurrentUserPackages().AsParallel().SelectMany(p => { @@ -241,6 +244,13 @@ public static Application[] All() } } + public static bool SupportUWP() + { + var windows10 = new Version(10, 0); + var support = Environment.OSVersion.Version.Major >= windows10.Major; + return support; + } + private static IEnumerable CurrentUserPackages() { var u = WindowsIdentity.GetCurrent().User; diff --git a/Plugins/Flow.Launcher.Plugin.Program/Settings.cs b/Plugins/Flow.Launcher.Plugin.Program/Settings.cs index 34da42f1f48..f59facaa4ac 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Settings.cs @@ -119,6 +119,7 @@ private void RemoveRedundantSuffixes() 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; diff --git a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml index 957042de5d3..fa97de4f26e 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml +++ b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml @@ -7,6 +7,9 @@ Height="520" DataContext="{Binding RelativeSource={RelativeSource Self}}" mc:Ignorable="d"> + + + @@ -27,6 +30,13 @@ Margin="0,0,14,0" HorizontalAlignment="Right" DockPanel.Dock="Right"> + - _settings.EnableUWP; + set + { + _settings.EnableUWP = value; + ReIndexing(); + } + } + public string CustomizedExplorerPath { get => _settings.CustomizedExplorer; @@ -89,6 +99,8 @@ public string CustomizedExplorerArg set => _settings.CustomizedArgs = value; } + public bool ShowUWPCheckbox => UWP.SupportUWP(); + public ProgramSetting(PluginInitContext context, Settings settings, Win32[] win32s, UWP.Application[] uwps) { this.context = context; From bf91bd2492c86adc2459cb627cb23d094767ec33 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sat, 17 Dec 2022 22:27:36 +0800 Subject: [PATCH 3/5] Fix double click on header --- .../Views/ProgramSetting.xaml.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs index 163178782a0..4b63d38a586 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs @@ -395,8 +395,11 @@ private void programSourceView_SelectionChanged(object sender, SelectionChangedE 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 items) From d3bae93a47ddce3558acf1f3ac9f6b4942342780 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sun, 18 Dec 2022 13:35:38 +0800 Subject: [PATCH 4/5] Revert "Disable PATH by default" --- Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs | 2 +- Plugins/Flow.Launcher.Plugin.Program/Settings.cs | 2 +- .../Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index f8c2206101e..e89970fb4bd 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -620,7 +620,7 @@ public static Win32[] All(Settings settings) autoIndexPrograms = autoIndexPrograms.Concat(startMenu); } - if (settings.EnablePathSource) + if (settings.EnablePATHSource) { var path = PATHPrograms(settings.GetSuffixes(), protocols, commonParents); programs = programs.Concat(path); diff --git a/Plugins/Flow.Launcher.Plugin.Program/Settings.cs b/Plugins/Flow.Launcher.Plugin.Program/Settings.cs index f59facaa4ac..9fd6d13e7e4 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Settings.cs @@ -118,7 +118,7 @@ private void RemoveRedundantSuffixes() public bool EnableDescription { get; set; } = false; public bool HideAppsPath { get; set; } = true; public bool EnableRegistrySource { get; set; } = true; - public bool EnablePathSource { get; set; } = false; + public bool EnablePATHSource { get; set; } = true; public bool EnableUWP { get; set; } = true; public string CustomizedExplorer { get; set; } = Explorer; diff --git a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs index 4b63d38a586..5b8ae023f13 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs @@ -69,10 +69,10 @@ public bool EnableStartMenuSource public bool EnablePATHSource { - get => _settings.EnablePathSource; + get => _settings.EnablePATHSource; set { - _settings.EnablePathSource = value; + _settings.EnablePATHSource = value; ReIndexing(); } } From b92181f6c68ff6cb81f1d6c0a8105267e9d2e22f Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Tue, 20 Dec 2022 19:48:10 +0800 Subject: [PATCH 5/5] Remove logic that modifies settings --- Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs index 35f0814a738..d0070f83374 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs @@ -202,11 +202,7 @@ private PackageVersion GetPackageVersionFromManifest(XmlNode xmlRoot) public static Application[] All(Settings settings) { var support = SupportUWP(); - if (!support && settings.EnableUWP) - { - settings.EnableUWP = false; - } - if (settings.EnableUWP) + if (support && settings.EnableUWP) { var applications = CurrentUserPackages().AsParallel().SelectMany(p => {