mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
HotkeyControl: add click handlers, add default hotkey
This commit is contained in:
parent
7458e10174
commit
78a6b27aa1
3 changed files with 36 additions and 7 deletions
|
|
@ -39,8 +39,7 @@
|
|||
</Popup>
|
||||
|
||||
<ToggleButton
|
||||
x:Name="HotkeyBtn"
|
||||
Click="OnButtonClicked"
|
||||
IsChecked="{Binding IsEditingHotkey, Mode=TwoWay, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}"
|
||||
FontSize="13"
|
||||
FontWeight="Bold"
|
||||
Foreground="{DynamicResource Color01B}">
|
||||
|
|
@ -60,9 +59,9 @@
|
|||
BorderThickness="1"
|
||||
CornerRadius="5">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Button Content="Reset" />
|
||||
<Button Content="Delete" />
|
||||
<Button Content="Stop Rec" />
|
||||
<Button Content="Reset" Click="OnResetToDefaultClicked" />
|
||||
<Button Content="Delete" Click="OnDeleteClicked" />
|
||||
<Button Content="Stop Rec" Click="OnStopRecordingClicked" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
|
|
|
|||
|
|
@ -36,8 +36,19 @@ namespace Flow.Launcher
|
|||
}
|
||||
}
|
||||
|
||||
public string DefaultHotkey { get; set; }
|
||||
|
||||
public string[] KeysToDisplay => Hotkey.Split(" + ");
|
||||
|
||||
private bool _isEditingHotkey = false;
|
||||
public bool IsEditingHotkey {
|
||||
get => _isEditingHotkey;
|
||||
set {
|
||||
_isEditingHotkey = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
#nullable enable
|
||||
public EventHandler<HotkeyEventArgs>? Action { get; set; }
|
||||
#nullable restore
|
||||
|
|
@ -202,9 +213,26 @@ namespace Flow.Launcher
|
|||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
private void OnButtonClicked(object sender, RoutedEventArgs e)
|
||||
private void OnStopRecordingClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// TODO
|
||||
IsEditingHotkey = false;
|
||||
}
|
||||
|
||||
private void OnResetToDefaultClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
IsEditingHotkey = false;
|
||||
if (!string.IsNullOrEmpty(Hotkey))
|
||||
HotKeyMapper.RemoveHotkey(Hotkey);
|
||||
Hotkey = DefaultHotkey;
|
||||
HotKeyMapper.SetHotkey(new HotkeyModel(Hotkey), Action);
|
||||
}
|
||||
|
||||
private void OnDeleteClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
IsEditingHotkey = false;
|
||||
if (!string.IsNullOrEmpty(Hotkey))
|
||||
HotKeyMapper.RemoveHotkey(Hotkey);
|
||||
Hotkey = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2649,6 +2649,7 @@
|
|||
Margin="0,0,16,0"
|
||||
HorizontalAlignment="Right"
|
||||
HorizontalContentAlignment="Right"
|
||||
DefaultHotkey="Alt + Space"
|
||||
Action="OnToggleHotkey"
|
||||
Hotkey="{Binding Settings.Hotkey}" />
|
||||
|
||||
|
|
@ -2673,6 +2674,7 @@
|
|||
Margin="0,0,16,0"
|
||||
HorizontalAlignment="Right"
|
||||
HorizontalContentAlignment="Right"
|
||||
DefaultHotkey="F1"
|
||||
Hotkey="{Binding Settings.PreviewHotkey}"
|
||||
ValidateKeyGesture="True" />
|
||||
<TextBlock Style="{StaticResource Glyph}">
|
||||
|
|
|
|||
Loading…
Reference in a new issue