2020-12-06 10:10:22 +00:00
|
|
|
|
using Flow.Launcher.Infrastructure.Storage;
|
|
|
|
|
|
using Flow.Launcher.Infrastructure.UserSettings;
|
|
|
|
|
|
using Flow.Launcher.Plugin.PluginsManager.ViewModels;
|
|
|
|
|
|
using Flow.Launcher.Plugin.PluginsManager.Views;
|
2020-12-06 08:58:27 +00:00
|
|
|
|
using System.Collections.Generic;
|
2020-12-06 10:10:22 +00:00
|
|
|
|
using System.Windows.Controls;
|
2020-12-06 08:58:27 +00:00
|
|
|
|
|
|
|
|
|
|
namespace Flow.Launcher.Plugin.PluginsManager
|
|
|
|
|
|
{
|
2020-12-06 10:10:22 +00:00
|
|
|
|
public class Main : ISettingProvider, IPlugin, ISavable, IContextMenu, IPluginI18n
|
2020-12-06 08:58:27 +00:00
|
|
|
|
{
|
2020-12-06 10:10:22 +00:00
|
|
|
|
internal PluginInitContext Context { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
internal Settings Settings;
|
|
|
|
|
|
|
|
|
|
|
|
private SettingsViewModel viewModel;
|
|
|
|
|
|
|
|
|
|
|
|
private IContextMenu contextMenu;
|
|
|
|
|
|
|
|
|
|
|
|
public Control CreateSettingPanel()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new PluginsManagerSettings(viewModel);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Init(PluginInitContext context)
|
|
|
|
|
|
{
|
|
|
|
|
|
Context = context;
|
|
|
|
|
|
viewModel = new SettingsViewModel(context);
|
|
|
|
|
|
Settings = viewModel.Settings;
|
|
|
|
|
|
contextMenu = new ContextMenu(Context, Settings);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<Result> LoadContextMenus(Result selectedResult)
|
|
|
|
|
|
{
|
|
|
|
|
|
return contextMenu.LoadContextMenus(selectedResult);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<Result> Query(Query query)
|
|
|
|
|
|
{
|
2020-12-14 10:05:32 +00:00
|
|
|
|
var search = query.Search.ToLower();
|
2020-12-06 20:40:42 +00:00
|
|
|
|
|
2020-12-14 10:05:32 +00:00
|
|
|
|
var pluginManager = new PluginsManager(Context, Settings);
|
2020-12-06 20:40:42 +00:00
|
|
|
|
|
2020-12-14 10:05:32 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(search)
|
2020-12-17 09:37:01 +00:00
|
|
|
|
&& ($"{Settings.HotkeyUninstall} ".StartsWith(search) || search.StartsWith($"{Settings.HotkeyUninstall} ")))
|
2020-12-14 10:05:32 +00:00
|
|
|
|
return pluginManager.RequestUninstall(search);
|
2020-12-17 09:37:01 +00:00
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(search)
|
|
|
|
|
|
&& ($"{Settings.HotkeyUpdate} ".StartsWith(search) || search.StartsWith($"{Settings.HotkeyUpdate} ")))
|
|
|
|
|
|
return pluginManager.RequestUpdate(search);
|
|
|
|
|
|
|
2020-12-10 10:28:01 +00:00
|
|
|
|
return pluginManager.RequestInstallOrUpdate(search);
|
2020-12-06 10:10:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Save()
|
|
|
|
|
|
{
|
|
|
|
|
|
viewModel.Save();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string GetTranslatedPluginTitle()
|
|
|
|
|
|
{
|
|
|
|
|
|
return Context.API.GetTranslation("plugin_pluginsmanager_plugin_name");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string GetTranslatedPluginDescription()
|
|
|
|
|
|
{
|
|
|
|
|
|
return Context.API.GetTranslation("plugin_pluginsmanager_plugin_description");
|
|
|
|
|
|
}
|
2020-12-06 08:58:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|