Use set hotkey function instead of setter

This commit is contained in:
Jack251970 2025-07-06 20:52:36 +08:00
parent 51917809b3
commit 4055e30538
2 changed files with 12 additions and 3 deletions

View file

@ -26,7 +26,7 @@ public record RegisteredHotkeyData
/// <summary>
/// <see cref="HotkeyModel"/> representation of this hotkey.
/// </summary>
public HotkeyModel Hotkey { get; set; }
public HotkeyModel Hotkey { get; private set; }
/// <summary>
/// String key in the localization dictionary that represents this hotkey. For example, <c>ReloadPluginHotkey</c>,
@ -233,6 +233,15 @@ public record RegisteredHotkeyData
RemoveHotkey = removeHotkey;
}
/// <summary>
/// Sets the hotkey for this registered hotkey data.
/// </summary>
/// <param name="hotkey"></param>
public void SetHotkey(HotkeyModel hotkey)
{
Hotkey = hotkey;
}
/// <inheritdoc />
public override string ToString()
{

View file

@ -260,7 +260,7 @@ internal static class HotKeyMapper
{
var hotkeyData = SearchRegisteredHotkeyData(metadata, globalPluginHotkey);
RemoveHotkey(hotkeyData);
hotkeyData.Hotkey = newHotkey;
hotkeyData.SetHotkey(newHotkey);
SetHotkey(hotkeyData);
}
else if (pluginHotkey is SearchWindowPluginHotkey)
@ -591,7 +591,7 @@ internal static class HotKeyMapper
RemoveHotkey(registeredHotkeyData);
// Update the hotkey string
registeredHotkeyData.Hotkey = newHotkey;
registeredHotkeyData.SetHotkey(newHotkey);
// Set the new hotkey
SetHotkey(registeredHotkeyData);