mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-01-06 03:07:54 +08:00
d6f9fddc94
1. Reorder the sequence of initialization of UserSettings. 2. Use dictionary for CustomizedPluginConfigs, so code logic like `.FirstOrDefault(o => o.ID == id);` are removed 3. part of #389
50 lines
1.8 KiB
C#
50 lines
1.8 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Wox.Core.Plugin;
|
|
using Wox.Core.UserSettings;
|
|
|
|
namespace Wox.Plugin.PluginIndicator
|
|
{
|
|
public class PluginIndicator : IPlugin, IPluginI18n
|
|
{
|
|
private PluginInitContext context;
|
|
|
|
public List<Result> Query(Query query)
|
|
{
|
|
var results = from keyword in PluginManager.NonGlobalPlugins.Keys
|
|
where keyword.StartsWith(query.Terms[0])
|
|
let metadata = PluginManager.NonGlobalPlugins[keyword].Metadata
|
|
let customizedPluginConfig = UserSettingStorage.Instance.CustomizedPluginConfigs[metadata.ID]
|
|
where !customizedPluginConfig.Disabled
|
|
select new Result
|
|
{
|
|
Title = keyword,
|
|
SubTitle = $"Activate {metadata.Name} plugin",
|
|
Score = 100,
|
|
IcoPath = metadata.FullIcoPath,
|
|
Action = c =>
|
|
{
|
|
context.API.ChangeQuery($"{keyword}{Plugin.Query.TermSeperater}");
|
|
return false;
|
|
}
|
|
};
|
|
return results.ToList();
|
|
}
|
|
|
|
public void Init(PluginInitContext context)
|
|
{
|
|
this.context = context;
|
|
}
|
|
|
|
public string GetTranslatedPluginTitle()
|
|
{
|
|
return context.API.GetTranslation("wox_plugin_pluginindicator_plugin_name");
|
|
}
|
|
|
|
public string GetTranslatedPluginDescription()
|
|
{
|
|
return context.API.GetTranslation("wox_plugin_pluginindicator_plugin_description");
|
|
}
|
|
}
|
|
}
|