Added settings pattern reset

This commit is contained in:
Thorsten Sommer 2026-08-11 13:43:47 +02:00
parent 75aeb784d2
commit 8cf138ccac
Signed by untrusted user who does not match committer: tsommer
GPG Key ID: 371BBA77A02C0108
4 changed files with 69 additions and 16 deletions

View File

@ -6571,6 +6571,9 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SETTINGS::SETTINGSDIALOGBATCHPROCESSING::T62
-- Default source of the instructions -- Default source of the instructions
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SETTINGS::SETTINGSDIALOGBATCHPROCESSING::T704081768"] = "Default source of the instructions" UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SETTINGS::SETTINGSDIALOGBATCHPROCESSING::T704081768"] = "Default source of the instructions"
-- Restore default patterns
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SETTINGS::SETTINGSDIALOGBATCHPROCESSING::T7425959"] = "Restore default patterns"
-- Leave empty when an input folder should be selected for every batch run. -- Leave empty when an input folder should be selected for every batch run.
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SETTINGS::SETTINGSDIALOGBATCHPROCESSING::T762890100"] = "Leave empty when an input folder should be selected for every batch run." UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SETTINGS::SETTINGSDIALOGBATCHPROCESSING::T762890100"] = "Leave empty when an input folder should be selected for every batch run."

View File

@ -1,17 +1,44 @@
@inherits ConfigurationBaseCore @inherits ConfigurationBaseCore
<MudTextField @if (this.ResetValue is null)
T="string" {
Text="@this.Text()" <MudTextField
TextChanged="@this.InternalUpdate" T="string"
Disabled="@this.IsDisabled" Text="@this.Text()"
Adornment="Adornment.Start" TextChanged="@this.InternalUpdate"
AdornmentIcon="@this.Icon" Disabled="@this.IsDisabled"
AdornmentColor="@this.IconColor" Adornment="Adornment.Start"
UserAttributes="@SPELLCHECK_ATTRIBUTES" AdornmentIcon="@this.Icon"
Lines="@this.NumLines" AdornmentColor="@this.IconColor"
AutoGrow="@this.AutoGrow" UserAttributes="@SPELLCHECK_ATTRIBUTES"
MaxLines="@this.GetMaxLines" Lines="@this.NumLines"
Immediate="@true" AutoGrow="@this.AutoGrow"
Underline="false" MaxLines="@this.GetMaxLines"
/> Immediate="@true"
Underline="false"
/>
}
else
{
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2">
<MudTextField
T="string"
Text="@this.Text()"
TextChanged="@this.InternalUpdate"
Disabled="@this.IsDisabled"
Adornment="Adornment.Start"
AdornmentIcon="@this.Icon"
AdornmentColor="@this.IconColor"
UserAttributes="@SPELLCHECK_ATTRIBUTES"
Lines="@this.NumLines"
AutoGrow="@this.AutoGrow"
MaxLines="@this.GetMaxLines"
Immediate="@true"
Underline="false"
Class="flex-grow-1"
/>
<MudButton Variant="Variant.Outlined" StartIcon="@Icons.Material.Filled.Restore" Disabled="@this.IsDisabled" OnClick="@this.ResetTextAsync" Class="mb-1">
@this.ResetButtonText
</MudButton>
</MudStack>
}

View File

