|
23 | 23 | using System.Collections.Specialized; |
24 | 24 | using CommunityToolkit.Mvvm.Input; |
25 | 25 | using System.Globalization; |
| 26 | +using System.Windows.Input; |
26 | 27 |
|
27 | 28 | namespace Flow.Launcher.ViewModel |
28 | 29 | { |
@@ -74,7 +75,7 @@ public MainViewModel(Settings settings) |
74 | 75 | OnPropertyChanged(nameof(OpenResultCommandModifiers)); |
75 | 76 | break; |
76 | 77 | case nameof(Settings.PreviewHotkey): |
77 | | - OnPropertyChanged(nameof(TogglePreviewHotkey)); |
| 78 | + UpdatePreviewHotkey(); |
78 | 79 | break; |
79 | 80 | } |
80 | 81 | }; |
@@ -114,6 +115,7 @@ public MainViewModel(Settings settings) |
114 | 115 | RegisterViewUpdate(); |
115 | 116 | RegisterResultsUpdatedEvent(); |
116 | 117 | _ = RegisterClockAndDateUpdateAsync(); |
| 118 | + UpdatePreviewHotkey(); |
117 | 119 | } |
118 | 120 |
|
119 | 121 | private void RegisterViewUpdate() |
@@ -582,7 +584,9 @@ public double MainWindowWidth |
582 | 584 |
|
583 | 585 | public string OpenResultCommandModifiers => Settings.OpenResultModifiers; |
584 | 586 |
|
585 | | - public string TogglePreviewHotkey => Settings.PreviewHotkey; // TODO: is hotkey combo possible? |
| 587 | + public Key TogglePreviewHotkey { get; set; } |
| 588 | + |
| 589 | + public ModifierKeys TogglePreviewModifiers { get; set; } = ModifierKeys.None; |
586 | 590 |
|
587 | 591 | public string Image => Constant.QueryTextBoxIconImagePath; |
588 | 592 |
|
@@ -1014,6 +1018,14 @@ public bool ShouldIgnoreHotkeys() |
1014 | 1018 | return Settings.IgnoreHotkeysOnFullscreen && WindowsInteropHelper.IsWindowFullscreen() || GameModeStatus; |
1015 | 1019 | } |
1016 | 1020 |
|
| 1021 | + private void UpdatePreviewHotkey() |
| 1022 | + { |
| 1023 | + var converter = new KeyGestureConverter(); |
| 1024 | + var key = (KeyGesture)converter.ConvertFromString(Settings.PreviewHotkey); |
| 1025 | + TogglePreviewHotkey = key.Key; |
| 1026 | + TogglePreviewModifiers = key.Modifiers; |
| 1027 | + } |
| 1028 | + |
1017 | 1029 | #endregion |
1018 | 1030 |
|
1019 | 1031 | #region Public Methods |
|
0 commit comments