Add validation for unchanged shortcuts in ShortcutDialog

This commit is contained in:
Thorsten Sommer 2026-01-24 20:04:01 +01:00
parent c9b6619fc9
commit 6439862fb8
Signed by untrusted user who does not match committer: tsommer
GPG Key ID: 371BBA77A02C0108
4 changed files with 21 additions and 0 deletions

View File

@ -4654,6 +4654,9 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SHORTCUTDIALOG::T3159532525"] = "Shortcut is
-- Define a shortcut -- Define a shortcut
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SHORTCUTDIALOG::T3734850493"] = "Define a shortcut" UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SHORTCUTDIALOG::T3734850493"] = "Define a shortcut"
-- This is the shortcut you previously used.
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SHORTCUTDIALOG::T4167229652"] = "This is the shortcut you previously used."
-- Supported modifiers: Ctrl/Cmd, Shift, Alt. -- Supported modifiers: Ctrl/Cmd, Shift, Alt.
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SHORTCUTDIALOG::T889258890"] = "Supported modifiers: Ctrl/Cmd, Shift, Alt." UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SHORTCUTDIALOG::T889258890"] = "Supported modifiers: Ctrl/Cmd, Shift, Alt."

View File

@ -33,6 +33,7 @@ public partial class ShortcutDialog : MSGComponentBase
private static readonly Dictionary<string, object?> USER_INPUT_ATTRIBUTES = new(); private static readonly Dictionary<string, object?> USER_INPUT_ATTRIBUTES = new();
private string currentShortcut = string.Empty; private string currentShortcut = string.Empty;
private string originalShortcut = string.Empty;
private string validationMessage = string.Empty; private string validationMessage = string.Empty;
private Severity validationSeverity = Severity.Info; private Severity validationSeverity = Severity.Info;
private bool hasValidationError; private bool hasValidationError;
@ -57,6 +58,7 @@ public partial class ShortcutDialog : MSGComponentBase
this.SettingsManager.InjectSpellchecking(USER_INPUT_ATTRIBUTES); this.SettingsManager.InjectSpellchecking(USER_INPUT_ATTRIBUTES);
this.currentShortcut = this.InitialShortcut; this.currentShortcut = this.InitialShortcut;
this.originalShortcut = this.InitialShortcut;
this.ParseExistingShortcut(); this.ParseExistingShortcut();
} }
@ -179,6 +181,16 @@ public partial class ShortcutDialog : MSGComponentBase
var result = await this.RustService.ValidateShortcut(this.currentShortcut); var result = await this.RustService.ValidateShortcut(this.currentShortcut);
if (result.IsValid) if (result.IsValid)
{ {
if (!string.IsNullOrWhiteSpace(this.originalShortcut)
&& this.currentShortcut.Equals(this.originalShortcut, StringComparison.OrdinalIgnoreCase))
{
this.validationMessage = T("This is the shortcut you previously used.");
this.validationSeverity = Severity.Info;
this.hasValidationError = false;
this.StateHasChanged();
return;
}
if (result.HasConflict) if (result.HasConflict)
{ {
this.validationMessage = string.Format(T("This shortcut conflicts with: {0}"), result.ConflictDescription); this.validationMessage = string.Format(T("This shortcut conflicts with: {0}"), result.ConflictDescription);

View File

@ -4656,6 +4656,9 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SHORTCUTDIALOG::T3159532525"] = "Der Tastatu
-- Define a shortcut -- Define a shortcut
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SHORTCUTDIALOG::T3734850493"] = "Tastaturkurzbefehl festlegen" UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SHORTCUTDIALOG::T3734850493"] = "Tastaturkurzbefehl festlegen"
-- This is the shortcut you previously used.
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SHORTCUTDIALOG::T4167229652"] = "Dies ist der Tastaturkurzbefehl, den Sie zuvor verwendet haben."
-- Supported modifiers: Ctrl/Cmd, Shift, Alt. -- Supported modifiers: Ctrl/Cmd, Shift, Alt.
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SHORTCUTDIALOG::T889258890"] = "Unterstützte Modifikatortasten: Strg/Cmd, Umschalt, Alt." UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SHORTCUTDIALOG::T889258890"] = "Unterstützte Modifikatortasten: Strg/Cmd, Umschalt, Alt."

View File

@ -4656,6 +4656,9 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SHORTCUTDIALOG::T3159532525"] = "Shortcut is
-- Define a shortcut -- Define a shortcut
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SHORTCUTDIALOG::T3734850493"] = "Define a shortcut" UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SHORTCUTDIALOG::T3734850493"] = "Define a shortcut"
-- This is the shortcut you previously used.
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SHORTCUTDIALOG::T4167229652"] = "This is the shortcut you previously used."
-- Supported modifiers: Ctrl/Cmd, Shift, Alt. -- Supported modifiers: Ctrl/Cmd, Shift, Alt.
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SHORTCUTDIALOG::T889258890"] = "Supported modifiers: Ctrl/Cmd, Shift, Alt." UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SHORTCUTDIALOG::T889258890"] = "Supported modifiers: Ctrl/Cmd, Shift, Alt."