2016-03-25 09:22:24 +08:00
|
|
|
|
using System.Collections.Generic;
|
2016-05-05 08:57:03 +08:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using Wox.Core.Plugin;
|
|
|
|
|
using Wox.Plugin;
|
2014-07-01 22:19:46 +08:00
|
|
|
|
|
2015-01-05 22:41:17 +08:00
|
|
|
|
namespace Wox.Core.UserSettings
|
2014-07-01 22:19:46 +08:00
|
|
|
|
{
|
2016-05-05 08:57:03 +08:00
|
|
|
|
public class PluginsSettings
|
|
|
|
|
{
|
|
|
|
|
public string PythonDirectory { get; set; }
|
|
|
|
|
public Dictionary<string, Plugin> Plugins { get; set; } = new Dictionary<string, Plugin>();
|
|
|
|
|
|
|
|
|
|
public void UpdatePluginSettings(List<PluginPair> plugins)
|
|
|
|
|
{
|
|
|
|
|
var metadatas = plugins.Select(p => p.Metadata);
|
|
|
|
|
foreach (var metadata in metadatas)
|
|
|
|
|
{
|
|
|
|
|
if (Plugins.ContainsKey(metadata.ID))
|
|
|
|
|
{
|
|
|
|
|
var settings = Plugins[metadata.ID];
|
|
|
|
|
if (settings.ActionKeywords?.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
metadata.ActionKeywords = settings.ActionKeywords;
|
|
|
|
|
metadata.ActionKeyword = settings.ActionKeywords[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Plugins[metadata.ID] = new Plugin
|
|
|
|
|
{
|
|
|
|
|
ID = metadata.ID,
|
|
|
|
|
Name = metadata.Name,
|
|
|
|
|
ActionKeywords = metadata.ActionKeywords,
|
|
|
|
|
Disabled = false
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-03-25 09:22:24 +08:00
|
|
|
|
|
2016-05-05 08:57:03 +08:00
|
|
|
|
public void UpdateActionKeyword(PluginMetadata metadata)
|
|
|
|
|
{
|
|
|
|
|
var settings = Plugins[metadata.ID];
|
|
|
|
|
settings.ActionKeywords = metadata.ActionKeywords;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public class Plugin
|
2014-07-01 22:19:46 +08:00
|
|
|
|
{
|
|
|
|
|
public string ID { get; set; }
|
|
|
|
|
public string Name { get; set; }
|
2015-11-06 10:29:32 +08:00
|
|
|
|
public List<string> ActionKeywords { get; set; }
|
2014-07-01 22:19:46 +08:00
|
|
|
|
public bool Disabled { get; set; }
|
|
|
|
|
}
|
|
|
|
|
}
|