2020-06-02 10:58:22 +00:00
|
|
|
using Flow.Launcher.Infrastructure.Storage;
|
2020-05-19 12:38:42 +00:00
|
|
|
using Flow.Launcher.Plugin.Explorer.Search;
|
2020-05-11 13:15:15 +00:00
|
|
|
using Flow.Launcher.Plugin.Explorer.ViewModels;
|
|
|
|
|
using Flow.Launcher.Plugin.Explorer.Views;
|
|
|
|
|
using System.Collections.Generic;
|
2021-01-02 14:01:15 +00:00
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
2020-05-11 13:15:15 +00:00
|
|
|
using System.Windows.Controls;
|
|
|
|
|
|
|
|
|
|
namespace Flow.Launcher.Plugin.Explorer
|
|
|
|
|
{
|
2021-01-02 14:01:15 +00:00
|
|
|
public class Main : ISettingProvider, IAsyncPlugin, ISavable, IContextMenu, IPluginI18n
|
2020-05-11 13:15:15 +00:00
|
|
|
{
|
2020-06-08 04:20:22 +00:00
|
|
|
internal PluginInitContext Context { get; set; }
|
2020-05-11 13:15:15 +00:00
|
|
|
|
2020-06-08 04:20:22 +00:00
|
|
|
internal Settings Settings;
|
2020-05-11 13:15:15 +00:00
|
|
|
|
2020-06-08 04:20:22 +00:00
|
|
|
private SettingsViewModel viewModel;
|
2020-05-11 13:15:15 +00:00
|
|
|
|
2020-06-08 04:20:22 +00:00
|
|
|
private IContextMenu contextMenu;
|
2020-05-25 08:58:04 +00:00
|
|
|
|
2021-01-02 14:01:15 +00:00
|
|
|
private SearchManager searchManager;
|
|
|
|
|
|
2020-05-11 13:15:15 +00:00
|
|
|
public Control CreateSettingPanel()
|
|
|
|
|
{
|
2020-06-08 04:20:22 +00:00
|
|
|
return new ExplorerSettings(viewModel);
|
2020-05-11 13:15:15 +00:00
|
|
|
}
|
|
|
|
|
|
2021-01-02 14:01:15 +00:00
|
|
|
public async Task InitAsync(PluginInitContext context)
|
2020-05-11 13:15:15 +00:00
|
|
|
{
|
|
|
|
|
Context = context;
|
2020-06-08 04:20:22 +00:00
|
|
|
viewModel = new SettingsViewModel(context);
|
2021-01-02 14:01:15 +00:00
|
|
|
await viewModel.LoadStorage();
|
2020-06-08 04:20:22 +00:00
|
|
|
Settings = viewModel.Settings;
|
|
|
|
|
contextMenu = new ContextMenu(Context, Settings);
|
2021-01-02 14:01:15 +00:00
|
|
|
searchManager = new SearchManager(Settings, Context);
|
2020-05-11 13:15:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Result> LoadContextMenus(Result selectedResult)
|
|
|
|
|
{
|
2020-06-08 04:20:22 +00:00
|
|
|
return contextMenu.LoadContextMenus(selectedResult);
|
2020-05-11 13:15:15 +00:00
|
|
|
}
|
|
|
|
|
|
2021-01-02 14:01:15 +00:00
|
|
|
public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
|
2020-05-11 13:15:15 +00:00
|
|
|
{
|
2021-01-02 14:01:15 +00:00
|
|
|
return await searchManager.SearchAsync(query, token);
|
2020-05-11 13:15:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Save()
|
|
|
|
|
{
|
2020-06-08 04:20:22 +00:00
|
|
|
viewModel.Save();
|
2020-05-11 13:15:15 +00:00
|
|
|
}
|
2020-06-08 10:31:48 +00:00
|
|
|
|
|
|
|
|
public string GetTranslatedPluginTitle()
|
|
|
|
|
{
|
|
|
|
|
return Context.API.GetTranslation("plugin_explorer_plugin_name");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetTranslatedPluginDescription()
|
|
|
|
|
{
|
|
|
|
|
return Context.API.GetTranslation("plugin_explorer_plugin_description");
|
|
|
|
|
}
|
2020-05-11 13:15:15 +00:00
|
|
|
}
|
|
|
|
|
}
|