diff --git a/Flow.Launcher/CustomQueryHotkeySetting.xaml b/Flow.Launcher/CustomQueryHotkeySetting.xaml
index 124115ffe..db6269f16 100644
--- a/Flow.Launcher/CustomQueryHotkeySetting.xaml
+++ b/Flow.Launcher/CustomQueryHotkeySetting.xaml
@@ -62,92 +62,84 @@
-
-
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
\ No newline at end of file
+
diff --git a/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs b/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs
index c84a2f9d9..cf10c5dca 100644
--- a/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs
+++ b/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs
@@ -31,18 +31,14 @@ namespace Flow.Launcher
private void btnAdd_OnClick(object sender, RoutedEventArgs e)
{
+ if (HotkeyControl.IsEmpty)
+ {
+ MessageBox.Show("Hotkey cannot be empty.");
+ return;
+ }
if (!update)
{
- if (!HotkeyControl.CurrentHotkeyAvailable)
- {
- MessageBox.Show(InternationalizationManager.Instance.GetTranslation("hotkeyIsNotUnavailable"));
- return;
- }
-
- if (_settings.CustomPluginHotkeys == null)
- {
- _settings.CustomPluginHotkeys = new ObservableCollection();
- }
+ _settings.CustomPluginHotkeys ??= new ObservableCollection();
var pluginHotkey = new CustomPluginHotkey
{
@@ -54,13 +50,6 @@ namespace Flow.Launcher
}
else
{
- if (updateCustomHotkey.Hotkey != HotkeyControl.CurrentHotkey.ToString() &&
- !HotkeyControl.CurrentHotkeyAvailable)
- {
- MessageBox.Show(InternationalizationManager.Instance.GetTranslation("hotkeyIsNotUnavailable"));
- return;
- }
-
var oldHotkey = updateCustomHotkey.Hotkey;
updateCustomHotkey.ActionKeyword = tbAction.Text;
updateCustomHotkey.Hotkey = HotkeyControl.CurrentHotkey.ToString();
@@ -105,12 +94,10 @@ namespace Flow.Launcher
private void window_MouseDown(object sender, MouseButtonEventArgs e) /* for close hotkey popup */
{
- TextBox textBox = Keyboard.FocusedElement as TextBox;
- if (textBox != null)
- {
- TraversalRequest tRequest = new TraversalRequest(FocusNavigationDirection.Next);
- textBox.MoveFocus(tRequest);
- }
+ if (Keyboard.FocusedElement is not TextBox textBox) return;
+
+ TraversalRequest tRequest = new TraversalRequest(FocusNavigationDirection.Next);
+ textBox.MoveFocus(tRequest);
}
}
}
diff --git a/Flow.Launcher/HotkeyControl.xaml.cs b/Flow.Launcher/HotkeyControl.xaml.cs
index de708e24b..bece67de2 100644
--- a/Flow.Launcher/HotkeyControl.xaml.cs
+++ b/Flow.Launcher/HotkeyControl.xaml.cs
@@ -78,6 +78,7 @@ namespace Flow.Launcher
InitializeComponent();
HotkeyList.ItemsSource = KeysToDisplay;
+ SetKeysToDisplay(CurrentHotkey);
}
/*------------------ New Logic Structure Part------------------------*/
@@ -157,6 +158,7 @@ namespace Flow.Launcher
public ObservableCollection KeysToDisplay { get; set; } = new ObservableCollection();
+ public bool IsEmpty => KeysToDisplay.Count == 0 || (KeysToDisplay.Count == 1 && KeysToDisplay[0] == EmptyHotkey);
public HotkeyModel CurrentHotkey { get; private set; } = new(false, false, false, false, Key.None);