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;
var filtered = previewVisibility.FilterPreviewFeatures(this.SettingsManager.ConfigurationData.App.EnabledPreviewFeatures);
filtered.UnionWith(this.GetManagedPreviewFeatures());
filtered.UnionWith(this.GetPluginContributedPreviewFeatures());
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)
return meta.ManagedValue.Where(x => !x.IsReleased()).ToHashSet();
if (ManagedConfiguration.TryGet(x => x.App, x => x.EnabledPreviewFeatures, out var meta) && meta.HasPluginContribution)
return meta.PluginContribution.Where(x => !x.IsReleased()).ToHashSet();
return [];
}
@ -43,13 +43,13 @@ public partial class SettingsPanelApp : SettingsPanelBase
private HashSet<PreviewFeatures> GetSelectedPreviewFeatures()
{
var enabled = this.SettingsManager.ConfigurationData.App.EnabledPreviewFeatures.Where(x => !x.IsReleased()).ToHashSet();
enabled.UnionWith(this.GetManagedPreviewFeatures());
enabled.UnionWith(this.GetPluginContributedPreviewFeatures());
return enabled;
}
private void UpdateEnabledPreviewFeatures(HashSet<PreviewFeatures> selectedFeatures)
{
selectedFeatures.UnionWith(this.GetManagedPreviewFeatures());
selectedFeatures.UnionWith(this.GetPluginContributedPreviewFeatures());
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; }
/// <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>
public bool IsLocked { get; private set; }
/// <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>
public Guid MangedByConfigPluginId { get; private set; }
public Guid LockedByConfigPluginId { get; private set; }
/// <summary>
/// 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; }
/// <summary>
/// Indicates whether a managed value is available.
/// Indicates whether a plugin contribution is available.
/// </summary>
public bool HasManagedValue { get; private set; }
public bool HasPluginContribution { get; private set; }
/// <summary>
/// The managed value provided by a configuration plugin.
/// The additive value contribution provided by a configuration plugin.
/// </summary>
public TValue ManagedValue { get; private set; } = default!;
public TValue PluginContribution { get; private set; } = default!;
/// <summary>
/// The ID of the plugin that provided the managed value.
/// The ID of the plugin that provided the additive value contribution.
/// </summary>
public Guid ManagedValueByConfigPluginId { get; private set; }
public Guid PluginContributionByConfigPluginId { get; private set; }
/// <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>
/// <param name="pluginId">The ID of the plugin that is managing this configuration.</param>
public void LockManagedState(Guid pluginId)
/// <param name="pluginId">The ID of the plugin that is locking this configuration.</param>
public void LockConfiguration(Guid pluginId)
{
this.IsLocked = true;
this.MangedByConfigPluginId = pluginId;
this.LockedByConfigPluginId = pluginId;
}
/// <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.
/// </summary>
public void ResetManagedState()
public void ResetLockedConfiguration()
{
this.IsLocked = false;
this.MangedByConfigPluginId = Guid.Empty;
this.LockedByConfigPluginId = Guid.Empty;
this.Reset();
}
/// <summary>
/// Unlocks the configuration state without changing the current value.
/// </summary>
public void UnlockManagedState()
public void UnlockConfiguration()
{
this.IsLocked = false;
this.MangedByConfigPluginId = Guid.Empty;
this.LockedByConfigPluginId = Guid.Empty;
}
/// <summary>
/// Stores a managed value provided by a configuration plugin.
/// Stores an additive plugin contribution.
/// </summary>
public void SetManagedValue(TValue value, Guid pluginId)
public void SetPluginContribution(TValue value, Guid pluginId)
{
this.ManagedValue = value;
this.ManagedValueByConfigPluginId = pluginId;
this.HasManagedValue = true;
this.PluginContribution = value;
this.PluginContributionByConfigPluginId = pluginId;
this.HasPluginContribution = true;
}
/// <summary>
/// Clears the managed value without changing the current value.
/// Clears the additive plugin contribution without changing the current value.
/// </summary>
public void ClearManagedValue()
public void ClearPluginContribution()
{
this.ManagedValue = default!;
this.ManagedValueByConfigPluginId = Guid.Empty;
this.HasManagedValue = false;
this.PluginContribution = default!;
this.PluginContributionByConfigPluginId = Guid.Empty;
this.HasPluginContribution = false;
}
/// <summary>

View File

@ -583,8 +583,8 @@ public static partial class ManagedConfiguration
}
/// <summary>
/// Attempts to process the configuration settings from a Lua table for enum set types.
/// The configured values are merged into the existing set, and the setting is left unlocked
/// Attempts to process additive plugin contributions for enum set settings from a Lua table.
/// The contributed values are merged into the existing set, and the setting remains unlocked
/// so users can add additional values.
/// </summary>
/// <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
/// elements, which must be an enum.</typeparam>
/// <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<TClass, ISet<TValue>>> propertyExpression,
Guid configPluginId,
@ -653,15 +653,15 @@ public static partial class ManagedConfiguration
var merged = new HashSet<TValue>(currentValue);
merged.UnionWith(configuredValue);
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)
configMeta.UnlockManagedState();
if (configMeta.IsLocked && configMeta.LockedByConfigPluginId == configPluginId)
configMeta.UnlockConfiguration();
return successful;
}
@ -828,12 +828,12 @@ public static partial class ManagedConfiguration
// 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.LockManagedState(configPluginId);
configMeta.LockConfiguration(configPluginId);
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.
// 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,
// 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.
//
configMeta.ResetManagedState();
configMeta.ResetLockedConfiguration();
break;
case false:

View File

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

View File

@ -121,8 +121,8 @@ public sealed class PluginConfiguration(bool isInternal, LuaState state, PluginT
// Config: preview features visibility
ManagedConfiguration.TryProcessConfiguration(x => x.App, x => x.PreviewVisibility, this.Id, settingsTable, dryRun);
// Config: enabled preview features (additive; users can enable additional features)
ManagedConfiguration.TryProcessConfigurationAdditive(x => x.App, x => x.EnabledPreviewFeatures, this.Id, settingsTable, dryRun);
// Config: enabled preview features (plugin contribution; users can enable additional features)
ManagedConfiguration.TryProcessConfigurationWithPluginContribution(x => x.App, x => x.EnabledPreviewFeatures, this.Id, settingsTable, dryRun);
// Config: hide some assistants?
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:
if(ManagedConfiguration.IsConfigurationLeftOver(x => x.App, x => x.EnabledPreviewFeatures, AVAILABLE_PLUGINS))
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;
// Check for the transcription provider: