Resolve conflicts

This commit is contained in:
Jack251970 2025-09-19 18:59:50 +08:00
parent d920b0ba39
commit 769c99b9f9
7 changed files with 18 additions and 26 deletions

View file

@ -455,7 +455,7 @@ namespace Flow.Launcher.Infrastructure.DialogJump
#region Hotkey #region Hotkey
public static void OnToggleHotkey(object sender, HotkeyEventArgs args) public static void ToggleHotkey()
{ {
_ = Task.Run(async () => _ = Task.Run(async () =>
{ {

View file

@ -23,13 +23,11 @@ internal static class HotKeyMapper
_settings = Ioc.Default.GetService<Settings>(); _settings = Ioc.Default.GetService<Settings>();
ChefKeysManager.RegisterHotkey(_settings.Hotkey, ToggleHotkey); ChefKeysManager.RegisterHotkey(_settings.Hotkey, ToggleHotkey);
ChefKeysManager.Start();
// TODO: Resolve this
if (_settings.EnableDialogJump) if (_settings.EnableDialogJump)
{ {
SetHotkey(_settings.DialogJumpHotkey, DialogJump.OnToggleHotkey); ChefKeysManager.RegisterHotkey(_settings.DialogJumpHotkey, DialogJump.ToggleHotkey);
} }
ChefKeysManager.Start();
LoadCustomPluginHotkey(); LoadCustomPluginHotkey();
} }
@ -52,8 +50,8 @@ internal static class HotKeyMapper
string.Format("|HotkeyMapper.SetHotkey|Error registering hotkey {2}: {0} \nStackTrace:{1}", string.Format("|HotkeyMapper.SetHotkey|Error registering hotkey {2}: {0} \nStackTrace:{1}",
e.Message, e.Message,
e.StackTrace, e.StackTrace,
hotkeyStr)); hotkey));
string errorMsg = string.Format(App.API.GetTranslation("registerHotkeyFailed"), hotkeyStr); string errorMsg = string.Format(App.API.GetTranslation("registerHotkeyFailed"), hotkey);
string errorMsgTitle = App.API.GetTranslation("MessageBoxTitle"); string errorMsgTitle = App.API.GetTranslation("MessageBoxTitle");
App.API.ShowMsgBox(errorMsg, errorMsgTitle); App.API.ShowMsgBox(errorMsg, errorMsgTitle);
} }
@ -69,21 +67,16 @@ internal static class HotKeyMapper
catch (Exception e) catch (Exception e)
{ {
App.API.LogError(ClassName, App.API.LogError(ClassName,
string.Format("|HotkeyMapper.RemoveHotkey|Error removing hotkey: {0} \nStackTrace:{1}", string.Format("|HotkeyMapper.RemoveHotkey|Error removing hotkey {2}: {0} \nStackTrace:{1}",
e.Message, e.Message,
e.StackTrace)); e.StackTrace,
string errorMsg = string.Format(App.API.GetTranslation("unregisterHotkeyFailed"), hotkeyStr); hotkey));
string errorMsg = string.Format(App.API.GetTranslation("unregisterHotkeyFailed"), hotkey);
string errorMsgTitle = App.API.GetTranslation("MessageBoxTitle"); string errorMsgTitle = App.API.GetTranslation("MessageBoxTitle");
App.API.ShowMsgBox(errorMsg, errorMsgTitle); App.API.ShowMsgBox(errorMsg, errorMsgTitle);
} }
} }
private static void RemoveWithChefKeys(string hotkeyStr)
{
ChefKeysManager.UnregisterHotkey(hotkeyStr);
ChefKeysManager.Stop();
}
internal static void LoadCustomPluginHotkey() internal static void LoadCustomPluginHotkey()
{ {
foreach (CustomPluginHotkey hotkey in _settings.CustomPluginHotkeys) foreach (CustomPluginHotkey hotkey in _settings.CustomPluginHotkeys)

View file

@ -1,4 +1,4 @@
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Globalization; using System.Globalization;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
@ -273,7 +273,7 @@ namespace Flow.Launcher
private async Task OpenHotkeyDialogAsync() private async Task OpenHotkeyDialogAsync()
{ {
hotkeyControlDialog = new HotkeyControlDialog(Hotkey, DefaultHotkey, HotkeySettings, IsWPFHotkeyControl, WindowTitle); hotkeyControlDialog = new HotkeyControlDialog(Hotkey, DefaultHotkey, IsWPFHotkeyControl, WindowTitle);
await hotkeyControlDialog.ShowAsync(); await hotkeyControlDialog.ShowAsync();
switch (hotkeyControlDialog.ResultType) switch (hotkeyControlDialog.ResultType)
{ {

View file

@ -64,8 +64,6 @@ public partial class HotkeyControlDialog : ContentDialog
// This is a requirement to be set with current hotkey for the WPF hotkey control when saving without any new changes // This is a requirement to be set with current hotkey for the WPF hotkey control when saving without any new changes
HotkeyToUpdate = new HotkeyModel(hotkey); HotkeyToUpdate = new HotkeyModel(hotkey);
_hotkeySettings = hotkeySettings;
SetKeysToDisplay(CurrentHotkey); SetKeysToDisplay(CurrentHotkey);
clearKeysOnFirstType = true; clearKeysOnFirstType = true;

View file

@ -158,11 +158,12 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
DialogJump.SetupDialogJump(value); DialogJump.SetupDialogJump(value);
if (Settings.EnableDialogJump) if (Settings.EnableDialogJump)
{ {
HotKeyMapper.SetHotkey(new(Settings.DialogJumpHotkey), DialogJump.OnToggleHotkey); // TODO: How can we parse the previousHotkey parameter here?
HotKeyMapper.RegisterHotkey(Settings.DialogJumpHotkey, string.Empty, DialogJump.ToggleHotkey);
} }
else else
{ {
HotKeyMapper.RemoveHotkey(Settings.DialogJumpHotkey); HotKeyMapper.UnregisterHotkey(Settings.DialogJumpHotkey);
} }
} }
} }

View file

@ -40,7 +40,7 @@ public partial class SettingsPaneHotkeyViewModel : BaseModel
{ {
if (Settings.EnableDialogJump) if (Settings.EnableDialogJump)
{ {
HotKeyMapper.SetHotkey(hotkey, DialogJump.OnToggleHotkey); HotKeyMapper.RegisterHotkey(hotkey.HotkeyRaw, hotkey.PreviousHotkey, DialogJump.ToggleHotkey);
} }
} }
@ -92,7 +92,7 @@ public partial class SettingsPaneHotkeyViewModel : BaseModel
var index = Settings.CustomPluginHotkeys.IndexOf(settingItem); var index = Settings.CustomPluginHotkeys.IndexOf(settingItem);
Settings.CustomPluginHotkeys[index] = new CustomPluginHotkey(window.Hotkey, window.ActionKeyword); Settings.CustomPluginHotkeys[index] = new CustomPluginHotkey(window.Hotkey, window.ActionKeyword);
HotKeyMapper.RemoveHotkey(settingItem.Hotkey); // remove origin hotkey HotKeyMapper.UnregisterHotkey(settingItem.Hotkey); // remove origin hotkey
HotKeyMapper.SetCustomQueryHotkey(Settings.CustomPluginHotkeys[index]); // set new hotkey HotKeyMapper.SetCustomQueryHotkey(Settings.CustomPluginHotkeys[index]); // set new hotkey
} }

View file

@ -34,10 +34,10 @@
<flowlauncher:HotkeyControl <flowlauncher:HotkeyControl
ChangeHotkey="{Binding SetTogglingHotkeyCommand}" ChangeHotkey="{Binding SetTogglingHotkeyCommand}"
DefaultHotkey="LeftAlt+Space" DefaultHotkey="LeftAlt+Space"
IsWPFHotkeyControl="False"
Type="Hotkey" Type="Hotkey"
ValidateKeyGesture="True" ValidateKeyGesture="True"
WindowTitle="{DynamicResource flowlauncherHotkey}" WindowTitle="{DynamicResource flowlauncherHotkey}" />
IsWPFHotkeyControl="False" />
</cc:Card> </cc:Card>
<cc:Card <cc:Card