Simplified voice recording shortcut update logic

This commit is contained in:
Thorsten Sommer 2026-01-23 14:16:48 +01:00
parent 8a18f7d069
commit 1fdd6aa875
Signed by untrusted user who does not match committer: tsommer
GPG Key ID: 371BBA77A02C0108
3 changed files with 3 additions and 9 deletions

View File

@ -27,7 +27,7 @@ public partial class ConfigurationShortcut : ConfigurationBaseCore
/// An action which is called when the shortcut was changed. /// An action which is called when the shortcut was changed.
/// </summary> /// </summary>
[Parameter] [Parameter]
public Func<string, Task> ShortcutUpdate { get; set; } = _ => Task.CompletedTask; public Action<string> ShortcutUpdate { get; set; } = _ => { };
/// <summary> /// <summary>
/// The name/identifier of the shortcut (used for conflict detection and registration). /// The name/identifier of the shortcut (used for conflict detection and registration).
@ -94,7 +94,7 @@ public partial class ConfigurationShortcut : ConfigurationBaseCore
if (dialogResult.Data is string newShortcut) if (dialogResult.Data is string newShortcut)
{ {
await this.ShortcutUpdate(newShortcut); this.ShortcutUpdate(newShortcut);
await this.SettingsManager.StoreSettings(); await this.SettingsManager.StoreSettings();
await this.InformAboutChange(); await this.InformAboutChange();
} }

View File

@ -33,6 +33,6 @@
@if (PreviewFeatures.PRE_SPEECH_TO_TEXT_2026.IsEnabled(this.SettingsManager)) @if (PreviewFeatures.PRE_SPEECH_TO_TEXT_2026.IsEnabled(this.SettingsManager))
{ {
<ConfigurationSelect OptionDescription="@T("Select a transcription provider")" SelectedValue="@(() => this.SettingsManager.ConfigurationData.App.UseTranscriptionProvider)" Data="@this.GetFilteredTranscriptionProviders()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.App.UseTranscriptionProvider = selectedValue)" OptionHelp="@T("Select a transcription provider for transcribing your voice. Without a selected provider, dictation and transcription features will be disabled.")" IsLocked="() => ManagedConfiguration.TryGet(x => x.App, x => x.UseTranscriptionProvider, out var meta) && meta.IsLocked"/> <ConfigurationSelect OptionDescription="@T("Select a transcription provider")" SelectedValue="@(() => this.SettingsManager.ConfigurationData.App.UseTranscriptionProvider)" Data="@this.GetFilteredTranscriptionProviders()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.App.UseTranscriptionProvider = selectedValue)" OptionHelp="@T("Select a transcription provider for transcribing your voice. Without a selected provider, dictation and transcription features will be disabled.")" IsLocked="() => ManagedConfiguration.TryGet(x => x.App, x => x.UseTranscriptionProvider, out var meta) && meta.IsLocked"/>
<ConfigurationShortcut OptionDescription="@T("Voice recording shortcut")" Shortcut="@(() => this.SettingsManager.ConfigurationData.App.ShortcutVoiceRecording)" ShortcutUpdate="@this.UpdateVoiceRecordingShortcut" ShortcutName="voice_recording_toggle" OptionHelp="@T("The global keyboard shortcut for toggling voice recording. This shortcut works system-wide, even when the app is not focused.")" IsLocked="() => ManagedConfiguration.TryGet(x => x.App, x => x.ShortcutVoiceRecording, out var meta) && meta.IsLocked"/> <ConfigurationShortcut OptionDescription="@T("Voice recording shortcut")" Shortcut="@(() => this.SettingsManager.ConfigurationData.App.ShortcutVoiceRecording)" ShortcutUpdate="@(shortcut => this.SettingsManager.ConfigurationData.App.ShortcutVoiceRecording = shortcut)" ShortcutName="voice_recording_toggle" OptionHelp="@T("The global keyboard shortcut for toggling voice recording. This shortcut works system-wide, even when the app is not focused.")" IsLocked="() => ManagedConfiguration.TryGet(x => x.App, x => x.ShortcutVoiceRecording, out var meta) && meta.IsLocked"/>
} }
</ExpansionPanel> </ExpansionPanel>

View File

@ -35,10 +35,4 @@ public partial class SettingsPanelApp : SettingsPanelBase
this.SettingsManager.ConfigurationData.App.LanguagePluginId = pluginId; this.SettingsManager.ConfigurationData.App.LanguagePluginId = pluginId;
await this.MessageBus.SendMessage<bool>(this, Event.PLUGINS_RELOADED); await this.MessageBus.SendMessage<bool>(this, Event.PLUGINS_RELOADED);
} }
private async Task UpdateVoiceRecordingShortcut(string shortcut)
{
this.SettingsManager.ConfigurationData.App.ShortcutVoiceRecording = shortcut;
await this.RustService.UpdateGlobalShortcut("voice_recording_toggle", shortcut);
}
} }