mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-10 05:06:36 +02:00
#21 Add Disable option for each plugin.
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Threading;
|
||||
using Python.Runtime;
|
||||
using Wox.Helper;
|
||||
using Wox.Infrastructure.Storage.UserSettings;
|
||||
using Wox.Plugin;
|
||||
using Wox.PluginLoader;
|
||||
|
||||
@@ -19,6 +20,13 @@ namespace Wox.Commands
|
||||
PluginPair thirdPlugin = Plugins.AllPlugins.FirstOrDefault(o => o.Metadata.ActionKeyword == q.ActionName);
|
||||
if (thirdPlugin != null && !string.IsNullOrEmpty(thirdPlugin.Metadata.ActionKeyword))
|
||||
{
|
||||
var customizedPluginConfig = UserSettingStorage.Instance.CustomizedPluginConfigs.FirstOrDefault(o => o.ID == thirdPlugin.Metadata.ID);
|
||||
if (customizedPluginConfig != null && customizedPluginConfig.Disabled)
|
||||
{
|
||||
UpdateResultView(null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (thirdPlugin.Metadata.Language == AllowedLanguage.Python)
|
||||
{
|
||||
SwitchPythonEnv(thirdPlugin);
|
||||
@@ -29,12 +37,15 @@ namespace Wox.Commands
|
||||
{
|
||||
thirdPlugin.InitContext.PushResults = (qu, r) =>
|
||||
{
|
||||
r.ForEach(o =>
|
||||
if (r != null)
|
||||
{
|
||||
o.PluginDirectory = thirdPlugin.Metadata.PluginDirecotry;
|
||||
o.OriginQuery = qu;
|
||||
});
|
||||
UpdateResultView(r);
|
||||
r.ForEach(o =>
|
||||
{
|
||||
o.PluginDirectory = thirdPlugin.Metadata.PluginDirecotry;
|
||||
o.OriginQuery = qu;
|
||||
});
|
||||
UpdateResultView(r);
|
||||
}
|
||||
};
|
||||
List<Result> results = thirdPlugin.Plugin.Query(q) ?? new List<Result>();
|
||||
thirdPlugin.InitContext.PushResults(q, results);
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using Wox.Infrastructure.Storage.UserSettings;
|
||||
using Wox.Plugin;
|
||||
using Wox.PluginLoader;
|
||||
|
||||
@@ -15,11 +16,11 @@ namespace Wox.Commands
|
||||
foreach (PluginPair pair in Plugins.AllPlugins.Where(o => o.Metadata.PluginType == PluginType.System))
|
||||
{
|
||||
PluginPair pair1 = pair;
|
||||
|
||||
ThreadPool.QueueUserWorkItem(state =>
|
||||
{
|
||||
pair1.InitContext.PushResults = (q, r) =>
|
||||
{
|
||||
if (r == null || r.Count == 0) return;
|
||||
foreach (Result result in r)
|
||||
{
|
||||
result.PluginDirectory = pair1.Metadata.PluginDirecotry;
|
||||
|
||||
Reference in New Issue
Block a user