From ee0c6f7a0ba7b896052d98994d9dd9e1eb79e1e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81d=C3=A1m=20Kov=C3=A1cs?= Date: Wed, 2 Feb 2022 21:50:10 +0100 Subject: [PATCH] Help, key bindings --- .../FileTime.App.Core/Tab/TabState.cs | 18 + src/GuiApp/FileTime.Avalonia/App.axaml | 4 + .../Command/CommandBinding.cs | 4 +- .../ViewModels/MainPageViewModel.cs | 49 +- .../FileTime.Avalonia/Views/MainWindow.axaml | 872 +++++++++--------- 5 files changed, 520 insertions(+), 427 deletions(-) diff --git a/src/AppCommon/FileTime.App.Core/Tab/TabState.cs b/src/AppCommon/FileTime.App.Core/Tab/TabState.cs index c18f062..6615669 100644 --- a/src/AppCommon/FileTime.App.Core/Tab/TabState.cs +++ b/src/AppCommon/FileTime.App.Core/Tab/TabState.cs @@ -59,6 +59,24 @@ namespace FileTime.App.Core.Tab } } + public async Task ClearMarkedItems(IContainer container) + { + if (_markedItems.ContainsKey(container)) + { + var markedItems = _markedItems[container]; + for (var i = 0; i < markedItems.Count; i++) + { + await ItemUnmarked.InvokeAsync(this, markedItems[i]); + markedItems.RemoveAt(i--); + } + } + } + + public async Task ClearCurrentMarkedItems() + { + await ClearMarkedItems(await Tab.GetCurrentLocation()); + } + public bool ContainsMarkedItem(IContainer container, AbsolutePath path) { if (!_markedItems.ContainsKey(container)) return false; diff --git a/src/GuiApp/FileTime.Avalonia/App.axaml b/src/GuiApp/FileTime.Avalonia/App.axaml index 4fce1de..6711d6c 100644 --- a/src/GuiApp/FileTime.Avalonia/App.axaml +++ b/src/GuiApp/FileTime.Avalonia/App.axaml @@ -11,6 +11,7 @@ #073642 #083e4c + #D0083e4c #00000000 #10000000 @@ -44,6 +45,9 @@ + 0 && currentText.Last() != ' ') s += " "; if (key.Ctrl ?? false) s += "CTRL+"; if (key.Alt ?? false) s += "ALT+"; @@ -69,7 +69,7 @@ namespace FileTime.Avalonia.Command { var s = ""; - if (currentText.Last() != ' ' && !wasCtrlOrAlt) s += " "; + if (currentText.Length > 0 && currentText.Last() != ' ' && !wasCtrlOrAlt) s += " "; s += key.Key.ToString(); if (!wasCtrlOrAlt) s += " "; diff --git a/src/GuiApp/FileTime.Avalonia/ViewModels/MainPageViewModel.cs b/src/GuiApp/FileTime.Avalonia/ViewModels/MainPageViewModel.cs index 4a455d1..87fb3d1 100644 --- a/src/GuiApp/FileTime.Avalonia/ViewModels/MainPageViewModel.cs +++ b/src/GuiApp/FileTime.Avalonia/ViewModels/MainPageViewModel.cs @@ -73,6 +73,12 @@ namespace FileTime.Avalonia.ViewModels [Property] private ObservableCollection _popupTexts = new ObservableCollection(); + [Property] + private bool _showAllShortcut; + + [Property] + private List _allShortcut; + public ObservableCollection TimelineCommands { get; } = new(); async partial void OnInitialize() @@ -95,6 +101,8 @@ namespace FileTime.Avalonia.ViewModels _keysToSkip.Add(new KeyWithModifiers[] { new KeyWithModifiers(Key.PageUp) }); _keysToSkip.Add(new KeyWithModifiers[] { new KeyWithModifiers(Key.F4, alt: true) }); + AllShortcut = _commandBindings.Concat(_universalCommandBindings).ToList(); + var tab = new Tab(); await tab.Init(LocalContentProvider); @@ -428,6 +436,7 @@ namespace FileTime.Avalonia.ViewModels { _clipboard.AddContent(selectedItem); } + await AppState.SelectedTab.TabState.ClearCurrentMarkedItems(); } else { @@ -647,6 +656,12 @@ namespace FileTime.Avalonia.ViewModels return Task.CompletedTask; } + private Task ShowAllShortcut2() + { + ShowAllShortcut = true; + return Task.CompletedTask; + } + [Command] public async void ProcessInputs() { @@ -707,6 +722,7 @@ namespace FileTime.Avalonia.ViewModels if (key == Key.Escape) { + ShowAllShortcut = false; _previousKeys.Clear(); PossibleCommands = new(); } @@ -750,7 +766,14 @@ namespace FileTime.Avalonia.ViewModels if (key == Key.Escape) { - await ExitRapidTravelMode(); + if (ShowAllShortcut) + { + ShowAllShortcut = false; + } + else + { + await ExitRapidTravelMode(); + } } else if (key == Key.Back) { @@ -888,6 +911,11 @@ namespace FileTime.Avalonia.ViewModels FileTime.App.Core.Command.Commands.CreateContainer, new KeyWithModifiers[]{new KeyWithModifiers(Key.C),new KeyWithModifiers(Key.C)}, CreateContainer), + new CommandBinding( + "create container", + FileTime.App.Core.Command.Commands.CreateContainer, + new KeyWithModifiers[]{new KeyWithModifiers(Key.F7)}, + CreateContainer), new CommandBinding( "create element", FileTime.App.Core.Command.Commands.CreateElement, @@ -1008,6 +1036,11 @@ namespace FileTime.Avalonia.ViewModels FileTime.App.Core.Command.Commands.Rename, new KeyWithModifiers[]{new KeyWithModifiers(Key.C),new KeyWithModifiers(Key.W)}, Rename), + new CommandBinding( + "rename", + FileTime.App.Core.Command.Commands.Rename, + new KeyWithModifiers[]{new KeyWithModifiers(Key.F2)}, + Rename), new CommandBinding( "timeline pause", FileTime.App.Core.Command.Commands.Dummy, @@ -1028,16 +1061,26 @@ namespace FileTime.Avalonia.ViewModels FileTime.App.Core.Command.Commands.Refresh, new KeyWithModifiers[]{new KeyWithModifiers(Key.R)}, RefreshCurrentLocation), + new CommandBinding( + "refresh", + FileTime.App.Core.Command.Commands.Refresh, + new KeyWithModifiers[]{new KeyWithModifiers(Key.F5)}, + RefreshCurrentLocation), new CommandBinding( "go to", FileTime.App.Core.Command.Commands.Dummy, - new KeyWithModifiers[]{new KeyWithModifiers(Key.L, ctrl: true)}, + new KeyWithModifiers[] { new KeyWithModifiers(Key.L, ctrl: true) }, GoToContainer), new CommandBinding( "toggle advanced icons", FileTime.App.Core.Command.Commands.Dummy, - new KeyWithModifiers[]{new KeyWithModifiers(Key.Z),new KeyWithModifiers(Key.I)}, + new KeyWithModifiers[] { new KeyWithModifiers(Key.Z), new KeyWithModifiers(Key.I) }, ToggleAdvancedIcons), + new CommandBinding( + "show all shortcut", + FileTime.App.Core.Command.Commands.Dummy, + new KeyWithModifiers[] { new KeyWithModifiers(Key.F1) }, + ShowAllShortcut2), }; var universalCommandBindings = new List() { diff --git a/src/GuiApp/FileTime.Avalonia/Views/MainWindow.axaml b/src/GuiApp/FileTime.Avalonia/Views/MainWindow.axaml index 040e1eb..782c612 100644 --- a/src/GuiApp/FileTime.Avalonia/Views/MainWindow.axaml +++ b/src/GuiApp/FileTime.Avalonia/Views/MainWindow.axaml @@ -18,464 +18,492 @@ x:Name="RootContainer" Background="{DynamicResource AppBackgroundBrush}"> - - - - - - - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - Empty - - + Margin="0,0,0,10" + Text="Drives" /> - - - - - + + - + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - Empty - - - - - - - - - - - - - - - + + - + - - - - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - -