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
public static void OnToggleHotkey(object sender, HotkeyEventArgs args)
public static void ToggleHotkey()
{
_ = Task.Run(async () =>
{

View file

@ -23,13 +23,11 @@ internal static class HotKeyMapper
_settings = Ioc.Default.GetService<Settings>();
ChefKeysManager.RegisterHotkey(_settings.Hotkey, ToggleHotkey);
ChefKeysManager.Start();
// TODO: Resolve this
if (_settings.EnableDialogJump)
{
SetHotkey(_settings.DialogJumpHotkey, DialogJump.OnToggleHotkey);
ChefKeysManager.RegisterHotkey(_settings.DialogJumpHotkey, DialogJump.ToggleHotkey);
}
ChefKeysManager.Start();
LoadCustomPluginHotkey();
}
@ -52,8 +50,8 @@ internal static class HotKeyMapper
string.Format("|HotkeyMapper.SetHotkey|Error registering hotkey {2}: {0} \nStackTrace:{1}",
e.Message,
e.StackTrace,
hotkeyStr));
string errorMsg = string.Format(App.API.GetTranslation("registerHotkeyFailed"), hotkeyStr);
hotkey));
string errorMsg = string.Format(App.API.GetTranslation("registerHotkeyFailed"), hotkey);
string errorMsgTitle = App.API.GetTranslation("MessageBoxTitle");
App.API.ShowMsgBox(errorMsg, errorMsgTitle);
}
@ -69,21 +67,16 @@ internal static class HotKeyMapper
catch (Exception e)
{
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.StackTrace));
string errorMsg = string.Format(App.API.GetTranslation("unregisterHotkeyFailed"), hotkeyStr);
e.StackTrace,
hotkey));
string errorMsg = string.Format(App.API.GetTranslation("unregisterHotkeyFailed"), hotkey);
string errorMsgTitle = App.API.GetTranslation("MessageBoxTitle");
App.API.ShowMsgBox(errorMsg, errorMsgTitle);
}
}
private static void RemoveWithChefKeys(string hotkeyStr)
{
ChefKeysManager.UnregisterHotkey(hotkeyStr);
ChefKeysManager.Stop();
}
internal static void LoadCustomPluginHotkey()
{
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.Threading.Tasks;
using System.Windows;
@ -273,7 +273,7 @@ namespace Flow.Launcher
private async Task OpenHotkeyDialogAsync()
{
hotkeyControlDialog = new HotkeyControlDialog(Hotkey, DefaultHotkey, HotkeySettings, IsWPFHotkeyControl, WindowTitle);
hotkeyControlDialog = new HotkeyControlDialog(Hotkey, DefaultHotkey, IsWPFHotkeyControl, WindowTitle);
await hotkeyControlDialog.ShowAsync();
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
HotkeyToUpdate = new HotkeyModel(hotkey);
_hotkeySettings = hotkeySettings;
SetKeysToDisplay(CurrentHotkey);
clearKeysOnFirstType = true;

View file

@ -158,11 +158,12 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
DialogJump.SetupDialogJump(value);
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
{
HotKeyMapper.RemoveHotkey(Settings.DialogJumpHotkey);
HotKeyMapper.UnregisterHotkey(Settings.DialogJumpHotkey);
}
}
}

View file

@ -40,7 +40,7 @@ public partial class SettingsPaneHotkeyViewModel : BaseModel
{
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);
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
}

View file

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