@ -41,6 +41,18 @@ public partial class ConfigurationText : ConfigurationBaseCore
/// </summary> /// </summary>
[Parameter] [Parameter]
public int MaxLines { get; set; } = 12; public int MaxLines { get; set; } = 12;
/// <summary>
/// When configured, displays a button which restores this value.
/// </summary>
[Parameter]
public Func<string>? ResetValue { get; set; }
/// <summary>
/// The text displayed on the optional reset button.
/// </summary>
[Parameter]
public string ResetButtonText { get; set; } = string.Empty;
private string internalText = string.Empty; private string internalText = string.Empty;
private readonly Timer timer = new(TimeSpan.FromMilliseconds(500)) private readonly Timer timer = new(TimeSpan.FromMilliseconds(500))
@ -85,6 +97,16 @@ public partial class ConfigurationText : ConfigurationBaseCore
this.internalText = text; this.internalText = text;
this.timer.Start(); this.timer.Start();
} }
private async Task ResetTextAsync()
{
if (this.ResetValue is null || this.IsDisabled)
return;
this.timer.Stop();
this.internalText = this.ResetValue();
await this.OptionChanged(this.internalText);
}
private async Task OptionChanged(string updatedText) private async Task OptionChanged(string updatedText)
{ {

View File

@ -1,5 +1,6 @@
@using AIStudio.Assistants.BatchProcessing @using AIStudio.Assistants.BatchProcessing
@using AIStudio.Settings @using AIStudio.Settings
@using AIStudio.Settings.DataModel
@using AIStudio.Tools.Rust @using AIStudio.Tools.Rust
@inherits SettingsDialogBase @inherits SettingsDialogBase
@ -16,7 +17,7 @@
<MudText Typo="Typo.h6" Class="mb-3">@T("Input")</MudText> <MudText Typo="Typo.h6" Class="mb-3">@T("Input")</MudText>
<ConfigurationText OptionDescription="@T("Default input folder")" Disabled="@this.DefaultsDisabled" Icon="@Icons.Material.Filled.Folder" Text="@(() => this.SettingsManager.ConfigurationData.BatchProcessing.InputDirectory)" TextUpdate="@(value => this.SettingsManager.ConfigurationData.BatchProcessing.InputDirectory = value)" OptionHelp="@T("Leave empty when an input folder should be selected for every batch run.")" IsLocked="() => ManagedConfiguration.TryGet(x => x.BatchProcessing, x => x.InputDirectory, out var meta) && meta.IsLocked"/> <ConfigurationText OptionDescription="@T("Default input folder")" Disabled="@this.DefaultsDisabled" Icon="@Icons.Material.Filled.Folder" Text="@(() => this.SettingsManager.ConfigurationData.BatchProcessing.InputDirectory)" TextUpdate="@(value => this.SettingsManager.ConfigurationData.BatchProcessing.InputDirectory = value)" OptionHelp="@T("Leave empty when an input folder should be selected for every batch run.")" IsLocked="() => ManagedConfiguration.TryGet(x => x.BatchProcessing, x => x.InputDirectory, out var meta) && meta.IsLocked"/>
<ConfigurationText OptionDescription="@T("Default file patterns")" Disabled="@this.DefaultsDisabled" Icon="@Icons.Material.Filled.FilterAlt" Text="@(() => this.SettingsManager.ConfigurationData.BatchProcessing.FilePatterns)" TextUpdate="@(value => this.SettingsManager.ConfigurationData.BatchProcessing.FilePatterns = value)" OptionHelp="@T("Separate multiple file patterns with a semicolon, e.g., *.pdf;*.docx.")" IsLocked="() => ManagedConfiguration.TryGet(x => x.BatchProcessing, x => x.FilePatterns, out var meta) && meta.IsLocked"/> <ConfigurationText OptionDescription="@T("Default file patterns")" Disabled="@this.DefaultsDisabled" Icon="@Icons.Material.Filled.FilterAlt" Text="@(() => this.SettingsManager.ConfigurationData.BatchProcessing.FilePatterns)" TextUpdate="@(value => this.SettingsManager.ConfigurationData.BatchProcessing.FilePatterns = value)" ResetValue="@(() => DataBatchProcessing.DEFAULT_FILE_PATTERNS)" ResetButtonText="@T("Restore default patterns")" OptionHelp="@T("Separate multiple file patterns with a semicolon, e.g., *.pdf;*.docx.")" IsLocked="() => ManagedConfiguration.TryGet(x => x.BatchProcessing, x => x.FilePatterns, out var meta) && meta.IsLocked"/>
<ConfigurationOption OptionDescription="@T("Include subfolders by default?")" Disabled="@this.DefaultsDisabled" LabelOn="@T("Subfolders are included")" LabelOff="@T("Only the selected folder is processed")" State="@(() => this.SettingsManager.ConfigurationData.BatchProcessing.IncludeSubdirectories)" StateUpdate="@(value => this.SettingsManager.ConfigurationData.BatchProcessing.IncludeSubdirectories = value)" IsLocked="() => ManagedConfiguration.TryGet(x => x.BatchProcessing, x => x.IncludeSubdirectories, out var meta) && meta.IsLocked"/> <ConfigurationOption OptionDescription="@T("Include subfolders by default?")" Disabled="@this.DefaultsDisabled" LabelOn="@T("Subfolders are included")" LabelOff="@T("Only the selected folder is processed")" State="@(() => this.SettingsManager.ConfigurationData.BatchProcessing.IncludeSubdirectories)" StateUpdate="@(value => this.SettingsManager.ConfigurationData.BatchProcessing.IncludeSubdirectories = value)" IsLocked="() => ManagedConfiguration.TryGet(x => x.BatchProcessing, x => x.IncludeSubdirectories, out var meta) && meta.IsLocked"/>
<MudText Typo="Typo.h6" Class="mb-3 mt-6">@T("Instructions")</MudText> <MudText Typo="Typo.h6" Class="mb-3 mt-6">@T("Instructions")</MudText>