Skip to content

Commit 4fbd74a

Browse files
committed
[WebSearch] Add copy URL to menu
1 parent ed53736 commit 4fbd74a

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed
3.17 KB
Loading

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
Thus, the generic formula for a search on Netflix is https://www.netflix.com/search?q={q}
3232
</system:String>
3333

34-
34+
<system:String x:Key="flowlauncher_plugin_websearch_copyurl_title">Copy URL</system:String>
35+
<system:String x:Key="flowlauncher_plugin_websearch_copyurl_subtitle">Copy search URL to clipboard</system:String>
3536

3637
<!-- web search edit -->
3738
<system:String x:Key="flowlauncher_plugin_websearch_title">Title</system:String>

Plugins/Flow.Launcher.Plugin.WebSearch/Languages/ru.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
Thus, the generic formula for a search on Netflix is https://www.netflix.com/search?q={q}
3030
</system:String>
3131

32-
32+
<system:String x:Key="flowlauncher_plugin_websearch_copyurl_title">Скопировать URL-адрес</system:String>
33+
<system:String x:Key="flowlauncher_plugin_websearch_copyurl_subtitle">Скопировать URL поиска в буфер обмена</system:String>
3334

3435
<!-- web search edit -->
3536
<system:String x:Key="flowlauncher_plugin_websearch_title">Title</system:String>

Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Flow.Launcher.Plugin.WebSearch
1313
{
14-
public class Main : IAsyncPlugin, ISettingProvider, IPluginI18n, IResultUpdated
14+
public class Main : IAsyncPlugin, ISettingProvider, IPluginI18n, IResultUpdated, IContextMenu
1515
{
1616
private PluginInitContext _context;
1717

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

7878
return true;
79-
}
79+
},
80+
ContextData = searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword)),
8081
};
8182

8283
results.Add(result);
@@ -139,11 +140,30 @@ private async Task<IEnumerable<Result>> SuggestionsAsync(string keyword, string
139140
_context.API.OpenUrl(searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)));
140141

141142
return true;
142-
}
143+
},
144+
ContextData = searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)),
143145
});
144146
return resultsFromSuggestion;
145147
}
146148

149+
public List<Result> LoadContextMenus(Result selected)
150+
{
151+
return new List<Result>() {
152+
new Result
153+
{
154+
Title = _context.API.GetTranslation("flowlauncher_plugin_websearch_copyurl_title"),
155+
SubTitle = _context.API.GetTranslation("flowlauncher_plugin_websearch_copyurl_subtitle"),
156+
IcoPath = "Images/copylink.png",
157+
Action = c =>
158+
{
159+
_context.API.CopyToClipboard(selected.ContextData as string);
160+
161+
return true;
162+
}
163+
},
164+
};
165+
}
166+
147167
public Task InitAsync(PluginInitContext context)
148168
{
149169
return Task.Run(Init);

0 commit comments

Comments
 (0)