Move get default hotkeys to pluginmanger and make Main.Context non-static

This commit is contained in:
弘韬 张 2020-12-29 12:14:59 +08:00
parent 00457ddc29
commit bb9682f791
3 changed files with 38 additions and 41 deletions

View file

@ -13,7 +13,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
{
public class Main : ISettingProvider, IPlugin, ISavable, IContextMenu, IPluginI18n
{
internal static PluginInitContext Context { get; set; }
internal PluginInitContext Context { get; set; }
internal Settings Settings;

View file

@ -50,6 +50,43 @@ namespace Flow.Launcher.Plugin.PluginsManager
await pluginsManifest.DownloadManifest();
}
internal List<Result> GetDefaultHotKeys()
{
return new List<Result>()
{
new Result()
{
Title = Settings.HotKeyInstall,
IcoPath = icoPath,
Action = _ =>
{
Context.API.ChangeQuery("pm install ");
return false;
}
},
new Result()
{
Title = Settings.HotkeyUninstall,
IcoPath = icoPath,
Action = _ =>
{
Context.API.ChangeQuery("pm uninstall ");
return false;
}
},
new Result()
{
Title = Settings.HotkeyUpdate,
IcoPath = icoPath,
Action = _ =>
{
Context.API.ChangeQuery("pm update ");
return false;
}
}
};
}
internal void InstallOrUpdate(UserPlugin plugin)
{
if (PluginExists(plugin.ID))

View file

@ -12,46 +12,6 @@ namespace Flow.Launcher.Plugin.PluginsManager
internal string HotkeyUpdate { get; set; } = "update";
internal readonly string icoPath = "Images\\pluginsmanager.png";
internal List<Result> HotKeys
{
get
{
return new List<Result>()
{
new Result()
{
Title = HotKeyInstall,
IcoPath = icoPath,
Action = _ =>
{
Main.Context.API.ChangeQuery("pm install ");
return false;
}
},
new Result()
{
Title = HotkeyUninstall,
IcoPath = icoPath,
Action = _ =>
{
Main.Context.API.ChangeQuery("pm uninstall ");
return false;
}
},
new Result()
{
Title = HotkeyUpdate,
IcoPath = icoPath,
Action = _ =>
{
Main.Context.API.ChangeQuery("pm update ");
return false;
}
}
};
}
}
}
}