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 b4924a0fc..96a4af09c 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs @@ -52,6 +52,11 @@ namespace Flow.Launcher.Plugin.Explorer } } + if (record.Type == ResultType.File) + { + contextMenus.Add(CreateOpenWithMenu(record)); + } + contextMenus.Add(CreateOpenContainingFolderResult(record)); if (record.WindowsIndexed) @@ -434,6 +439,21 @@ 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 + }; + } + 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 d5352ef1e..f2491d928 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 96a4af09c..4e0596a44 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs @@ -52,13 +52,13 @@ namespace Flow.Launcher.Plugin.Explorer } } + 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 @@ namespace Flow.Launcher.Plugin.Explorer 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 4e0596a44..2297e5f96 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs @@ -451,7 +451,7 @@ namespace Flow.Launcher.Plugin.Explorer 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"), }; }