Refactored terminology

This commit is contained in:
Thorsten Sommer 2026-02-20 11:52:27 +01:00
parent df1432f4a1
commit 776b8e410d
Signed by untrusted user who does not match committer: tsommer
GPG Key ID: 371BBA77A02C0108
6 changed files with 75 additions and 74 deletions

View File

@ -28,14 +28,14 @@ public partial class SettingsPanelApp : SettingsPanelBase
{ {
this.SettingsManager.ConfigurationData.App.PreviewVisibility = previewVisibility; this.SettingsManager.ConfigurationData.App.PreviewVisibility = previewVisibility;
var filtered = previewVisibility.FilterPreviewFeatures(this.SettingsManager.ConfigurationData.App.EnabledPreviewFeatures); var filtered = previewVisibility.FilterPreviewFeatures(this.SettingsManager.ConfigurationData.App.EnabledPreviewFeatures);
filtered.UnionWith(this.GetManagedPreviewFeatures()); filtered.UnionWith(this.GetPluginContributedPreviewFeatures());
this.SettingsManager.ConfigurationData.App.EnabledPreviewFeatures = filtered; this.SettingsManager.ConfigurationData.App.EnabledPreviewFeatures = filtered;
} }
private HashSet<PreviewFeatures> GetManagedPreviewFeatures() private HashSet<PreviewFeatures> GetPluginContributedPreviewFeatures()
{ {
if (ManagedConfiguration.TryGet(x => x.App, x => x.EnabledPreviewFeatures, out var meta) && meta.HasManagedValue) if (ManagedConfiguration.TryGet(x => x.App, x => x.EnabledPreviewFeatures, out var meta) && meta.HasPluginContribution)
return meta.ManagedValue.Where(x => !x.IsReleased()).ToHashSet(); return meta.PluginContribution.Where(x => !x.IsReleased()).ToHashSet();
return []; return [];
} }
@ -43,13 +43,13 @@ public partial class SettingsPanelApp : SettingsPanelBase
private HashSet<PreviewFeatures> GetSelectedPreviewFeatures() private HashSet<PreviewFeatures> GetSelectedPreviewFeatures()
{ {
var enabled = this.SettingsManager.ConfigurationData.App.EnabledPreviewFeatures.Where(x => !x.IsReleased()).ToHashSet(); var enabled = this.SettingsManager.ConfigurationData.App.EnabledPreviewFeatures.Where(x => !x.IsReleased()).ToHashSet();
enabled.UnionWith(this.GetManagedPreviewFeatures()); enabled.UnionWith(this.GetPluginContributedPreviewFeatures());
return enabled; return enabled;
} }
private void UpdateEnabledPreviewFeatures(HashSet<PreviewFeatures> selectedFeatures) private void UpdateEnabledPreviewFeatures(HashSet<PreviewFeatures> selectedFeatures)
{ {
selectedFeatures.UnionWith(this.GetManagedPreviewFeatures()); selectedFeatures.UnionWith(this.GetPluginContributedPreviewFeatures());
this.SettingsManager.ConfigurationData.App.EnabledPreviewFeatures = selectedFeatures; this.SettingsManager.ConfigurationData.App.EnabledPreviewFeatures = selectedFeatures;
} }

View File

