Skip to content

Commit

Permalink
Merge pull request #3082 from NoPlagiarism/search_copy_url
Browse files Browse the repository at this point in the history
[WebSearch] Add copy URL to menu
  • Loading branch information
jjw24 authored Dec 7, 2024
2 parents ce6b4d9 + 386ac97 commit 304f98e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion Plugins/Flow.Launcher.Plugin.WebSearch/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
3 changes: 2 additions & 1 deletion Plugins/Flow.Launcher.Plugin.WebSearch/Languages/ru.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
27 changes: 24 additions & 3 deletions Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Flow.Launcher.Plugin.WebSearch
{
public class Main : IAsyncPlugin, ISettingProvider, IPluginI18n, IResultUpdated
public class Main : IAsyncPlugin, ISettingProvider, IPluginI18n, IResultUpdated, IContextMenu
{
internal static PluginInitContext _context;

Expand Down Expand Up @@ -76,7 +76,8 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
_context.API.OpenUrl(searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword)));

return true;
}
},
ContextData = searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword)),
};

results.Add(result);
Expand Down Expand Up @@ -139,11 +140,31 @@ private async Task<IEnumerable<Result>> SuggestionsAsync(string keyword, string
_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);
Expand Down

0 comments on commit 304f98e

Please sign in to comment.