mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
44 lines
1.5 KiB
C#
44 lines
1.5 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Flow.Launcher.Core.Plugin;
|
|
using Flow.Launcher.Infrastructure;
|
|
using Flow.Launcher.Infrastructure.UserSettings;
|
|
using Flow.Launcher.Plugin;
|
|
using Flow.Launcher.ViewModel;
|
|
|
|
#nullable enable
|
|
|
|
namespace Flow.Launcher.SettingPages.ViewModels;
|
|
|
|
public class SettingsPanePluginsViewModel : BaseModel
|
|
{
|
|
private readonly Settings _settings;
|
|
|
|
public SettingsPanePluginsViewModel(Settings settings)
|
|
{
|
|
_settings = settings;
|
|
}
|
|
|
|
public string FilterText { get; set; } = string.Empty;
|
|
|
|
public PluginViewModel? SelectedPlugin { get; set; }
|
|
|
|
private IEnumerable<PluginViewModel>? _pluginViewModels;
|
|
private IEnumerable<PluginViewModel> PluginViewModels => _pluginViewModels ??= PluginManager.AllPlugins
|
|
.OrderBy(plugin => plugin.Metadata.Disabled)
|
|
.ThenBy(plugin => plugin.Metadata.Name)
|
|
.Select(plugin => new PluginViewModel
|
|
{
|
|
PluginPair = plugin,
|
|
PluginSettingsObject = _settings.PluginSettings.Plugins[plugin.Metadata.ID]
|
|
})
|
|
.ToList();
|
|
|
|
public List<PluginViewModel> FilteredPluginViewModels => PluginViewModels
|
|
.Where(v =>
|
|
string.IsNullOrEmpty(FilterText) ||
|
|
StringMatcher.FuzzySearch(FilterText, v.PluginPair.Metadata.Name).IsSearchPrecisionScoreMet() ||
|
|
StringMatcher.FuzzySearch(FilterText, v.PluginPair.Metadata.Description).IsSearchPrecisionScoreMet()
|
|
)
|
|
.ToList();
|
|
}
|