Skip to content

Commit 63aabd5

Browse files
authored
Merge pull request #3526 from Flow-Launcher/copy_file_name
Support copy file name
2 parents 1775c0f + 0c7d0e9 commit 63aabd5

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs

+23
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,29 @@ public List<Result> LoadContextMenus(Result selectedResult)
140140
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\ue8c8")
141141
});
142142

143+
contextMenus.Add(new Result
144+
{
145+
Title = Context.API.GetTranslation("plugin_explorer_copyname"),
146+
SubTitle = Context.API.GetTranslation("plugin_explorer_copyname_subtitle"),
147+
Action = _ =>
148+
{
149+
try
150+
{
151+
Context.API.CopyToClipboard(Path.GetFileName(record.FullPath));
152+
return true;
153+
}
154+
catch (Exception e)
155+
{
156+
var message = "Fail to set text in clipboard";
157+
LogException(message, e);
158+
Context.API.ShowMsg(message);
159+
return false;
160+
}
161+
},
162+
IcoPath = Constants.CopyImagePath,
163+
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\ue8c8")
164+
});
165+
143166
contextMenus.Add(new Result
144167
{
145168
Title = Context.API.GetTranslation("plugin_explorer_copyfilefolder"),

Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml

+2
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@
8282
<!-- Context menu items -->
8383
<system:String x:Key="plugin_explorer_copypath">Copy path</system:String>
8484
<system:String x:Key="plugin_explorer_copypath_subtitle">Copy path of current item to clipboard</system:String>
85+
<system:String x:Key="plugin_explorer_copyname">Copy name</system:String>
86+
<system:String x:Key="plugin_explorer_copyname_subtitle">Copy name of current item to clipboard</system:String>
8587
<system:String x:Key="plugin_explorer_copyfilefolder">Copy</system:String>
8688
<system:String x:Key="plugin_explorer_copyfile_subtitle">Copy current file to clipboard</system:String>
8789
<system:String x:Key="plugin_explorer_copyfolder_subtitle">Copy current folder to clipboard</system:String>

Plugins/Flow.Launcher.Plugin.Explorer/Main.cs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using System.IO;
99
using System.Threading;
1010
using System.Threading.Tasks;
11-
using System.Windows;
1211
using System.Windows.Controls;
1312
using Flow.Launcher.Plugin.Explorer.Exceptions;
1413

0 commit comments

Comments
 (0)