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;
|
2021-01-26 20:42:43 +00:00
|
|
|
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
|
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-26 10:09:35 +00:00
|
|
|
using System.Linq;
|
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-05-11 12:18:57 +00:00
|
|
|
public class Main : ISettingProvider, IAsyncPlugin, 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-05-22 09:23:25 +00:00
|
|
|
public Task InitAsync(PluginInitContext context)
|
2020-05-11 13:15:15 +00:00
|
|
|
{
|
|
|
|
|
Context = context;
|
2021-05-11 12:18:57 +00:00
|
|
|
|
2021-05-13 11:29:21 +00:00
|
|
|
Settings = context.API.LoadSettingJsonStorage<Settings>();
|
2021-05-11 12:18:57 +00:00
|
|
|
|
|
|
|
|
viewModel = new SettingsViewModel(context, Settings);
|
|
|
|
|
|
2021-01-26 10:09:35 +00:00
|
|
|
|
|
|
|
|
// as at v1.7.0 this is to maintain backwards compatibility, need to be removed afterwards.
|
|
|
|
|
if (Settings.QuickFolderAccessLinks.Any())
|
2021-01-26 19:17:24 +00:00
|
|
|
{
|
2021-01-26 10:09:35 +00:00
|
|
|
Settings.QuickAccessLinks = Settings.QuickFolderAccessLinks;
|
2021-01-26 20:42:43 +00:00
|
|
|
Settings.QuickFolderAccessLinks = new List<AccessLink>();
|
2021-01-26 19:17:24 +00:00
|
|
|
}
|
2021-01-26 10:09:35 +00:00
|
|
|
|
2021-01-26 10:14:39 +00:00
|
|
|
contextMenu = new ContextMenu(Context, Settings, viewModel);
|
2021-01-02 14:01:15 +00:00
|
|
|
searchManager = new SearchManager(Settings, Context);
|
2021-01-29 10:40:51 +00:00
|
|
|
ResultManager.Init(Context);
|
2021-05-22 09:23:25 +00:00
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
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
|
|
|
}
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
}
|