Flow.Launcher/Plugins/Flow.Launcher.Plugin.PluginsManager/ContextMenu.cs

77 lines
3.4 KiB
C#
Raw Permalink Normal View History

2020-12-29 07:14:22 +00:00
using Flow.Launcher.Infrastructure.UserSettings;
2020-12-16 10:52:00 +00:00
using Flow.Launcher.Plugin.PluginsManager.Models;
2020-12-06 10:10:22 +00:00
using System;
using System.Collections.Generic;
using System.Text;
namespace Flow.Launcher.Plugin.PluginsManager
{
internal class ContextMenu : IContextMenu
{
private PluginInitContext Context { get; set; }
public ContextMenu(PluginInitContext context)
2020-12-06 10:10:22 +00:00
{
Context = context;
}
public List<Result> LoadContextMenus(Result selectedResult)
{
2020-12-16 10:52:00 +00:00
var pluginManifestInfo = selectedResult.ContextData as UserPlugin;
return new List<Result>
{
new Result
{
Title = Context.API.GetTranslation("plugin_pluginsmanager_plugin_contextmenu_openwebsite_title"),
SubTitle = Context.API.GetTranslation("plugin_pluginsmanager_plugin_contextmenu_openwebsite_subtitle"),
2021-02-08 10:05:50 +00:00
IcoPath = selectedResult.IcoPath,
2020-12-16 10:52:00 +00:00
Action = _ =>
{
2020-12-16 19:31:33 +00:00
SharedCommands.SearchWeb.NewTabInBrowser(pluginManifestInfo.Website);
2020-12-16 10:52:00 +00:00
return true;
}
},
new Result
{
Title = Context.API.GetTranslation("plugin_pluginsmanager_plugin_contextmenu_gotosourcecode_title"),
SubTitle = Context.API.GetTranslation("plugin_pluginsmanager_plugin_contextmenu_gotosourcecode_subtitle"),
IcoPath = "Images\\sourcecode.png",
Action = _ =>
{
2020-12-16 19:31:33 +00:00
SharedCommands.SearchWeb.NewTabInBrowser(pluginManifestInfo.UrlSourceCode);
2020-12-16 10:52:00 +00:00
return true;
}
},
new Result
{
Title = Context.API.GetTranslation("plugin_pluginsmanager_plugin_contextmenu_newissue_title"),
SubTitle = Context.API.GetTranslation("plugin_pluginsmanager_plugin_contextmenu_newissue_subtitle"),
IcoPath = "Images\\request.png",
Action = _ =>
{
// standard UrlSourceCode format in PluginsManifest's plugins.json file: https://github.com/jjw24/WoxDictionary/tree/master
var link = pluginManifestInfo.UrlSourceCode.StartsWith("https://github.com")
? pluginManifestInfo.UrlSourceCode.Replace("/tree/master", "/issues/new/choose")
: pluginManifestInfo.UrlSourceCode;
2020-12-29 07:14:22 +00:00
SharedCommands.SearchWeb.NewTabInBrowser(link);
2020-12-16 10:52:00 +00:00
return true;
}
},
new Result
{
Title = Context.API.GetTranslation("plugin_pluginsmanager_plugin_contextmenu_pluginsmanifest_title"),
SubTitle = Context.API.GetTranslation("plugin_pluginsmanager_plugin_contextmenu_pluginsmanifest_subtitle"),
2021-02-08 10:05:50 +00:00
IcoPath = "Images\\manifestsite.png",
2020-12-16 10:52:00 +00:00
Action = _ =>
{
2020-12-29 07:14:22 +00:00
SharedCommands.SearchWeb.NewTabInBrowser("https://github.com/Flow-Launcher/Flow.Launcher.PluginsManifest");
2020-12-16 10:52:00 +00:00
return true;
}
}
};
2020-12-06 10:10:22 +00:00
}
}
}