[WebSearch] Add copy URL to menu

This commit is contained in:
NoPlagiarism 2024-11-18 17:07:57 +05:00
parent ed5373653d
commit 4fbd74a14d
4 changed files with 27 additions and 5 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View file

@ -31,7 +31,8 @@
Thus, the generic formula for a search on Netflix is https://www.netflix.com/search?q={q}
</system:String>
<system:String x:Key="flowlauncher_plugin_websearch_copyurl_title">Copy URL</system:String>
<system:String x:Key="flowlauncher_plugin_websearch_copyurl_subtitle">Copy search URL to clipboard</system:String>
<!-- web search edit -->
<system:String x:Key="flowlauncher_plugin_websearch_title">Title</system:String>

View file

@ -29,7 +29,8 @@
Thus, the generic formula for a search on Netflix is https://www.netflix.com/search?q={q}
</system:String>
<system:String x:Key="flowlauncher_plugin_websearch_copyurl_title">Скопировать URL-адрес</system:String>
<system:String x:Key="flowlauncher_plugin_websearch_copyurl_subtitle">Скопировать URL поиска в буфер обмена</system:String>
<!-- web search edit -->
<system:String x:Key="flowlauncher_plugin_websearch_title">Title</system:String>

View file

@ -11,7 +11,7 @@ using Flow.Launcher.Plugin.SharedCommands;
namespace Flow.Launcher.Plugin.WebSearch
{
public class Main : IAsyncPlugin, ISettingProvider, IPluginI18n, IResultUpdated
public class Main : IAsyncPlugin, ISettingProvider, IPluginI18n, IResultUpdated, IContextMenu
{
private PluginInitContext _context;
@ -76,7 +76,8 @@ namespace Flow.Launcher.Plugin.WebSearch
_context.API.OpenUrl(searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword)));
return true;
}
},
ContextData = searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword)),
};
results.Add(result);
@ -139,11 +140,30 @@ namespace Flow.Launcher.Plugin.WebSearch
_context.API.OpenUrl(searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)));
return true;
}
},
ContextData = searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)),
});
return resultsFromSuggestion;
}
public List<Result> LoadContextMenus(Result selected)
{
return new List<Result>() {
new Result
{
Title = _context.API.GetTranslation("flowlauncher_plugin_websearch_copyurl_title"),
SubTitle = _context.API.GetTranslation("flowlauncher_plugin_websearch_copyurl_subtitle"),
IcoPath = "Images/copylink.png",
Action = c =>
{
_context.API.CopyToClipboard(selected.ContextData as string);
return true;
}
},
};
}
public Task InitAsync(PluginInitContext context)
{
return Task.Run(Init);