context menu selection for adding to quick access

This commit is contained in:
Jeremy Wu 2021-01-26 20:21:12 +11:00
parent 85dee95fc7
commit cab7f94c6b
4 changed files with 36 additions and 0 deletions

View file

@ -50,6 +50,38 @@ namespace Flow.Launcher.Plugin.Explorer
var icoPath = (record.Type == ResultType.File) ? Constants.FileImagePath : Constants.FolderImagePath;
var fileOrFolder = (record.Type == ResultType.File) ? "file" : "folder";
if (!Settings.QuickFolderAccessLinks.Any(x => x.Path == record.FullPath))
{
contextMenus.Add(new Result
{
Title = Context.API.GetTranslation("plugin_explorer_add_to_quickaccess"),
SubTitle = $"Add the current {fileOrFolder} to Quick Access",
Action = (context) =>
{
try
{
Settings.QuickFolderAccessLinks.Add(new FolderLink { Path = record.FullPath, Type = record.Type });
Context.API.ShowMsg(Context.API.GetTranslation("plugin_explorer_addfilefoldersuccess"),
string.Format(
Context.API.GetTranslation("plugin_explorer_addfilefoldersuccess_detail"),
fileOrFolder),
Constants.ExplorerIconImageFullPath);
return true;
}
catch (Exception e)
{
var message = "Fail to add to Quick Access";
LogException(message, e);
Context.API.ShowMsg(message);
return false;
}
},
IcoPath = Constants.QuickAccessImagePath
});
}
contextMenus.Add(new Result
{
Title = Context.API.GetTranslation("plugin_explorer_copypath"),

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

View file

@ -42,5 +42,8 @@
<system:String x:Key="plugin_explorer_openindexingoptions">Open Windows Indexing Options</system:String>
<system:String x:Key="plugin_explorer_openindexingoptions_subtitle">Manage indexed files and folders</system:String>
<system:String x:Key="plugin_explorer_openindexingoptions_errormsg">Failed to open Windows Indexing Options</system:String>
<system:String x:Key="plugin_explorer_add_to_quickaccess">Add to Quick Access</system:String>
<system:String x:Key="plugin_explorer_addfilefoldersuccess">Successfully Added</system:String>
<system:String x:Key="plugin_explorer_addfilefoldersuccess_detail">Successfully added to Quick Access</system:String>
</ResourceDictionary>

View file

@ -15,6 +15,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
internal const string ExplorerIconImagePath = "Images\\explorer.png";
internal const string DifferentUserIconImagePath = "Images\\user.png";
internal const string IndexingOptionsIconImagePath = "Images\\windowsindexingoptions.png";
internal const string QuickAccessImagePath = "Images\\quickaccess.png";
internal const string ToolTipOpenDirectory = "Ctrl + Enter to open the directory";