mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Don't close HotkeyControl2Dialog after pressing Reset or Delete in it
This commit is contained in:
parent
9762afdd00
commit
20fa61dc5d
2 changed files with 18 additions and 28 deletions
|
|
@ -122,7 +122,7 @@ namespace Flow.Launcher
|
|||
HotKeyMapper.RemoveHotkey(Hotkey);
|
||||
}
|
||||
|
||||
var dialog = new HotkeyControl2Dialog(Hotkey, WindowTitle);
|
||||
var dialog = new HotkeyControl2Dialog(Hotkey, DefaultHotkey, WindowTitle);
|
||||
await dialog.ShowAsync();
|
||||
switch (dialog.ResultType)
|
||||
{
|
||||
|
|
@ -131,27 +131,12 @@ namespace Flow.Launcher
|
|||
case HotkeyControl2Dialog.EResultType.Save:
|
||||
SetHotkey(dialog.ResultValue);
|
||||
break;
|
||||
case HotkeyControl2Dialog.EResultType.Reset:
|
||||
ResetToDefault();
|
||||
break;
|
||||
case HotkeyControl2Dialog.EResultType.Delete:
|
||||
Delete();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetToDefault()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Hotkey))
|
||||
HotKeyMapper.RemoveHotkey(Hotkey);
|
||||
Hotkey = DefaultHotkey;
|
||||
CurrentHotkey = new HotkeyModel(Hotkey);
|
||||
|
||||
SetKeysToDisplay(CurrentHotkey);
|
||||
|
||||
SetHotkey(CurrentHotkey);
|
||||
}
|
||||
|
||||
|
||||
private void SetHotkey(HotkeyModel keyModel, bool triggerValidate = true)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace Flow.Launcher;
|
|||
|
||||
public partial class HotkeyControl2Dialog : ContentDialog
|
||||
{
|
||||
public string Hotkey { get; set; } = string.Empty;
|
||||
private string DefaultHotkey { get; }
|
||||
public string WindowTitle { get; }
|
||||
public HotkeyModel CurrentHotkey { get; private set; }
|
||||
public ObservableCollection<string> KeysToDisplay { get; } = new();
|
||||
|
|
@ -20,47 +20,52 @@ public partial class HotkeyControl2Dialog : ContentDialog
|
|||
{
|
||||
Cancel,
|
||||
Save,
|
||||
Reset,
|
||||
Delete
|
||||
}
|
||||
|
||||
public EResultType ResultType { get; private set; } = EResultType.Cancel;
|
||||
public string ResultValue { get; private set; } = string.Empty;
|
||||
public string EmptyHotkey => InternationalizationManager.Instance.GetTranslation("none");
|
||||
public static string EmptyHotkey => InternationalizationManager.Instance.GetTranslation("none");
|
||||
|
||||
public HotkeyControl2Dialog(string hotkey, string windowTitle = "")
|
||||
public HotkeyControl2Dialog(string hotkey, string defaultHotkey, string windowTitle = "")
|
||||
{
|
||||
WindowTitle = windowTitle switch
|
||||
{
|
||||
"" or null => InternationalizationManager.Instance.GetTranslation("hotkeyRegTitle"),
|
||||
_ => windowTitle
|
||||
};
|
||||
DefaultHotkey = defaultHotkey;
|
||||
CurrentHotkey = new HotkeyModel(hotkey);
|
||||
SetKeysToDisplay(CurrentHotkey);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void Reset(object sender, RoutedEventArgs routedEventArgs)
|
||||
private void Reset(object sender, RoutedEventArgs routedEventArgs)
|
||||
{
|
||||
ResultType = EResultType.Reset;
|
||||
Hide();
|
||||
SetKeysToDisplay(new HotkeyModel(DefaultHotkey));
|
||||
}
|
||||
|
||||
public void Delete(object sender, RoutedEventArgs routedEventArgs)
|
||||
private void Delete(object sender, RoutedEventArgs routedEventArgs)
|
||||
{
|
||||
ResultType = EResultType.Delete;
|
||||
Hide();
|
||||
KeysToDisplay.Clear();
|
||||
KeysToDisplay.Add(EmptyHotkey);
|
||||
}
|
||||
|
||||
public void Cancel(object sender, RoutedEventArgs routedEventArgs)
|
||||
private void Cancel(object sender, RoutedEventArgs routedEventArgs)
|
||||
{
|
||||
ResultType = EResultType.Cancel;
|
||||
Hide();
|
||||
}
|
||||
|
||||
public void Save(object sender, RoutedEventArgs routedEventArgs)
|
||||
private void Save(object sender, RoutedEventArgs routedEventArgs)
|
||||
{
|
||||
if (KeysToDisplay.Count == 1 && KeysToDisplay[0] == EmptyHotkey)
|
||||
{
|
||||
ResultType = EResultType.Delete;
|
||||
Hide();
|
||||
return;
|
||||
}
|
||||
ResultType = EResultType.Save;
|
||||
ResultValue = string.Join("+", KeysToDisplay);
|
||||
Hide();
|
||||
|
|
|
|||
Loading…
Reference in a new issue