@ -28,14 +28,14 @@ public record ConfigMeta<TClass, TValue> : ConfigMetaBase
private Expression<Func<TClass, TValue>> PropertyExpression { get; } private Expression<Func<TClass, TValue>> PropertyExpression { get; }
/// <summary> /// <summary>
/// Indicates whether the configuration is managed by a plugin and is therefore locked. /// Indicates whether the configuration is locked by a configuration plugin.
/// </summary> /// </summary>
public bool IsLocked { get; private set; } public bool IsLocked { get; private set; }
/// <summary> /// <summary>
/// The ID of the plugin that manages this configuration. This is set when the configuration is locked. /// The ID of the plugin that locked this configuration.
/// </summary> /// </summary>
public Guid MangedByConfigPluginId { get; private set; } public Guid LockedByConfigPluginId { get; private set; }
/// <summary> /// <summary>
/// The default value for the configuration property. This is used when resetting the property to its default state. /// The default value for the configuration property. This is used when resetting the property to its default state.
@ -43,68 +43,68 @@ public record ConfigMeta<TClass, TValue> : ConfigMetaBase
public required TValue Default { get; init; } public required TValue Default { get; init; }
/// <summary> /// <summary>
/// Indicates whether a managed value is available. /// Indicates whether a plugin contribution is available.
/// </summary> /// </summary>
public bool HasManagedValue { get; private set; } public bool HasPluginContribution { get; private set; }
/// <summary> /// <summary>
/// The managed value provided by a configuration plugin. /// The additive value contribution provided by a configuration plugin.
/// </summary> /// </summary>
public TValue ManagedValue { get; private set; } = default!; public TValue PluginContribution { get; private set; } = default!;
/// <summary> /// <summary>
/// The ID of the plugin that provided the managed value. /// The ID of the plugin that provided the additive value contribution.
/// </summary> /// </summary>
public Guid ManagedValueByConfigPluginId { get; private set; } public Guid PluginContributionByConfigPluginId { get; private set; }
/// <summary> /// <summary>
/// Locks the configuration state, indicating that it is managed by a specific plugin. /// Locks the configuration state, indicating that it is controlled by a specific plugin.
/// </summary> /// </summary>
/// <param name="pluginId">The ID of the plugin that is managing this configuration.</param> /// <param name="pluginId">The ID of the plugin that is locking this configuration.</param>
public void LockManagedState(Guid pluginId) public void LockConfiguration(Guid pluginId)
{ {
this.IsLocked = true; this.IsLocked = true;
this.MangedByConfigPluginId = pluginId; this.LockedByConfigPluginId = pluginId;
} }
/// <summary> /// <summary>
/// Resets the managed state of the configuration, allowing it to be modified again. /// Resets the locked state of the configuration, allowing it to be modified again.
/// This will also reset the property to its default value. /// This will also reset the property to its default value.
/// </summary> /// </summary>
public void ResetManagedState() public void ResetLockedConfiguration()
{ {
this.IsLocked = false; this.IsLocked = false;
this.MangedByConfigPluginId = Guid.Empty; this.LockedByConfigPluginId = Guid.Empty;
this.Reset(); this.Reset();
} }
/// <summary> /// <summary>
/// Unlocks the configuration state without changing the current value. /// Unlocks the configuration state without changing the current value.
/// </summary> /// </summary>
public void UnlockManagedState() public void UnlockConfiguration()
{ {
this.IsLocked = false; this.IsLocked = false;
this.MangedByConfigPluginId = Guid.Empty; this.LockedByConfigPluginId = Guid.Empty;
} }
/// <summary> /// <summary>
/// Stores a managed value provided by a configuration plugin. /// Stores an additive plugin contribution.
/// </summary> /// </summary>
public void SetManagedValue(TValue value, Guid pluginId) public void SetPluginContribution(TValue value, Guid pluginId)
{ {
this.ManagedValue = value; this.PluginContribution = value;
this.ManagedValueByConfigPluginId = pluginId; this.PluginContributionByConfigPluginId = pluginId;
this.HasManagedValue = true; this.HasPluginContribution = true;
} }
/// <summary> /// <summary>
/// Clears the managed value without changing the current value. /// Clears the additive plugin contribution without changing the current value.
/// </summary> /// </summary>
public void ClearManagedValue() public void ClearPluginContribution()
{ {
this.ManagedValue = default!; this.PluginContribution = default!;
this.ManagedValueByConfigPluginId = Guid.Empty; this.PluginContributionByConfigPluginId = Guid.Empty;
this.HasManagedValue = false; this.HasPluginContribution = false;
} }
/// <summary> /// <summary>

View File

