Merge pull request #2508 from flooxo/open_target

Add open target for program shortcuts
This commit is contained in:
Jeremy Wu 2024-03-31 15:07:03 +11:00 committed by GitHub
commit 27962154f4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 29 additions and 5 deletions

View file

@ -73,6 +73,7 @@
<system:String x:Key="flowlauncher_plugin_program_run_as_administrator">Run As Administrator</system:String>
<system:String x:Key="flowlauncher_plugin_program_open_containing_folder">Open containing folder</system:String>
<system:String x:Key="flowlauncher_plugin_program_disable_program">Disable this program from displaying</system:String>
<system:String x:Key="flowlauncher_plugin_program_open_target_folder">Open target folder</system:String>
<system:String x:Key="flowlauncher_plugin_program_plugin_name">Program</system:String>
<system:String x:Key="flowlauncher_plugin_program_plugin_description">Search programs in Flow Launcher</system:String>

View file

@ -39,15 +39,20 @@ namespace Flow.Launcher.Plugin.Program.Programs
public string FullPath { get; set; }
/// <summary>
/// Path of the executable for .lnk, or the URL for .url. Arguments are included if any.
/// Path of the executable for .lnk, or the URL for .url
/// </summary>
public string LnkResolvedPath { get; set; }
/// <summary>
/// Path of the actual executable file. Args are included.
/// Path of the actual executable file
/// </summary>
public string ExecutablePath => LnkResolvedPath ?? FullPath;
/// <summary>
/// Arguments for the executable.
/// </summary>
public string Args { get; set; }
public string ParentDirectory { get; set; }
/// <summary>
@ -261,11 +266,29 @@ namespace Flow.Launcher.Plugin.Program.Programs
},
IcoPath = "Images/folder.png",
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\xe838"),
}
},
};
if (Extension(FullPath) == ShortcutExtension)
{
contextMenus.Add(OpenTargetFolderContextMenuResult(api));
}
return contextMenus;
}
private Result OpenTargetFolderContextMenuResult(IPublicAPI api)
{
return new Result
{
Title = api.GetTranslation("flowlauncher_plugin_program_open_target_folder"),
Action = _ =>
{
api.OpenDirectory(Path.GetDirectoryName(ExecutablePath), ExecutablePath);
return true;
},
IcoPath = "Images/folder.png",
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\xe8de"),
};
}
public override string ToString()
{
@ -327,7 +350,7 @@ namespace Flow.Launcher.Plugin.Program.Programs
var args = _helper.arguments;
if (!string.IsNullOrEmpty(args))
{
program.LnkResolvedPath += " " + args;
program.Args = args;
}
var description = _helper.description;
@ -624,7 +647,7 @@ namespace Flow.Launcher.Plugin.Program.Programs
private static IEnumerable<Win32> ProgramsHasher(IEnumerable<Win32> programs)
{
var startMenuPaths = GetStartMenuPaths();
return programs.GroupBy(p => p.ExecutablePath.ToLowerInvariant())
return programs.GroupBy(p => (p.ExecutablePath + p.Args).ToLowerInvariant())
.AsParallel()
.SelectMany(g =>
{