[CmdPal]Fix resetting the hotkey in Settings (#38149)

Fix resetting the hotkey in Settings
This commit is contained in:
Jaime Bernardo
2025-03-25 18:58:46 +00:00
committed by GitHub
parent be1968aaa5
commit aeec3a967f
2 changed files with 9 additions and 3 deletions

View File

@@ -22,7 +22,9 @@ public partial class SettingsModel : ObservableObject
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// SETTINGS HERE // SETTINGS HERE
public HotkeySettings? Hotkey { get; set; } = new HotkeySettings(true, false, true, false, 0x20); // win+alt+space public static HotkeySettings DefaultActivationShortcut { get; } = new HotkeySettings(true, false, true, false, 0x20); // win+alt+space
public HotkeySettings? Hotkey { get; set; } = DefaultActivationShortcut;
public bool ShowAppDetails { get; set; } public bool ShowAppDetails { get; set; }

View File

@@ -3,22 +3,26 @@
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.ComponentModel;
using Microsoft.CmdPal.UI.ViewModels.Settings; using Microsoft.CmdPal.UI.ViewModels.Settings;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
namespace Microsoft.CmdPal.UI.ViewModels; namespace Microsoft.CmdPal.UI.ViewModels;
public partial class SettingsViewModel public partial class SettingsViewModel : INotifyPropertyChanged
{ {
private readonly SettingsModel _settings; private readonly SettingsModel _settings;
private readonly IServiceProvider _serviceProvider; private readonly IServiceProvider _serviceProvider;
public event PropertyChangedEventHandler? PropertyChanged;
public HotkeySettings? Hotkey public HotkeySettings? Hotkey
{ {
get => _settings.Hotkey; get => _settings.Hotkey;
set set
{ {
_settings.Hotkey = value; _settings.Hotkey = value ?? SettingsModel.DefaultActivationShortcut;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Hotkey)));
Save(); Save();
} }
} }