From 1327250a6fc29375965c903dd576309586215323 Mon Sep 17 00:00:00 2001 From: Florian Grabmeier Date: Tue, 16 Jan 2024 22:55:25 +0100 Subject: [PATCH 1/3] Add "Open With" option to file context menu Signed-off-by: Florian Grabmeier --- .../ContextMenu.cs | 20 +++++++++++++++++++ .../Languages/en.xaml | 4 +++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs index b4924a0fc91..96a4af09cea 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs @@ -52,6 +52,11 @@ public List LoadContextMenus(Result selectedResult) } } + if (record.Type == ResultType.File) + { + contextMenus.Add(CreateOpenWithMenu(record)); + } + contextMenus.Add(CreateOpenContainingFolderResult(record)); if (record.WindowsIndexed) @@ -434,6 +439,21 @@ 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 + }; + } + private void LogException(string message, Exception e) { Log.Exception($"|Flow.Launcher.Plugin.Folder.ContextMenu|{message}", e); diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml index d5352ef1e9a..f2491d928ea 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml @@ -102,7 +102,9 @@ Remove from Quick Access Remove current item from Quick Access Show Windows Context Menu - + Open With + Select a program to open with + {0} free of {1} Open in Default File Manager From 8898a09aac613c89d726060c10bd77471be98655 Mon Sep 17 00:00:00 2001 From: Florian Grabmeier Date: Tue, 16 Jan 2024 22:59:46 +0100 Subject: [PATCH 2/3] Add Glyph for open with Signed-off-by: Florian Grabmeier --- Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs index 96a4af09cea..4e0596a44c7 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs @@ -52,13 +52,13 @@ public List LoadContextMenus(Result selectedResult) } } + contextMenus.Add(CreateOpenContainingFolderResult(record)); + if (record.Type == ResultType.File) { contextMenus.Add(CreateOpenWithMenu(record)); } - contextMenus.Add(CreateOpenContainingFolderResult(record)); - if (record.WindowsIndexed) { contextMenus.Add(CreateOpenWindowsIndexingOptions()); @@ -450,7 +450,8 @@ private Result CreateOpenWithMenu(SearchResult record) Process.Start("rundll32.exe", $"{Path.Combine(Environment.SystemDirectory, "shell32.dll")},OpenAs_RunDLL {record.FullPath}"); return true; }, - IcoPath = Constants.ShowContextMenuImagePath + IcoPath = Constants.ShowContextMenuImagePath, + Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\ue700"), }; } From e14e7d09590cbf03d84802d0f39eca180836f9de Mon Sep 17 00:00:00 2001 From: Florian Grabmeier Date: Wed, 17 Jan 2024 10:56:10 +0100 Subject: [PATCH 3/3] Update Glyph Signed-off-by: Florian Grabmeier --- Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs index 4e0596a44c7..2297e5f9633 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs @@ -451,7 +451,7 @@ private Result CreateOpenWithMenu(SearchResult record) return true; }, IcoPath = Constants.ShowContextMenuImagePath, - Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\ue700"), + Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\ue7ac"), }; }