Remove ChangeHotkey event & Remove deprecated functions

This commit is contained in:
Jack251970 2025-07-02 14:02:50 +08:00
parent 2cf6bfb725
commit 730625c6db
6 changed files with 5 additions and 82 deletions

View file

@ -246,20 +246,6 @@ internal static class HotKeyMapper
#endregion
// TODO: Deprecated
internal static void OnToggleHotkey(object sender, HotkeyEventArgs args)
{
if (!_mainViewModel.ShouldIgnoreHotkeys())
_mainViewModel.ToggleFlowLauncher();
}
// TODO: Deprecated
private static void OnToggleHotkeyWithChefKeys()
{
if (!_mainViewModel.ShouldIgnoreHotkeys())
_mainViewModel.ToggleFlowLauncher();
}
// TODO: Deprecated
private static void SetHotkey(string hotkeyStr, EventHandler<HotkeyEventArgs> action)
{
@ -268,27 +254,7 @@ internal static class HotKeyMapper
}
// TODO: Deprecated
private static void SetWithChefKeys(string hotkeyStr)
{
try
{
ChefKeysManager.RegisterHotkey(hotkeyStr, hotkeyStr, OnToggleHotkeyWithChefKeys);
ChefKeysManager.Start();
}
catch (Exception e)
{
App.API.LogError(ClassName,
string.Format("Error registering hotkey: {0} \nStackTrace:{1}",
e.Message,
e.StackTrace));
string errorMsg = string.Format(App.API.GetTranslation("registerHotkeyFailed"), hotkeyStr);
string errorMsgTitle = App.API.GetTranslation("MessageBoxTitle");
App.API.ShowMsgBox(errorMsg, errorMsgTitle);
}
}
// TODO: Deprecated
internal static void SetHotkey(HotkeyModel hotkey, EventHandler<HotkeyEventArgs> action)
private static void SetHotkey(HotkeyModel hotkey, EventHandler<HotkeyEventArgs> action)
{
if (hotkey.IsEmpty)
{
@ -298,12 +264,6 @@ internal static class HotKeyMapper
string hotkeyStr = hotkey.ToString();
try
{
if (hotkeyStr == "LWin" || hotkeyStr == "RWin")
{
SetWithChefKeys(hotkeyStr);
return;
}
HotkeyManager.Current.AddOrReplace(hotkeyStr, hotkey.CharKey, hotkey.ModifierKeys, action);
}
catch (Exception e)
@ -324,12 +284,6 @@ internal static class HotKeyMapper
{
try
{
if (hotkeyStr == "LWin" || hotkeyStr == "RWin")
{
RemoveWithChefKeys(hotkeyStr);
return;
}
if (!string.IsNullOrEmpty(hotkeyStr))
HotkeyManager.Current.Remove(hotkeyStr);
}
@ -345,13 +299,6 @@ internal static class HotKeyMapper
}
}
// TODO: Deprecated
private static void RemoveWithChefKeys(string hotkeyStr)
{
ChefKeysManager.UnregisterHotkey(hotkeyStr);
ChefKeysManager.Stop();
}
#region Hotkey Setting
private static void SetHotkey(RegisteredHotkeyData hotkeyData)

View file

@ -242,11 +242,6 @@ namespace Flow.Launcher
private async Task OpenHotkeyDialogAsync()
{
if (!string.IsNullOrEmpty(Hotkey))
{
HotKeyMapper.RemoveHotkey(Hotkey);
}
var dialog = new HotkeyControlDialog(Hotkey, DefaultHotkey, WindowTitle)
{
Owner = Window.GetWindow(this)
@ -300,8 +295,6 @@ namespace Flow.Launcher
public void Delete()
{
if (!string.IsNullOrEmpty(Hotkey))
HotKeyMapper.RemoveHotkey(Hotkey);
Hotkey = "";
SetKeysToDisplay(new HotkeyModel(false, false, false, false, Key.None));
}
@ -318,7 +311,6 @@ namespace Flow.Launcher
foreach (var key in hotkey.Value.EnumerateDisplayKeys()!)
{
KeysToDisplay.Add(key);
}
}

View file

@ -38,7 +38,7 @@
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="250" />
<RowDefinition Height="340"/>
<RowDefinition Height="340" />
</Grid.RowDefinitions>
<Border Grid.Row="0" HorizontalAlignment="Stretch">
@ -90,11 +90,12 @@
</Border>
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Visible">
<StackPanel Margin="24 20 24 20">
<StackPanel Margin="24 20 24 20">
<TextBlock
FontSize="20"
FontWeight="SemiBold"
Text="{DynamicResource Welcome_Page2_Title}" TextWrapping="WrapWithOverflow"/>
Text="{DynamicResource Welcome_Page2_Title}"
TextWrapping="WrapWithOverflow" />
<TextBlock
Margin="0 10 0 0"
FontSize="14"
@ -112,7 +113,6 @@
Text="{DynamicResource flowlauncherHotkey}" />
<flowlauncher:HotkeyControl
Margin="0 8 0 0"
ChangeHotkey="{Binding SetTogglingHotkeyCommand}"
DefaultHotkey="Alt+Space"
Type="Hotkey"
ValidateKeyGesture="True"

View file

@ -1,9 +1,7 @@
using System.Windows.Media;
using System.Windows.Navigation;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.DependencyInjection;
using Flow.Launcher.Helper;
using Flow.Launcher.Infrastructure.Hotkey;
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.ViewModel;
@ -27,12 +25,6 @@ namespace Flow.Launcher.Resources.Pages
base.OnNavigatedTo(e);
}
[RelayCommand]
private static void SetTogglingHotkey(HotkeyModel hotkey)
{
HotKeyMapper.SetHotkey(hotkey, HotKeyMapper.OnToggleHotkey);
}
public Brush PreviewBackground
{
get => WallpaperPathRetrieval.GetWallpaperBrush();

View file

@ -3,7 +3,6 @@ using System.Windows;
using CommunityToolkit.Mvvm.Input;
using Flow.Launcher.Helper;
using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure.Hotkey;
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Plugin;
@ -28,12 +27,6 @@ public partial class SettingsPaneHotkeyViewModel : BaseModel
Settings = settings;
}
[RelayCommand]
private void SetTogglingHotkey(HotkeyModel hotkey)
{
HotKeyMapper.SetHotkey(hotkey, HotKeyMapper.OnToggleHotkey);
}
[RelayCommand]
private void CustomHotkeyDelete()
{

View file

@ -32,7 +32,6 @@
Icon="&#xeda7;"
Sub="{DynamicResource flowlauncherHotkeyToolTip}">
<flowlauncher:HotkeyControl
ChangeHotkey="{Binding SetTogglingHotkeyCommand}"
DefaultHotkey="Alt+Space"
Type="Hotkey"
ValidateKeyGesture="True"