tweak plugin settings (#9522)

This commit is contained in:
Mykhailo Pylyp
2021-02-10 15:12:42 +02:00
committed by GitHub
parent ec6b9acad9
commit d92ff6d45d
24 changed files with 240 additions and 398 deletions

View File

@@ -1,47 +0,0 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using Wox.Plugin;
namespace Wox.Infrastructure.UserSettings
{
public class PluginSettings : BaseModel
{
public Dictionary<string, RunPlugin> Plugins { get; private set; } = new Dictionary<string, RunPlugin>();
public void UpdatePluginSettings(List<PluginMetadata> metadatas)
{
if (metadatas == null)
{
throw new ArgumentNullException(nameof(metadatas));
}
foreach (var metadata in metadatas)
{
if (Plugins.ContainsKey(metadata.ID))
{
var settings = Plugins[metadata.ID];
if (settings.GetActionKeywords()?.Count > 0)
{
metadata.SetActionKeywords(settings.GetActionKeywords());
metadata.ActionKeyword = settings.GetActionKeywords()[0];
}
metadata.Disabled = settings.Disabled;
}
else
{
Plugins[metadata.ID] = new RunPlugin(metadata.GetActionKeywords())
{
ID = metadata.ID,
Name = metadata.Name,
Disabled = metadata.Disabled,
};
}
}
}
}
}

View File

@@ -135,10 +135,6 @@ namespace Wox.Infrastructure.UserSettings
}
}
// Order defaults to 0 or -1, so 1 will let this property appear last
[JsonProperty(Order = 1)]
public PluginSettings PluginSettings { get; set; } = new PluginSettings();
public ObservableCollection<CustomPluginHotkey> CustomPluginHotkeys { get; } = new ObservableCollection<CustomPluginHotkey>();
public bool DontPromptUpdateMsg { get; set; }

View File

@@ -1,37 +0,0 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
namespace Wox.Infrastructure.UserSettings
{
public class RunPlugin
{
public string ID { get; set; }
public string Name { get; set; }
private List<string> _actionKeywords;
public RunPlugin(List<string> actionKeywords = null)
{
_actionKeywords = actionKeywords;
}
public List<string> GetActionKeywords()
{
return _actionKeywords;
}
public void SetActionKeywords(List<string> value)
{
_actionKeywords = value;
}
/// <summary>
/// Gets or sets a value indicating whether used only to save the state of the plugin in settings
/// </summary>
public bool Disabled { get; set; }
}
}