Skip to content

Commit afdb56d

Browse files
committed
Change RegisteredHotkeys to observable
1 parent b87f233 commit afdb56d

File tree

2 files changed

+3
-88
lines changed

2 files changed

+3
-88
lines changed

Flow.Launcher.Infrastructure/Hotkey/IHotkeySettings.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Collections.Generic;
1+
using System.Collections.ObjectModel;
22

33
namespace Flow.Launcher.Infrastructure.Hotkey;
44

@@ -13,5 +13,5 @@ public interface IHotkeySettings
1313
/// A list of hotkeys that have already been registered. The dialog will display these hotkeys and provide a way to
1414
/// unregister them.
1515
/// </summary>
16-
public List<RegisteredHotkeyData> RegisteredHotkeys { get; }
16+
public ObservableCollection<RegisteredHotkeyData> RegisteredHotkeys { get; }
1717
}

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 1 addition & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -435,92 +435,7 @@ public bool ShowAtTopmost
435435
public PluginsSettings PluginSettings { get; set; } = new();
436436

437437
[JsonIgnore]
438-
public List<RegisteredHotkeyData> RegisteredHotkeys
439-
{
440-
get
441-
{
442-
var list = FixedHotkeys();
443-
444-
// Customizeable hotkeys
445-
if (!string.IsNullOrEmpty(Hotkey))
446-
list.Add(new(Hotkey, "flowlauncherHotkey", () => Hotkey = ""));
447-
if (!string.IsNullOrEmpty(PreviewHotkey))
448-
list.Add(new(PreviewHotkey, "previewHotkey", () => PreviewHotkey = ""));
449-
if (!string.IsNullOrEmpty(AutoCompleteHotkey))
450-
list.Add(new(AutoCompleteHotkey, "autoCompleteHotkey", () => AutoCompleteHotkey = ""));
451-
if (!string.IsNullOrEmpty(AutoCompleteHotkey2))
452-
list.Add(new(AutoCompleteHotkey2, "autoCompleteHotkey", () => AutoCompleteHotkey2 = ""));
453-
if (!string.IsNullOrEmpty(SelectNextItemHotkey))
454-
list.Add(new(SelectNextItemHotkey, "SelectNextItemHotkey", () => SelectNextItemHotkey = ""));
455-
if (!string.IsNullOrEmpty(SelectNextItemHotkey2))
456-
list.Add(new(SelectNextItemHotkey2, "SelectNextItemHotkey", () => SelectNextItemHotkey2 = ""));
457-
if (!string.IsNullOrEmpty(SelectPrevItemHotkey))
458-
list.Add(new(SelectPrevItemHotkey, "SelectPrevItemHotkey", () => SelectPrevItemHotkey = ""));
459-
if (!string.IsNullOrEmpty(SelectPrevItemHotkey2))
460-
list.Add(new(SelectPrevItemHotkey2, "SelectPrevItemHotkey", () => SelectPrevItemHotkey2 = ""));
461-
if (!string.IsNullOrEmpty(SettingWindowHotkey))
462-
list.Add(new(SettingWindowHotkey, "SettingWindowHotkey", () => SettingWindowHotkey = ""));
463-
if (!string.IsNullOrEmpty(OpenHistoryHotkey))
464-
list.Add(new(OpenHistoryHotkey, "OpenHistoryHotkey", () => OpenHistoryHotkey = ""));
465-
if (!string.IsNullOrEmpty(OpenContextMenuHotkey))
466-
list.Add(new(OpenContextMenuHotkey, "OpenContextMenuHotkey", () => OpenContextMenuHotkey = ""));
467-
if (!string.IsNullOrEmpty(SelectNextPageHotkey))
468-
list.Add(new(SelectNextPageHotkey, "SelectNextPageHotkey", () => SelectNextPageHotkey = ""));
469-
if (!string.IsNullOrEmpty(SelectPrevPageHotkey))
470-
list.Add(new(SelectPrevPageHotkey, "SelectPrevPageHotkey", () => SelectPrevPageHotkey = ""));
471-
if (!string.IsNullOrEmpty(CycleHistoryUpHotkey))
472-
list.Add(new(CycleHistoryUpHotkey, "CycleHistoryUpHotkey", () => CycleHistoryUpHotkey = ""));
473-
if (!string.IsNullOrEmpty(CycleHistoryDownHotkey))
474-
list.Add(new(CycleHistoryDownHotkey, "CycleHistoryDownHotkey", () => CycleHistoryDownHotkey = ""));
475-
476-
// Custom Query Hotkeys
477-
foreach (var customPluginHotkey in CustomPluginHotkeys)
478-
{
479-
if (!string.IsNullOrEmpty(customPluginHotkey.Hotkey))
480-
list.Add(new(customPluginHotkey.Hotkey, "customQueryHotkey", () => customPluginHotkey.Hotkey = ""));
481-
}
482-
483-
return list;
484-
}
485-
}
486-
487-
private List<RegisteredHotkeyData> FixedHotkeys()
488-
{
489-
return new List<RegisteredHotkeyData>
490-
{
491-
new("Up", "HotkeyLeftRightDesc"),
492-
new("Down", "HotkeyLeftRightDesc"),
493-
new("Left", "HotkeyUpDownDesc"),
494-
new("Right", "HotkeyUpDownDesc"),
495-
new("Escape", "HotkeyESCDesc"),
496-
new("F5", "ReloadPluginHotkey"),
497-
new("Alt+Home", "HotkeySelectFirstResult"),
498-
new("Alt+End", "HotkeySelectLastResult"),
499-
new("Ctrl+R", "HotkeyRequery"),
500-
new("Ctrl+OemCloseBrackets", "QuickWidthHotkey"),
501-
new("Ctrl+OemOpenBrackets", "QuickWidthHotkey"),
502-
new("Ctrl+OemPlus", "QuickHeightHotkey"),
503-
new("Ctrl+OemMinus", "QuickHeightHotkey"),
504-
new("Ctrl+Shift+Enter", "HotkeyCtrlShiftEnterDesc"),
505-
new("Shift+Enter", "OpenContextMenuHotkey"),
506-
new("Enter", "HotkeyRunDesc"),
507-
new("Ctrl+Enter", "OpenContainFolderHotkey"),
508-
new("Alt+Enter", "HotkeyOpenResult"),
509-
new("Ctrl+F12", "ToggleGameModeHotkey"),
510-
new("Ctrl+Shift+C", "CopyFilePathHotkey"),
511-
512-
new($"{OpenResultModifiers}+D1", "HotkeyOpenResultN", 1),
513-
new($"{OpenResultModifiers}+D2", "HotkeyOpenResultN", 2),
514-
new($"{OpenResultModifiers}+D3", "HotkeyOpenResultN", 3),
515-
new($"{OpenResultModifiers}+D4", "HotkeyOpenResultN", 4),
516-
new($"{OpenResultModifiers}+D5", "HotkeyOpenResultN", 5),
517-
new($"{OpenResultModifiers}+D6", "HotkeyOpenResultN", 6),
518-
new($"{OpenResultModifiers}+D7", "HotkeyOpenResultN", 7),
519-
new($"{OpenResultModifiers}+D8", "HotkeyOpenResultN", 8),
520-
new($"{OpenResultModifiers}+D9", "HotkeyOpenResultN", 9),
521-
new($"{OpenResultModifiers}+D0", "HotkeyOpenResultN", 10)
522-
};
523-
}
438+
public ObservableCollection<RegisteredHotkeyData> RegisteredHotkeys { get; } = new();
524439
}
525440

526441
public enum LastQueryMode

0 commit comments

Comments
 (0)