Rapid travel filter + ESC improvements
This commit is contained in:
@@ -79,6 +79,10 @@ public class DefaultModeKeyInputHandler : IDefaultModeKeyInputHandler
|
||||
{
|
||||
_modalService.CloseModal(_openModals.Last());
|
||||
}
|
||||
else if (_appState.RapidTravelText.Value != "")
|
||||
{
|
||||
await _appState.SetRapidTravelTextAsync("");
|
||||
}
|
||||
else if (_currentLocation.Value?.GetExtension<EscHandlerContainerExtension>() is { } escHandler)
|
||||
{
|
||||
var escapeResult = await escHandler.HandleEsc();
|
||||
|
||||
@@ -5,6 +5,7 @@ using DeclarativeProperty;
|
||||
using FileTime.App.Core.Configuration;
|
||||
using FileTime.App.Core.Models.Enums;
|
||||
using FileTime.Core.Models.Extensions;
|
||||
using FileTime.Core.Services;
|
||||
using MoreLinq;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
|
||||
@@ -31,7 +32,7 @@ public abstract partial class AppStateBase : IAppState
|
||||
[Notify] public List<KeyConfig> PreviousKeys { get; } = new();
|
||||
[Notify] public bool NoCommandFound { get; set; }
|
||||
|
||||
protected AppStateBase()
|
||||
protected AppStateBase(ITabEvents tabEvents)
|
||||
{
|
||||
_rapidTravelText = new("");
|
||||
RapidTravelText = _rapidTravelText.DistinctUntilChanged();
|
||||
@@ -59,6 +60,8 @@ public abstract partial class AppStateBase : IAppState
|
||||
.Switch()
|
||||
.Map(c => c?.GetExtension<StatusProviderContainerExtension>()?.GetStatusProperty())
|
||||
.Switch()!;
|
||||
|
||||
tabEvents.LocationChanged += (_, _) => Task.Run(async () => await SetRapidTravelTextAsync("")).Wait();
|
||||
}
|
||||
|
||||
public void AddTab(ITabViewModel tabViewModel)
|
||||
@@ -79,11 +82,8 @@ public abstract partial class AppStateBase : IAppState
|
||||
|
||||
public void SetSearchText(string? searchText) => _searchText.OnNext(searchText);
|
||||
|
||||
public async Task SwitchViewModeAsync(ViewMode newViewMode)
|
||||
{
|
||||
if (newViewMode != Models.Enums.ViewMode.RapidTravel) await SetRapidTravelTextAsync(null);
|
||||
await _viewMode.SetValue(newViewMode);
|
||||
}
|
||||
public Task SwitchViewModeAsync(ViewMode newViewMode)
|
||||
=> _viewMode.SetValue(newViewMode);
|
||||
|
||||
public async Task SetSelectedTabAsync(ITabViewModel tabToSelect) => await _selectedTab.SetValue(tabToSelect);
|
||||
public async Task SetRapidTravelTextAsync(string? text) => await _rapidTravelText.SetValue(text);
|
||||
|
||||
@@ -5,4 +5,5 @@ namespace FileTime.GuiApp.App.Services;
|
||||
public interface IKeyInputHandlerService
|
||||
{
|
||||
Task ProcessKeyDown(KeyEventArgs e);
|
||||
event EventHandler? UnhandledEsc;
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -102,6 +102,7 @@ public partial class MainWindowViewModel : IMainWindowViewModel
|
||||
|
||||
_modalService.AllModalClosed += (_, _) => FocusDefaultElement?.Invoke();
|
||||
_instanceMessageHandler.ShowWindow += () => ShowWindow?.Invoke();
|
||||
_keyInputHandlerService.UnhandledEsc += (_,_) => FocusDefaultElement?.Invoke();
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user