From 750cfa44c1227f9ca77c8fec4fd081482916a52d Mon Sep 17 00:00:00 2001 From: Tai Le Date: Sun, 16 Oct 2022 16:25:47 +0700 Subject: [PATCH 01/18] Support .url file --- Flow.Launcher/ViewModel/ResultViewModel.cs | 6 ++-- .../Flow.Launcher.Plugin.Program.csproj | 1 + .../Programs/Win32.cs | 33 +++++++++++++++++++ .../Flow.Launcher.Plugin.Program/Settings.cs | 2 +- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/Flow.Launcher/ViewModel/ResultViewModel.cs b/Flow.Launcher/ViewModel/ResultViewModel.cs index a188cd357e1..458aa498f4b 100644 --- a/Flow.Launcher/ViewModel/ResultViewModel.cs +++ b/Flow.Launcher/ViewModel/ResultViewModel.cs @@ -163,15 +163,17 @@ private async ValueTask LoadImageAsync() } } + var loadFullImage = (Path.GetExtension(imagePath) ?? "").Equals(".url", StringComparison.OrdinalIgnoreCase); + if (ImageLoader.CacheContainImage(imagePath)) { // will get here either when icoPath has value\icon delegate is null\when had exception in delegate - image = ImageLoader.Load(imagePath); + image = ImageLoader.Load(imagePath, loadFullImage); return; } // We need to modify the property not field here to trigger the OnPropertyChanged event - Image = await Task.Run(() => ImageLoader.Load(imagePath)).ConfigureAwait(false); + Image = await Task.Run(() => ImageLoader.Load(imagePath, loadFullImage)).ConfigureAwait(false); } public Result Result { get; } diff --git a/Plugins/Flow.Launcher.Plugin.Program/Flow.Launcher.Plugin.Program.csproj b/Plugins/Flow.Launcher.Plugin.Program/Flow.Launcher.Plugin.Program.csproj index 2809e0b5cfa..83f9464c436 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Flow.Launcher.Plugin.Program.csproj +++ b/Plugins/Flow.Launcher.Plugin.Program/Flow.Launcher.Plugin.Program.csproj @@ -58,6 +58,7 @@ + diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index 6a8b232e94e..54e4dfa8064 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -16,7 +16,10 @@ using System.Diagnostics; using Stopwatch = Flow.Launcher.Infrastructure.Stopwatch; using System.Diagnostics.CodeAnalysis; +using System.Text.RegularExpressions; using System.Threading.Channels; +using Flow.Launcher.Infrastructure.Image; +using IniParser; namespace Flow.Launcher.Plugin.Program.Programs { @@ -36,6 +39,7 @@ public class Win32 : IProgram, IEquatable public string Location => ParentDirectory; private const string ShortcutExtension = "lnk"; + private const string UrlExtension = "url"; private const string ExeExtension = "exe"; private static readonly Win32 Default = new Win32() @@ -287,6 +291,33 @@ private static Win32 LnkProgram(string path) #endif } + private static Win32 UrlProgram(string path) + { + var program = Win32Program(path); + + var parser = new FileIniDataParser(); + var data = parser.ReadFile(path); + + try + { + var urlSection = data["InternetShortcut"]; + + program.LnkResolvedPath = urlSection["URL"]; + + var iconPath = urlSection["IconFile"]; + if (Path.GetExtension(iconPath).Equals(".ico", StringComparison.OrdinalIgnoreCase)) + { + program.IcoPath = iconPath; + } + } + catch (Exception e) + { + // Many files do not have the required fields, so no logging is done. + } + + return program; + } + private static Win32 ExeProgram(string path) { try @@ -343,6 +374,7 @@ private static IEnumerable UnregisteredPrograms(List ExeProgram(x), ShortcutExtension => LnkProgram(x), + UrlExtension => UrlProgram(x), _ => Win32Program(x) }); @@ -365,6 +397,7 @@ private static IEnumerable StartMenuPrograms(string[] suffixes) .Select(x => Extension(x) switch { ShortcutExtension => LnkProgram(x), + UrlExtension => UrlProgram(x), _ => Win32Program(x) }).Where(x => x.Valid); return programs; diff --git a/Plugins/Flow.Launcher.Plugin.Program/Settings.cs b/Plugins/Flow.Launcher.Plugin.Program/Settings.cs index d97ddd9932a..d5f49238929 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Settings.cs @@ -9,7 +9,7 @@ public class Settings public DateTime LastIndexTime { get; set; } public List ProgramSources { get; set; } = new List(); public List DisabledProgramSources { get; set; } = new List(); - public string[] ProgramSuffixes { get; set; } = {"appref-ms", "exe", "lnk"}; + public string[] ProgramSuffixes { get; set; } = {"appref-ms", "exe", "lnk", "url"}; public bool EnableStartMenuSource { get; set; } = true; From b559ad1980790ee080f5f359670fe8150bd92a1e Mon Sep 17 00:00:00 2001 From: DB p Date: Sat, 22 Oct 2022 15:39:40 +0900 Subject: [PATCH 02/18] Adjust Text / Change Button / Add Layout --- .../Languages/en.xaml | 4 +- .../ProgramSuffixes.xaml | 51 +++++++++++++++++-- 2 files changed, 50 insertions(+), 5 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml index 8d8cae02c9f..4274f165b6f 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml @@ -12,7 +12,7 @@ Disable Location All Programs - File Suffixes + File Type Reindex Indexing Index Start Menu @@ -35,7 +35,7 @@ Are you sure you want to delete the selected program sources? OK - Flow Launcher will only index files that end with the following suffixes. (Each suffix should split by ';' ) + Flow Launcher will only index files that end with the following file types. Successfully updated file suffixes File suffixes can't be empty diff --git a/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml b/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml index e5f4041410f..326ca6a65e7 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml +++ b/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml @@ -5,7 +5,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Title="{DynamicResource flowlauncher_plugin_program_suffixes}" - Width="400" + Width="700" Background="{DynamicResource PopuBGColor}" Foreground="{DynamicResource PopupTextColor}" ResizeMode="NoResize" @@ -17,7 +17,7 @@ - + @@ -55,7 +55,9 @@ + + - + + + + + + + + + + Excutable Types + + appref-ms + EXE + Lnk + Custom File Types + + + + + + + URL Types + + Steam Games + Epic Games + Http/Https + Custom URL Protocols + + + + Date: Sat, 22 Oct 2022 17:21:45 +0900 Subject: [PATCH 03/18] - Adjust Strings - Add Auto Hide Styles --- .../Languages/en.xaml | 14 +- .../ProgramSuffixes.xaml | 130 ++++++++++++++---- 2 files changed, 117 insertions(+), 27 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml index 4274f165b6f..c77b070acc3 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml @@ -4,6 +4,7 @@ xmlns:system="clr-namespace:System;assembly=mscorlib"> + Reset Default Delete Edit Add @@ -35,10 +36,21 @@ Are you sure you want to delete the selected program sources? OK - Flow Launcher will only index files that end with the following file types. + Program Plugin will only index files that end with the following file types. Successfully updated file suffixes File suffixes can't be empty + Excutable Types + URL Types + Custom URL Types + Custom File Types + + Insert file types what you want, Each file type should split by ';'. (ex>bat; py;) + + + Insert protocol types what you want, Each protocol type should split by ';'. (ex>steam; epic;) + + Run As Different User Run As Administrator Open containing folder diff --git a/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml b/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml index 326ca6a65e7..496073c26c7 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml +++ b/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml @@ -4,8 +4,9 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:ui="http://schemas.modernwpf.com/2019" Title="{DynamicResource flowlauncher_plugin_program_suffixes}" - Width="700" + Width="600" Background="{DynamicResource PopuBGColor}" Foreground="{DynamicResource PopupTextColor}" ResizeMode="NoResize" @@ -15,6 +16,49 @@ + + + + + + + + + @@ -70,47 +114,74 @@ FontSize="14" Text="{DynamicResource flowlauncher_plugin_program_only_index_tip}" TextWrapping="Wrap" /> + + + + + + + + + - + - - + + - + - Excutable Types - - appref-ms - EXE - Lnk - Custom File Types - + FontSize="16" + FontWeight="SemiBold" + Text="{DynamicResource flowlauncher_plugin_program_suffixes_excutable_types}" /> + appref-ms + EXE + Lnk + + - URL Types - - Steam Games - Epic Games - Http/Https - Custom URL Protocols - + FontSize="16" + FontWeight="SemiBold" + Text="{DynamicResource flowlauncher_plugin_program_suffixes_URL_types}" /> + Steam Games + Epic Games + Http/Https + + @@ -123,11 +194,18 @@ BorderThickness="0,1,0,0">