@ -583,8 +583,8 @@ public static partial class ManagedConfiguration
} }
/// <summary> /// <summary>
/// Attempts to process the configuration settings from a Lua table for enum set types. /// Attempts to process additive plugin contributions for enum set settings from a Lua table.
/// The configured values are merged into the existing set, and the setting is left unlocked /// The contributed values are merged into the existing set, and the setting remains unlocked
/// so users can add additional values. /// so users can add additional values.
/// </summary> /// </summary>
/// <param name="configPluginId">The ID of the related configuration plugin.</param> /// <param name="configPluginId">The ID of the related configuration plugin.</param>
@ -596,7 +596,7 @@ public static partial class ManagedConfiguration
/// <typeparam name="TValue">The type of the property within the configuration class. It is also the type of the set /// <typeparam name="TValue">The type of the property within the configuration class. It is also the type of the set
/// elements, which must be an enum.</typeparam> /// elements, which must be an enum.</typeparam>
/// <returns>True when the configuration was successfully processed, otherwise false.</returns> /// <returns>True when the configuration was successfully processed, otherwise false.</returns>
public static bool TryProcessConfigurationAdditive<TClass, TValue>( public static bool TryProcessConfigurationWithPluginContribution<TClass, TValue>(
Expression<Func<Data, TClass>> configSelection, Expression<Func<Data, TClass>> configSelection,
Expression<Func<TClass, ISet<TValue>>> propertyExpression, Expression<Func<TClass, ISet<TValue>>> propertyExpression,
Guid configPluginId, Guid configPluginId,
@ -653,15 +653,15 @@ public static partial class ManagedConfiguration
var merged = new HashSet<TValue>(currentValue); var merged = new HashSet<TValue>(currentValue);
merged.UnionWith(configuredValue); merged.UnionWith(configuredValue);
configMeta.SetValue(merged); configMeta.SetValue(merged);
configMeta.SetManagedValue(new HashSet<TValue>(configuredValue), configPluginId); configMeta.SetPluginContribution(new HashSet<TValue>(configuredValue), configPluginId);
} }
else if (configMeta.HasManagedValue && configMeta.ManagedValueByConfigPluginId == configPluginId) else if (configMeta.HasPluginContribution && configMeta.PluginContributionByConfigPluginId == configPluginId)
{ {
configMeta.ClearManagedValue(); configMeta.ClearPluginContribution();
} }
if (configMeta.IsLocked && configMeta.MangedByConfigPluginId == configPluginId) if (configMeta.IsLocked && configMeta.LockedByConfigPluginId == configPluginId)
configMeta.UnlockManagedState(); configMeta.UnlockConfiguration();
return successful; return successful;
} }
@ -828,12 +828,12 @@ public static partial class ManagedConfiguration
// Case: the setting was configured, and we could read the value successfully. // Case: the setting was configured, and we could read the value successfully.
// //
// Set the configured value and lock the managed state: // Set the configured value and lock the configuration:
configMeta.SetValue(configuredValue); configMeta.SetValue(configuredValue);
configMeta.LockManagedState(configPluginId); configMeta.LockConfiguration(configPluginId);
break; break;
case false when configMeta.IsLocked && configMeta.MangedByConfigPluginId == configPluginId: case false when configMeta.IsLocked && configMeta.LockedByConfigPluginId == configPluginId:
// //
// Case: the setting was configured previously, but we could not read the value successfully. // Case: the setting was configured previously, but we could not read the value successfully.
// This happens when the setting was removed from the configuration plugin. We handle that // This happens when the setting was removed from the configuration plugin. We handle that
@ -841,10 +841,10 @@ public static partial class ManagedConfiguration
// //
// The other case, when the setting was locked and managed by a different configuration plugin, // The other case, when the setting was locked and managed by a different configuration plugin,
// is handled by the IsConfigurationLeftOver method, which checks if the configuration plugin // is handled by the IsConfigurationLeftOver method, which checks if the configuration plugin
// is still available. If it is not available, it resets the managed state of the // is still available. If it is not available, it resets the locked state of the
// configuration setting, allowing it to be reconfigured by a different plugin or left unchanged. // configuration setting, allowing it to be reconfigured by a different plugin or left unchanged.
// //
configMeta.ResetManagedState(); configMeta.ResetLockedConfiguration();
break; break;
case false: case false:

View File

