2022-10-23 09:05:12 +00:00
|
|
|
|
using System.Collections.Generic;
|
2020-04-21 09:12:17 +00:00
|
|
|
|
using Flow.Launcher.Plugin;
|
2014-07-01 14:19:46 +00:00
|
|
|
|
|
2020-04-21 09:12:17 +00:00
|
|
|
|
namespace Flow.Launcher.Infrastructure.UserSettings
|
2014-07-01 14:19:46 +00:00
|
|
|
|
{
|
2016-05-23 21:08:13 +00:00
|
|
|
|
public class PluginsSettings : BaseModel
|
2016-05-05 00:57:03 +00:00
|
|
|
|
{
|
2022-12-02 08:27:04 +00:00
|
|
|
|
private string pythonExecutablePath = string.Empty;
|
2022-11-21 22:20:27 +00:00
|
|
|
|
public string PythonExecutablePath {
|
|
|
|
|
|
get { return pythonExecutablePath; }
|
2022-10-25 10:54:00 +00:00
|
|
|
|
set
|
|
|
|
|
|
{
|
2022-11-21 22:20:27 +00:00
|
|
|
|
pythonExecutablePath = value;
|
2022-10-25 10:54:00 +00:00
|
|
|
|
Constant.PythonPath = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-10-23 09:05:12 +00:00
|
|
|
|
|
2022-12-02 08:27:04 +00:00
|
|
|
|
private string nodeExecutablePath = string.Empty;
|
2022-11-21 22:20:27 +00:00
|
|
|
|
public string NodeExecutablePath
|
2022-10-25 10:54:00 +00:00
|
|
|
|
{
|
2022-11-21 22:20:27 +00:00
|
|
|
|
get { return nodeExecutablePath; }
|
2022-10-25 10:54:00 +00:00
|
|
|
|
set
|
|
|
|
|
|
{
|
2022-11-21 22:20:27 +00:00
|
|
|
|
nodeExecutablePath = value;
|
2022-10-25 10:54:00 +00:00
|
|
|
|
Constant.NodePath = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-10-23 09:05:12 +00:00
|
|
|
|
|
2016-05-05 00:57:03 +00:00
|
|
|
|
public Dictionary<string, Plugin> Plugins { get; set; } = new Dictionary<string, Plugin>();
|
|
|
|
|
|
|
2016-05-12 01:45:35 +00:00
|
|
|
|
public void UpdatePluginSettings(List<PluginMetadata> metadatas)
|
2016-05-05 00:57:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
foreach (var metadata in metadatas)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Plugins.ContainsKey(metadata.ID))
|
|
|
|
|
|
{
|
|
|
|
|
|
var settings = Plugins[metadata.ID];
|
2020-07-19 12:11:17 +00:00
|
|
|
|
|
2020-07-19 12:11:55 +00:00
|
|
|
|
if (string.IsNullOrEmpty(settings.Version))
|
|
|
|
|
|
settings.Version = metadata.Version;
|
|
|
|
|
|
|
2016-05-05 00:57:03 +00:00
|
|
|
|
if (settings.ActionKeywords?.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
metadata.ActionKeywords = settings.ActionKeywords;
|
|
|
|
|
|
metadata.ActionKeyword = settings.ActionKeywords[0];
|
|
|
|
|
|
}
|
2021-05-25 12:20:22 +00:00
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
metadata.ActionKeywords = new List<string>();
|
|
|
|
|
|
metadata.ActionKeyword = string.Empty;
|
|
|
|
|
|
}
|
2016-05-22 04:30:38 +00:00
|
|
|
|
metadata.Disabled = settings.Disabled;
|
2021-01-05 08:11:38 +00:00
|
|
|
|
metadata.Priority = settings.Priority;
|
2016-05-05 00:57:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Plugins[metadata.ID] = new Plugin
|
|
|
|
|
|
{
|
|
|
|
|
|
ID = metadata.ID,
|
|
|
|
|
|
Name = metadata.Name,
|
2020-07-19 12:11:55 +00:00
|
|
|
|
Version = metadata.Version,
|
2020-02-22 09:02:07 +00:00
|
|
|
|
ActionKeywords = metadata.ActionKeywords,
|
2021-01-05 08:11:38 +00:00
|
|
|
|
Disabled = metadata.Disabled,
|
|
|
|
|
|
Priority = metadata.Priority
|
2016-05-05 00:57:03 +00:00
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public class Plugin
|
2014-07-01 14:19:46 +00:00
|
|
|
|
{
|
|
|
|
|
|
public string ID { get; set; }
|
|
|
|
|
|
public string Name { get; set; }
|
2020-07-19 12:11:55 +00:00
|
|
|
|
public string Version { get; set; }
|
2020-02-22 09:02:07 +00:00
|
|
|
|
public List<string> ActionKeywords { get; set; } // a reference of the action keywords from plugin manager
|
2021-01-05 08:11:38 +00:00
|
|
|
|
public int Priority { get; set; }
|
2020-02-22 09:02:07 +00:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Used only to save the state of the plugin in settings
|
|
|
|
|
|
/// </summary>
|
2014-07-01 14:19:46 +00:00
|
|
|
|
public bool Disabled { get; set; }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|