mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
tweak plugin settings (#9522)
This commit is contained in:
@@ -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,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user