Skip to content

Commit 979aa3d

Browse files
Support hotkey modifiers
1 parent 68ae8a1 commit 979aa3d

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

Flow.Launcher/MainWindow.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@
182182
Modifiers="Ctrl"/>
183183
<KeyBinding
184184
Key="{Binding TogglePreviewHotkey}"
185-
Command="{Binding TogglePreviewCommand}"/>
185+
Command="{Binding TogglePreviewCommand}"
186+
Modifiers="{Binding TogglePreviewModifiers}"/>
186187
</Window.InputBindings>
187188
<Grid>
188189
<Border MouseDown="OnMouseDown" Style="{DynamicResource WindowBorderStyle}">

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
using System.Collections.Specialized;
2424
using CommunityToolkit.Mvvm.Input;
2525
using System.Globalization;
26+
using System.Windows.Input;
2627

2728
namespace Flow.Launcher.ViewModel
2829
{
@@ -74,7 +75,7 @@ public MainViewModel(Settings settings)
7475
OnPropertyChanged(nameof(OpenResultCommandModifiers));
7576
break;
7677
case nameof(Settings.PreviewHotkey):
77-
OnPropertyChanged(nameof(TogglePreviewHotkey));
78+
UpdatePreviewHotkey();
7879
break;
7980
}
8081
};
@@ -114,6 +115,7 @@ public MainViewModel(Settings settings)
114115
RegisterViewUpdate();
115116
RegisterResultsUpdatedEvent();
116117
_ = RegisterClockAndDateUpdateAsync();
118+
UpdatePreviewHotkey();
117119
}
118120

119121
private void RegisterViewUpdate()
@@ -582,7 +584,9 @@ public double MainWindowWidth
582584

583585
public string OpenResultCommandModifiers => Settings.OpenResultModifiers;
584586

585-
public string TogglePreviewHotkey => Settings.PreviewHotkey; // TODO: is hotkey combo possible?
587+
public Key TogglePreviewHotkey { get; set; }
588+
589+
public ModifierKeys TogglePreviewModifiers { get; set; }
586590

587591
public string Image => Constant.QueryTextBoxIconImagePath;
588592

@@ -1014,6 +1018,14 @@ public bool ShouldIgnoreHotkeys()
10141018
return Settings.IgnoreHotkeysOnFullscreen && WindowsInteropHelper.IsWindowFullscreen() || GameModeStatus;
10151019
}
10161020

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+
10171029
#endregion
10181030

10191031
#region Public Methods

0 commit comments

Comments
 (0)