Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions Flow.Launcher/HotkeyControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public ICommand? ChangeHotkey
nameof(Type),
typeof(HotkeyType),
typeof(HotkeyControl),
new FrameworkPropertyMetadata(HotkeyType.Hotkey, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnHotkeyChanged)
new FrameworkPropertyMetadata(HotkeyType.None, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnHotkeyChanged)
);

public HotkeyType Type
Expand All @@ -95,6 +95,9 @@ public HotkeyType Type

public enum HotkeyType
{
// Custom hotkeys
None, // Used for getting hotkey from dialog result
// Settings hotkeys
Hotkey,
PreviewHotkey,
OpenContextMenuHotkey,
Expand All @@ -115,12 +118,16 @@ public enum HotkeyType
// and it will not construct settings instances twice
private static readonly Settings _settings = Ioc.Default.GetRequiredService<Settings>();

private string hotkey = string.Empty;
public string Hotkey
{
get
{
return Type switch
{
// Custom hotkeys
HotkeyType.None => hotkey,
// Settings hotkeys
HotkeyType.Hotkey => _settings.Hotkey,
HotkeyType.PreviewHotkey => _settings.PreviewHotkey,
HotkeyType.OpenContextMenuHotkey => _settings.OpenContextMenuHotkey,
Expand All @@ -135,13 +142,18 @@ public string Hotkey
HotkeyType.SelectPrevItemHotkey2 => _settings.SelectPrevItemHotkey2,
HotkeyType.SelectNextItemHotkey => _settings.SelectNextItemHotkey,
HotkeyType.SelectNextItemHotkey2 => _settings.SelectNextItemHotkey2,
_ => string.Empty
_ => throw new System.NotImplementedException("Hotkey type not setted")
};
}
set
{
switch (Type)
{
// Custom hotkeys
case HotkeyType.None:
hotkey = value;
break;
// Settings hotkeys
case HotkeyType.Hotkey:
_settings.Hotkey = value;
break;
Expand Down Expand Up @@ -185,7 +197,7 @@ public string Hotkey
_settings.SelectNextItemHotkey2 = value;
break;
default:
return;
throw new System.NotImplementedException("Hotkey type not setted");
}

// After setting the hotkey, we need to refresh the interface
Expand Down
Loading