Skip to content

Commit cab7f94

Browse files
committed
context menu selection for adding to quick access
1 parent 85dee95 commit cab7f94

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,38 @@ public List<Result> LoadContextMenus(Result selectedResult)
5050

5151
var icoPath = (record.Type == ResultType.File) ? Constants.FileImagePath : Constants.FolderImagePath;
5252
var fileOrFolder = (record.Type == ResultType.File) ? "file" : "folder";
53+
54+
if (!Settings.QuickFolderAccessLinks.Any(x => x.Path == record.FullPath))
55+
{
56+
contextMenus.Add(new Result
57+
{
58+
Title = Context.API.GetTranslation("plugin_explorer_add_to_quickaccess"),
59+
SubTitle = $"Add the current {fileOrFolder} to Quick Access",
60+
Action = (context) =>
61+
{
62+
try
63+
{
64+
Settings.QuickFolderAccessLinks.Add(new FolderLink { Path = record.FullPath, Type = record.Type });
65+
66+
Context.API.ShowMsg(Context.API.GetTranslation("plugin_explorer_addfilefoldersuccess"),
67+
string.Format(
68+
Context.API.GetTranslation("plugin_explorer_addfilefoldersuccess_detail"),
69+
fileOrFolder),
70+
Constants.ExplorerIconImageFullPath);
71+
return true;
72+
}
73+
catch (Exception e)
74+
{
75+
var message = "Fail to add to Quick Access";
76+
LogException(message, e);
77+
Context.API.ShowMsg(message);
78+
return false;
79+
}
80+
},
81+
IcoPath = Constants.QuickAccessImagePath
82+
});
83+
}
84+
5385
contextMenus.Add(new Result
5486
{
5587
Title = Context.API.GetTranslation("plugin_explorer_copypath"),
42.8 KB
Loading

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,8 @@
4242
<system:String x:Key="plugin_explorer_openindexingoptions">Open Windows Indexing Options</system:String>
4343
<system:String x:Key="plugin_explorer_openindexingoptions_subtitle">Manage indexed files and folders</system:String>
4444
<system:String x:Key="plugin_explorer_openindexingoptions_errormsg">Failed to open Windows Indexing Options</system:String>
45+
<system:String x:Key="plugin_explorer_add_to_quickaccess">Add to Quick Access</system:String>
46+
<system:String x:Key="plugin_explorer_addfilefoldersuccess">Successfully Added</system:String>
47+
<system:String x:Key="plugin_explorer_addfilefoldersuccess_detail">Successfully added to Quick Access</system:String>
4548

4649
</ResourceDictionary>

Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ internal static class Constants
1515
internal const string ExplorerIconImagePath = "Images\\explorer.png";
1616
internal const string DifferentUserIconImagePath = "Images\\user.png";
1717
internal const string IndexingOptionsIconImagePath = "Images\\windowsindexingoptions.png";
18+
internal const string QuickAccessImagePath = "Images\\quickaccess.png";
1819

1920
internal const string ToolTipOpenDirectory = "Ctrl + Enter to open the directory";
2021

0 commit comments

Comments
 (0)