Rapid travel filter + ESC improvements

This commit is contained in:
2024-02-27 21:17:12 +01:00
parent 9ee819cee3
commit 4302b23ceb
7 changed files with 22 additions and 8 deletions

View File

@@ -5,4 +5,5 @@ namespace FileTime.GuiApp.App.Services;
public interface IKeyInputHandlerService
{
Task ProcessKeyDown(KeyEventArgs e);
event EventHandler? UnhandledEsc;
}

View File

@@ -16,6 +16,8 @@ public class KeyInputHandlerService : IKeyInputHandlerService
private readonly IAppKeyService<Key> _appKeyService;
private GuiPanel _activePanel;
public event EventHandler? UnhandledEsc;
private readonly Dictionary<(GuiPanel, Key), GuiPanel> _panelMovements = new()
{
[(GuiPanel.FileBrowser, Key.Up)] = GuiPanel.Timeline,
@@ -72,6 +74,11 @@ public class KeyInputHandlerService : IKeyInputHandlerService
if (e.ToGeneralKeyEventArgs(_appKeyService, specialKeyStatus) is { } args)
{
await _defaultModeKeyInputHandler.HandleInputKey(args);
if (!args.Handled && args.Key == Keys.Escape)
{
UnhandledEsc?.Invoke(this, EventArgs.Empty);
}
}
}
else

View File

@@ -102,6 +102,7 @@ public partial class MainWindowViewModel : IMainWindowViewModel
_modalService.AllModalClosed += (_, _) => FocusDefaultElement?.Invoke();
_instanceMessageHandler.ShowWindow += () => ShowWindow?.Invoke();
_keyInputHandlerService.UnhandledEsc += (_,_) => FocusDefaultElement?.Invoke();
Task.Run(async () =>
{

View File

@@ -74,7 +74,7 @@ public partial class MainWindow : Window, IUiAccessor
try
{
var viewModel = DI.ServiceProvider.GetRequiredService<MainWindowViewModel>();
viewModel.FocusDefaultElement = () => Focus();
viewModel.FocusDefaultElement = () => Dispatcher.UIThread.Invoke(() => Focus());
viewModel.ShowWindow = Activate;
ViewModel = viewModel;
}

View File

@@ -2,6 +2,7 @@ using System.Collections.ObjectModel;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using FileTime.App.Core.ViewModels;
using FileTime.Core.Services;
using FileTime.GuiApp.App.Models;
using FileTime.GuiApp.App.ViewModels;
using FileTime.Providers.Local;
@@ -18,7 +19,7 @@ public partial class GuiAppState : AppStateBase, IGuiAppState, IDisposable
public IObservable<GuiPanel> ActivePanel { get; }
public GuiAppState()
public GuiAppState(ITabEvents tabEvents):base(tabEvents)
{
ActivePanel = _activePanel.AsObservable();
}