Skip to content

Commit aeec3a9

Browse files
[CmdPal]Fix resetting the hotkey in Settings (#38149)
Fix resetting the hotkey in Settings
1 parent be1968a commit aeec3a9

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SettingsModel.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ public partial class SettingsModel : ObservableObject
2222

2323
///////////////////////////////////////////////////////////////////////////
2424
// SETTINGS HERE
25-
public HotkeySettings? Hotkey { get; set; } = new HotkeySettings(true, false, true, false, 0x20); // win+alt+space
25+
public static HotkeySettings DefaultActivationShortcut { get; } = new HotkeySettings(true, false, true, false, 0x20); // win+alt+space
26+
27+
public HotkeySettings? Hotkey { get; set; } = DefaultActivationShortcut;
2628

2729
public bool ShowAppDetails { get; set; }
2830

src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SettingsViewModel.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,26 @@
33
// See the LICENSE file in the project root for more information.
44

55
using System.Collections.ObjectModel;
6+
using System.ComponentModel;
67
using Microsoft.CmdPal.UI.ViewModels.Settings;
78
using Microsoft.Extensions.DependencyInjection;
89

910
namespace Microsoft.CmdPal.UI.ViewModels;
1011

11-
public partial class SettingsViewModel
12+
public partial class SettingsViewModel : INotifyPropertyChanged
1213
{
1314
private readonly SettingsModel _settings;
1415
private readonly IServiceProvider _serviceProvider;
1516

17+
public event PropertyChangedEventHandler? PropertyChanged;
18+
1619
public HotkeySettings? Hotkey
1720
{
1821
get => _settings.Hotkey;
1922
set
2023
{
21-
_settings.Hotkey = value;
24+
_settings.Hotkey = value ?? SettingsModel.DefaultActivationShortcut;
25+
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Hotkey)));
2226
Save();
2327
}
2428
}

0 commit comments

Comments
 (0)