@ -252,13 +252,13 @@ public static partial class ManagedConfiguration
if (!TryGet(configSelection, propertyExpression, out var configMeta)) if (!TryGet(configSelection, propertyExpression, out var configMeta))
return false; return false;
if (configMeta.MangedByConfigPluginId == Guid.Empty || !configMeta.IsLocked) if (configMeta.LockedByConfigPluginId == Guid.Empty || !configMeta.IsLocked)
return false; return false;
var plugin = availablePlugins.FirstOrDefault(x => x.Id == configMeta.MangedByConfigPluginId); var plugin = availablePlugins.FirstOrDefault(x => x.Id == configMeta.LockedByConfigPluginId);
if (plugin is null) if (plugin is null)
{ {
configMeta.ResetManagedState(); configMeta.ResetLockedConfiguration();
return true; return true;
} }
@ -273,13 +273,13 @@ public static partial class ManagedConfiguration
if (!TryGet(configSelection, propertyExpression, out var configMeta)) if (!TryGet(configSelection, propertyExpression, out var configMeta))
return false; return false;
if (configMeta.MangedByConfigPluginId == Guid.Empty || !configMeta.IsLocked) if (configMeta.LockedByConfigPluginId == Guid.Empty || !configMeta.IsLocked)
return false; return false;
var plugin = availablePlugins.FirstOrDefault(x => x.Id == configMeta.MangedByConfigPluginId); var plugin = availablePlugins.FirstOrDefault(x => x.Id == configMeta.LockedByConfigPluginId);
if (plugin is null) if (plugin is null)
{ {
configMeta.ResetManagedState(); configMeta.ResetLockedConfiguration();
return true; return true;
} }
@ -297,13 +297,13 @@ public static partial class ManagedConfiguration
if (!TryGet(configSelection, propertyExpression, out var configMeta)) if (!TryGet(configSelection, propertyExpression, out var configMeta))
return false; return false;
if (configMeta.MangedByConfigPluginId == Guid.Empty || !configMeta.IsLocked) if (configMeta.LockedByConfigPluginId == Guid.Empty || !configMeta.IsLocked)
return false; return false;
var plugin = availablePlugins.FirstOrDefault(x => x.Id == configMeta.MangedByConfigPluginId); var plugin = availablePlugins.FirstOrDefault(x => x.Id == configMeta.LockedByConfigPluginId);
if (plugin is null) if (plugin is null)
{ {
configMeta.ResetManagedState(); configMeta.ResetLockedConfiguration();
return true; return true;
} }
@ -320,13 +320,13 @@ public static partial class ManagedConfiguration
if (!TryGet(configSelection, propertyExpression, out var configMeta)) if (!TryGet(configSelection, propertyExpression, out var configMeta))
return false; return false;
if (configMeta.MangedByConfigPluginId == Guid.Empty || !configMeta.IsLocked) if (configMeta.LockedByConfigPluginId == Guid.Empty || !configMeta.IsLocked)
return false; return false;
var plugin = availablePlugins.FirstOrDefault(x => x.Id == configMeta.MangedByConfigPluginId); var plugin = availablePlugins.FirstOrDefault(x => x.Id == configMeta.LockedByConfigPluginId);
if (plugin is null) if (plugin is null)
{ {
configMeta.ResetManagedState(); configMeta.ResetLockedConfiguration();
return true; return true;
} }
@ -341,13 +341,13 @@ public static partial class ManagedConfiguration
if (!TryGet(configSelection, propertyExpression, out var configMeta)) if (!TryGet(configSelection, propertyExpression, out var configMeta))
return false; return false;
if (configMeta.MangedByConfigPluginId == Guid.Empty || !configMeta.IsLocked) if (configMeta.LockedByConfigPluginId == Guid.Empty || !configMeta.IsLocked)
return false; return false;
var plugin = availablePlugins.FirstOrDefault(x => x.Id == configMeta.MangedByConfigPluginId); var plugin = availablePlugins.FirstOrDefault(x => x.Id == configMeta.LockedByConfigPluginId);
if (plugin is null) if (plugin is null)
{ {
configMeta.ResetManagedState(); configMeta.ResetLockedConfiguration();
return true; return true;
} }
@ -355,10 +355,10 @@ public static partial class ManagedConfiguration
} }
/// <summary> /// <summary>
/// Checks if a managed value is left over from a configuration plugin that is no longer available. /// Checks if a plugin contribution is left over from a configuration plugin that is no longer available.
/// If so, it clears the managed value and returns true. /// If so, it clears the contribution and returns true.
/// </summary> /// </summary>
public static bool IsManagedValueLeftOver<TClass, TValue>( public static bool IsPluginContributionLeftOver<TClass, TValue>(
Expression<Func<Data, TClass>> configSelection, Expression<Func<Data, TClass>> configSelection,
Expression<Func<TClass, ISet<TValue>>> propertyExpression, Expression<Func<TClass, ISet<TValue>>> propertyExpression,
IEnumerable<IAvailablePlugin> availablePlugins) IEnumerable<IAvailablePlugin> availablePlugins)
@ -366,13 +366,13 @@ public static partial class ManagedConfiguration
if (!TryGet(configSelection, propertyExpression, out var configMeta)) if (!TryGet(configSelection, propertyExpression, out var configMeta))
return false; return false;
if (!configMeta.HasManagedValue || configMeta.ManagedValueByConfigPluginId == Guid.Empty) if (!configMeta.HasPluginContribution || configMeta.PluginContributionByConfigPluginId == Guid.Empty)
return false; return false;
var plugin = availablePlugins.FirstOrDefault(x => x.Id == configMeta.ManagedValueByConfigPluginId); var plugin = availablePlugins.FirstOrDefault(x => x.Id == configMeta.PluginContributionByConfigPluginId);
if (plugin is null) if (plugin is null)
{ {
configMeta.ClearManagedValue(); configMeta.ClearPluginContribution();
return true; return true;
} }
@ -387,13 +387,13 @@ public static partial class ManagedConfiguration
if (!TryGet(configSelection, propertyExpression, out var configMeta)) if (!TryGet(configSelection, propertyExpression, out var configMeta))
return false; return false;
if (configMeta.MangedByConfigPluginId == Guid.Empty || !configMeta.IsLocked) if (configMeta.LockedByConfigPluginId == Guid.Empty || !configMeta.IsLocked)
return false; return false;
var plugin = availablePlugins.FirstOrDefault(x => x.Id == configMeta.MangedByConfigPluginId); var plugin = availablePlugins.FirstOrDefault(x => x.Id == configMeta.LockedByConfigPluginId);
if (plugin is null) if (plugin is null)
{ {
configMeta.ResetManagedState(); configMeta.ResetLockedConfiguration();
return true; return true;
} }

