Skip to content

Commit

Permalink
Merge pull request #2489 from flooxo/open_with
Browse files Browse the repository at this point in the history
feat: Add open with option for files in context menu
  • Loading branch information
taooceros authored Jan 21, 2024
2 parents 06e3452 + e14e7d0 commit f927f3a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
21 changes: 21 additions & 0 deletions Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public List<Result> LoadContextMenus(Result selectedResult)

contextMenus.Add(CreateOpenContainingFolderResult(record));

if (record.Type == ResultType.File)
{
contextMenus.Add(CreateOpenWithMenu(record));
}

if (record.WindowsIndexed)
{
contextMenus.Add(CreateOpenWindowsIndexingOptions());
Expand Down Expand Up @@ -434,6 +439,22 @@ private Result CreateOpenWindowsIndexingOptions()
};
}

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);
Expand Down
4 changes: 3 additions & 1 deletion Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit f927f3a

Please sign in to comment.