mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
66 lines
2 KiB
C#
66 lines
2 KiB
C#
using Flow.Launcher.Infrastructure.Storage;
|
|
using Flow.Launcher.Infrastructure.UserSettings;
|
|
using Flow.Launcher.Plugin.PluginsManager.ViewModels;
|
|
using Flow.Launcher.Plugin.PluginsManager.Views;
|
|
using System.Collections.Generic;
|
|
using System.Windows.Controls;
|
|
|
|
namespace Flow.Launcher.Plugin.PluginsManager
|
|
{
|
|
public class Main : ISettingProvider, IPlugin, ISavable, IContextMenu, IPluginI18n
|
|
{
|
|
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)
|
|
{
|
|
var search = query.Search.ToLower();
|
|
|
|
var pluginManager = new PluginsManager(Context, Settings);
|
|
|
|
if (!string.IsNullOrEmpty(search)
|
|
&& ($"{Settings.UninstallHotkey} ".StartsWith(search) || search.StartsWith($"{Settings.UninstallHotkey} ")))
|
|
return pluginManager.RequestUninstall(search);
|
|
|
|
return pluginManager.RequestInstallOrUpdate(search);
|
|
}
|
|
|
|
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");
|
|
}
|
|
}
|
|
}
|