Merge pull request #3082 from NoPlagiarism/search_copy_url

[WebSearch] Add copy URL to menu
This commit is contained in:
Jeremy Wu 2024-12-08 10:48:34 +11:00 committed by GitHub
commit 304f98e9ed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 28 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
{
internal static 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,31 @@ 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)
{
if (selected?.ContextData == null || selected.ContextData is not string) return new List<Result>();
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);