using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace Hua.Todo.Avalonia.Models;

/// <summary>
/// 热键配置模型。
/// 用于描述全局热键的修饰键、主键与启用状态，并通过通知机制驱动动态更新。
/// </summary>
public sealed class HotKeyConfig : INotifyPropertyChanged
{
    private string _modifiers = "Alt";
    private string _key = "X";
    private bool _isEnabled = true;

    /// <summary>
    /// 修饰键（例如 Alt、Control、Shift、Windows；多个键用逗号分隔）。
    /// </summary>
    public string Modifiers
    {
        get => _modifiers;
        set
        {
            if (_modifiers != value)
            {
                _modifiers = value;
                OnPropertyChanged();
            }
        }
    }

    /// <summary>
    /// 主键（例如 X、C、V）。
    /// </summary>
    public string Key
    {
        get => _key;
        set
        {
            if (_key != value)
            {
                _key = value;
                OnPropertyChanged();
            }
        }
    }

    /// <summary>
    /// 是否启用热键。
    /// </summary>
    public bool IsEnabled
    {
        get => _isEnabled;
        set
        {
            if (_isEnabled != value)
            {
                _isEnabled = value;
                OnPropertyChanged();
            }
        }
    }

    /// <inheritdoc />
    public event PropertyChangedEventHandler? PropertyChanged;

    private void OnPropertyChanged([CallerMemberName] string? propertyName = null)
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
    }
}

