Merge pull request #2489 from flooxo/open_with

feat: Add open with option for files in context menu
This commit is contained in:
Kevin Zhang 2024-01-21 10:53:00 -06:00 committed by GitHub
commit f927f3aa83
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 1 deletions

View file

@ -54,6 +54,11 @@ namespace Flow.Launcher.Plugin.Explorer
contextMenus.Add(CreateOpenContainingFolderResult(record));
if (record.Type == ResultType.File)
{
contextMenus.Add(CreateOpenWithMenu(record));
}
if (record.WindowsIndexed)
{
contextMenus.Add(CreateOpenWindowsIndexingOptions());
@ -434,6 +439,22 @@ namespace Flow.Launcher.Plugin.Explorer
};
}
private Result CreateOpenWithMenu(SearchResult record)
{
return new Result
{
Title = Context.API.GetTranslation("plugin_explorer_openwith"),
SubTitle = Context.API.GetTranslation("plugin_explorer_openwith_subtitle"),
Action = _ =>
{
Process.Start("rundll32.exe", $"{Path.Combine(Environment.SystemDirectory, "shell32.dll")},OpenAs_RunDLL {record.FullPath}");
return true;
},
IcoPath = Constants.ShowContextMenuImagePath,
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\ue7ac"),
};
}
private void LogException(string message, Exception e)
{
Log.Exception($"|Flow.Launcher.Plugin.Folder.ContextMenu|{message}", e);

View file

@ -102,7 +102,9 @@
<system:String x:Key="plugin_explorer_remove_from_quickaccess_title">Remove from Quick Access</system:String>
<system:String x:Key="plugin_explorer_remove_from_quickaccess_subtitle">Remove current item from Quick Access</system:String>
<system:String x:Key="plugin_explorer_show_contextmenu_title">Show Windows Context Menu</system:String>
<system:String x:Key="plugin_explorer_openwith">Open With</system:String>
<system:String x:Key="plugin_explorer_openwith_subtitle">Select a program to open with</system:String>
<!-- Special Results-->
<system:String x:Key="plugin_explorer_diskfreespace">{0} free of {1}</system:String>
<system:String x:Key="plugin_explorer_openresultfolder">Open in Default File Manager</system:String>