View File

@ -121,8 +121,8 @@ public sealed class PluginConfiguration(bool isInternal, LuaState state, PluginT
// Config: preview features visibility // Config: preview features visibility
ManagedConfiguration.TryProcessConfiguration(x => x.App, x => x.PreviewVisibility, this.Id, settingsTable, dryRun); ManagedConfiguration.TryProcessConfiguration(x => x.App, x => x.PreviewVisibility, this.Id, settingsTable, dryRun);
// Config: enabled preview features (additive; users can enable additional features) // Config: enabled preview features (plugin contribution; users can enable additional features)
ManagedConfiguration.TryProcessConfigurationAdditive(x => x.App, x => x.EnabledPreviewFeatures, this.Id, settingsTable, dryRun); ManagedConfiguration.TryProcessConfigurationWithPluginContribution(x => x.App, x => x.EnabledPreviewFeatures, this.Id, settingsTable, dryRun);
// Config: hide some assistants? // Config: hide some assistants?
ManagedConfiguration.TryProcessConfiguration(x => x.App, x => x.HiddenAssistants, this.Id, settingsTable, dryRun); ManagedConfiguration.TryProcessConfiguration(x => x.App, x => x.HiddenAssistants, this.Id, settingsTable, dryRun);

View File

@ -218,7 +218,8 @@ public static partial class PluginFactory
// Check for enabled preview features: // Check for enabled preview features:
if(ManagedConfiguration.IsConfigurationLeftOver(x => x.App, x => x.EnabledPreviewFeatures, AVAILABLE_PLUGINS)) if(ManagedConfiguration.IsConfigurationLeftOver(x => x.App, x => x.EnabledPreviewFeatures, AVAILABLE_PLUGINS))
wasConfigurationChanged = true; wasConfigurationChanged = true;
if(ManagedConfiguration.IsManagedValueLeftOver(x => x.App, x => x.EnabledPreviewFeatures, AVAILABLE_PLUGINS))
if(ManagedConfiguration.IsPluginContributionLeftOver(x => x.App, x => x.EnabledPreviewFeatures, AVAILABLE_PLUGINS))
wasConfigurationChanged = true; wasConfigurationChanged = true;
// Check for the transcription provider: // Check for the transcription provider: