Skip to content

Commit 25bf44d

Browse files
committed
do not allow add on long key press
1 parent 62dccbf commit 25bf44d

File tree

3 files changed

+53
-43
lines changed

3 files changed

+53
-43
lines changed

Flow.Launcher.Infrastructure/Hotkey/HotkeyModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ internal void AddString(string key)
9292
HotkeyRaw = string.IsNullOrEmpty(HotkeyRaw) ? key : HotkeyRaw + "+" + key;
9393
}
9494

95+
internal string GetLastKeySet() => !string.IsNullOrEmpty(HotkeyRaw) ? HotkeyRaw.Split('+').Last() : string.Empty;
96+
9597
internal bool MaxKeysReached() => DisplayKeysRaw().Count() == 4;
9698

9799
internal void Clear()

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -302,18 +302,18 @@ public List<RegisteredHotkeyData> RegisteredHotkeys
302302
list.Add(new(SelectPrevItemHotkey, "SelectPrevItemHotkey", () => SelectPrevItemHotkey = ""));
303303
if (!string.IsNullOrEmpty(SelectPrevItemHotkey2))
304304
list.Add(new(SelectPrevItemHotkey2, "SelectPrevItemHotkey", () => SelectPrevItemHotkey2 = ""));
305-
//if (!string.IsNullOrEmpty(SettingWindowHotkey))
306-
// list.Add(new(SettingWindowHotkey, "SettingWindowHotkey", () => SettingWindowHotkey = ""));
307-
//if (!string.IsNullOrEmpty(OpenContextMenuHotkey))
308-
// list.Add(new(OpenContextMenuHotkey, "OpenContextMenuHotkey", () => OpenContextMenuHotkey = ""));
309-
//if (!string.IsNullOrEmpty(SelectNextPageHotkey))
310-
// list.Add(new(SelectNextPageHotkey, "SelectNextPageHotkey", () => SelectNextPageHotkey = ""));
311-
//if (!string.IsNullOrEmpty(SelectPrevPageHotkey))
312-
// list.Add(new(SelectPrevPageHotkey, "SelectPrevPageHotkey", () => SelectPrevPageHotkey = ""));
313-
//if (!string.IsNullOrEmpty(CycleHistoryUpHotkey))
314-
// list.Add(new(CycleHistoryUpHotkey, "CycleHistoryUpHotkey", () => CycleHistoryUpHotkey = ""));
315-
//if (!string.IsNullOrEmpty(CycleHistoryDownHotkey))
316-
// list.Add(new(CycleHistoryDownHotkey, "CycleHistoryDownHotkey", () => CycleHistoryDownHotkey = ""));
305+
if (!string.IsNullOrEmpty(SettingWindowHotkey))
306+
list.Add(new(SettingWindowHotkey, "SettingWindowHotkey", () => SettingWindowHotkey = ""));
307+
if (!string.IsNullOrEmpty(OpenContextMenuHotkey))
308+
list.Add(new(OpenContextMenuHotkey, "OpenContextMenuHotkey", () => OpenContextMenuHotkey = ""));
309+
if (!string.IsNullOrEmpty(SelectNextPageHotkey))
310+
list.Add(new(SelectNextPageHotkey, "SelectNextPageHotkey", () => SelectNextPageHotkey = ""));
311+
if (!string.IsNullOrEmpty(SelectPrevPageHotkey))
312+
list.Add(new(SelectPrevPageHotkey, "SelectPrevPageHotkey", () => SelectPrevPageHotkey = ""));
313+
if (!string.IsNullOrEmpty(CycleHistoryUpHotkey))
314+
list.Add(new(CycleHistoryUpHotkey, "CycleHistoryUpHotkey", () => CycleHistoryUpHotkey = ""));
315+
if (!string.IsNullOrEmpty(CycleHistoryDownHotkey))
316+
list.Add(new(CycleHistoryDownHotkey, "CycleHistoryDownHotkey", () => CycleHistoryDownHotkey = ""));
317317

318318
// Custom Query Hotkeys
319319
foreach (var customPluginHotkey in CustomPluginHotkeys)
@@ -334,34 +334,34 @@ private List<RegisteredHotkeyData> FixedHotkeys()
334334
new("Down", "HotkeyLeftRightDesc"),
335335
new("Left", "HotkeyUpDownDesc"),
336336
new("Right", "HotkeyUpDownDesc"),
337-
//new("Escape", "HotkeyESCDesc"),
338-
//new("F5", "ReloadPluginHotkey"),
339-
//new("Alt+Home", "HotkeySelectFirstResult"),
340-
//new("Alt+End", "HotkeySelectLastResult"),
341-
//new("Ctrl+R", "HotkeyRequery"),
342-
//new("Ctrl+H", "ToggleHistoryHotkey"),
343-
//new("Ctrl+OemCloseBrackets", "QuickWidthHotkey"),
344-
//new("Ctrl+OemOpenBrackets", "QuickWidthHotkey"),
345-
//new("Ctrl+OemPlus", "QuickHeightHotkey"),
346-
//new("Ctrl+OemMinus", "QuickHeightHotkey"),
347-
//new("Ctrl+Shift+Enter", "HotkeyCtrlShiftEnterDesc"),
348-
//new("Shift+Enter", "OpenContextMenuHotkey"),
349-
//new("Enter", "HotkeyRunDesc"),
350-
//new("Ctrl+Enter", "OpenContainFolderHotkey"),
351-
//new("Alt+Enter", "HotkeyOpenResult"),
352-
//new("Ctrl+F12", "ToggleGameModeHotkey"),
353-
//new("Ctrl+Shift+C", "CopyFilePathHotkey"),
354-
355-
//new($"{OpenResultModifiers}+D1", "HotkeyOpenResultN", 1),
356-
//new($"{OpenResultModifiers}+D2", "HotkeyOpenResultN", 2),
357-
//new($"{OpenResultModifiers}+D3", "HotkeyOpenResultN", 3),
358-
//new($"{OpenResultModifiers}+D4", "HotkeyOpenResultN", 4),
359-
//new($"{OpenResultModifiers}+D5", "HotkeyOpenResultN", 5),
360-
//new($"{OpenResultModifiers}+D6", "HotkeyOpenResultN", 6),
361-
//new($"{OpenResultModifiers}+D7", "HotkeyOpenResultN", 7),
362-
//new($"{OpenResultModifiers}+D8", "HotkeyOpenResultN", 8),
363-
//new($"{OpenResultModifiers}+D9", "HotkeyOpenResultN", 9),
364-
//new($"{OpenResultModifiers}+D0", "HotkeyOpenResultN", 10)
337+
new("Escape", "HotkeyESCDesc"),
338+
new("F5", "ReloadPluginHotkey"),
339+
new("Alt+Home", "HotkeySelectFirstResult"),
340+
new("Alt+End", "HotkeySelectLastResult"),
341+
new("Ctrl+R", "HotkeyRequery"),
342+
new("Ctrl+H", "ToggleHistoryHotkey"),
343+
new("Ctrl+OemCloseBrackets", "QuickWidthHotkey"),
344+
new("Ctrl+OemOpenBrackets", "QuickWidthHotkey"),
345+
new("Ctrl+OemPlus", "QuickHeightHotkey"),
346+
new("Ctrl+OemMinus", "QuickHeightHotkey"),
347+
new("Ctrl+Shift+Enter", "HotkeyCtrlShiftEnterDesc"),
348+
new("Shift+Enter", "OpenContextMenuHotkey"),
349+
new("Enter", "HotkeyRunDesc"),
350+
new("Ctrl+Enter", "OpenContainFolderHotkey"),
351+
new("Alt+Enter", "HotkeyOpenResult"),
352+
new("Ctrl+F12", "ToggleGameModeHotkey"),
353+
new("Ctrl+Shift+C", "CopyFilePathHotkey"),
354+
355+
new($"{OpenResultModifiers}+D1", "HotkeyOpenResultN", 1),
356+
new($"{OpenResultModifiers}+D2", "HotkeyOpenResultN", 2),
357+
new($"{OpenResultModifiers}+D3", "HotkeyOpenResultN", 3),
358+
new($"{OpenResultModifiers}+D4", "HotkeyOpenResultN", 4),
359+
new($"{OpenResultModifiers}+D5", "HotkeyOpenResultN", 5),
360+
new($"{OpenResultModifiers}+D6", "HotkeyOpenResultN", 6),
361+
new($"{OpenResultModifiers}+D7", "HotkeyOpenResultN", 7),
362+
new($"{OpenResultModifiers}+D8", "HotkeyOpenResultN", 8),
363+
new($"{OpenResultModifiers}+D9", "HotkeyOpenResultN", 9),
364+
new($"{OpenResultModifiers}+D0", "HotkeyOpenResultN", 10)
365365
};
366366
}
367367
}

Flow.Launcher/HotkeyControlDialog.xaml.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,19 +134,27 @@ private void OnPreviewKeyDown(object sender, KeyEventArgs e)
134134
if (ChefKeysManager.StartMenuBlocked && key.ToString() == ChefKeysManager.StartMenuSimulatedKey)
135135
return;
136136

137+
AddKey(key);
138+
139+
SetKeysToDisplay(HotkeyToUpdate);
140+
}
141+
142+
private void AddKey(Key key)
143+
{
144+
if (HotkeyToUpdate.GetLastKeySet() == key.ToString())
145+
return;
146+
137147
if (!isWPFHotkeyControl)
138148
{
139149
if (HotkeyToUpdate.MaxKeysReached())
140150
return;
141-
151+
142152
HotkeyToUpdate.AddString(key.ToString());
143153
}
144154
else
145155
{
146156
HotkeyToUpdate.SetHotkeyFromWPFControl(GlobalHotkey.CheckModifiers(), key);
147157
}
148-
149-
SetKeysToDisplay(HotkeyToUpdate);
150158
}
151159

152160
private void SetKeysToDisplay(HotkeyModel? hotkey)

0 commit comments

Comments
 (0)