Loading fix, CopyPath, Open in explorer
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
namespace FileTime.App.Core.Services;
|
||||
|
||||
public interface ISystemClipboardService
|
||||
{
|
||||
Task CopyToClipboardAsync(string text);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace FileTime.App.Core.UserCommand;
|
||||
|
||||
public class CopyNativePathCommand : IIdentifiableUserCommand
|
||||
{
|
||||
public const string CommandName = "copy_path";
|
||||
public static CopyNativePathCommand Instance { get; } = new CopyNativePathCommand();
|
||||
|
||||
private CopyNativePathCommand()
|
||||
{
|
||||
}
|
||||
|
||||
public string UserCommandID => CommandName;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace FileTime.App.Core.UserCommand;
|
||||
|
||||
public class OpenInDefaultFileExplorerCommand : IIdentifiableUserCommand
|
||||
{
|
||||
public const string CommandName = "open_in_default_explorer";
|
||||
public static OpenInDefaultFileExplorerCommand Instance { get; } = new OpenInDefaultFileExplorerCommand();
|
||||
|
||||
private OpenInDefaultFileExplorerCommand()
|
||||
{
|
||||
}
|
||||
|
||||
public string UserCommandID => CommandName;
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
using System.Reactive.Linq;
|
||||
using System.Text.Json;
|
||||
using FileTime.App.Core.Models;
|
||||
using FileTime.App.Core.ViewModels;
|
||||
|
||||
@@ -7,7 +7,6 @@ using FileTime.Core.Services;
|
||||
using FileTime.Core.Timeline;
|
||||
using FileTime.Providers.Local;
|
||||
using InitableService;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace FileTime.App.Core.Services.UserCommandHandler;
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
using System.Diagnostics;
|
||||
using FileTime.App.Core.UserCommand;
|
||||
using FileTime.App.Core.ViewModels;
|
||||
using FileTime.Core.Models;
|
||||
|
||||
namespace FileTime.App.Core.Services.UserCommandHandler;
|
||||
|
||||
public class ToolUserCommandHandlerService : UserCommandHandlerServiceBase
|
||||
{
|
||||
private readonly ISystemClipboardService _systemClipboardService;
|
||||
private IContainer? _currentLocation;
|
||||
private IItemViewModel? _currentSelectedItem;
|
||||
|
||||
public ToolUserCommandHandlerService(IAppState appState, ISystemClipboardService systemClipboardService) : base(appState)
|
||||
{
|
||||
_systemClipboardService = systemClipboardService;
|
||||
SaveCurrentLocation(l => _currentLocation = l);
|
||||
SaveCurrentSelectedItem(i => _currentSelectedItem = i);
|
||||
|
||||
AddCommandHandlers(new IUserCommandHandler[]
|
||||
{
|
||||
new TypeUserCommandHandler<OpenInDefaultFileExplorerCommand>(OpenInDefaultFileExplorer),
|
||||
new TypeUserCommandHandler<CopyNativePathCommand>(CopyNativePath),
|
||||
});
|
||||
}
|
||||
|
||||
private async Task CopyNativePath()
|
||||
{
|
||||
if (_currentSelectedItem?.BaseItem?.NativePath is null) return;
|
||||
await _systemClipboardService.CopyToClipboardAsync(_currentSelectedItem.BaseItem.NativePath.Path);
|
||||
}
|
||||
|
||||
private Task OpenInDefaultFileExplorer()
|
||||
{
|
||||
if (_currentLocation?.NativePath is null) return Task.CompletedTask;
|
||||
Process.Start("explorer.exe", "\"" + _currentLocation.NativePath.Path + "\"");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,7 @@ public static class Startup
|
||||
{
|
||||
return serviceCollection
|
||||
.AddSingleton<IUserCommandHandler, NavigationUserCommandHandlerService>()
|
||||
.AddSingleton<IUserCommandHandler, ItemManipulationUserCommandHandlerService>();
|
||||
.AddSingleton<IUserCommandHandler, ItemManipulationUserCommandHandlerService>()
|
||||
.AddSingleton<IUserCommandHandler, ToolUserCommandHandlerService>();
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ public class DefaultIdentifiableCommandHandlerRegister : IStartupHandler
|
||||
|
||||
AddUserCommand(CloseTabCommand.Instance);
|
||||
AddUserCommand(CopyCommand.Instance);
|
||||
AddUserCommand(CopyNativePathCommand.Instance);
|
||||
AddUserCommand(CreateContainer.Instance);
|
||||
AddUserCommand(CreateElement.Instance);
|
||||
AddUserCommand(EnterRapidTravelCommand.Instance);
|
||||
@@ -28,6 +29,7 @@ public class DefaultIdentifiableCommandHandlerRegister : IStartupHandler
|
||||
AddUserCommand(MoveCursorToLastCommand.Instance);
|
||||
AddUserCommand(MoveCursorUpCommand.Instance);
|
||||
AddUserCommand(MoveCursorUpPageCommand.Instance);
|
||||
AddUserCommand(OpenInDefaultFileExplorerCommand.Instance);
|
||||
AddUserCommand(OpenSelectedCommand.Instance);
|
||||
AddUserCommand(PasteCommand.Merge);
|
||||
AddUserCommand(PasteCommand.Overwrite);
|
||||
|
||||
@@ -49,7 +49,7 @@ public static class MainConfiguration
|
||||
//new CommandBindingConfiguration(ConfigCommand.Compress, new[] { Key.Y, Key.C }),
|
||||
new CommandBindingConfiguration(CopyCommand.CommandName, new[] { Key.Y, Key.Y }),
|
||||
//new CommandBindingConfiguration(ConfigCommand.CopyHash, new[] { Key.C, Key.H }),
|
||||
//new CommandBindingConfiguration(ConfigCommand.CopyPath, new[] { Key.C, Key.P }),
|
||||
new CommandBindingConfiguration(CopyNativePathCommand.CommandName, new[] { Key.C, Key.P }),
|
||||
new CommandBindingConfiguration(CreateContainer.CommandName, Key.F7),
|
||||
new CommandBindingConfiguration(CreateContainer.CommandName, new[] { Key.C, Key.C }),
|
||||
new CommandBindingConfiguration(CreateElement.CommandName, new[] { Key.C, Key.E }),
|
||||
@@ -69,7 +69,7 @@ public static class MainConfiguration
|
||||
new CommandBindingConfiguration(MoveCursorToFirstCommand.CommandName, new[] { Key.G, Key.G }),
|
||||
//new CommandBindingConfiguration(ConfigCommand.NextTimelineBlock, Key.L ),
|
||||
//new CommandBindingConfiguration(ConfigCommand.NextTimelineCommand, Key.J ),
|
||||
//new CommandBindingConfiguration(ConfigCommand.OpenInFileBrowser, new[] { Key.O, Key.E }),
|
||||
new CommandBindingConfiguration(OpenInDefaultFileExplorerCommand.CommandName, new[] { Key.O, Key.E }),
|
||||
new CommandBindingConfiguration(PasteCommand.PasteMergeCommandName, new[] { Key.P, Key.P }),
|
||||
new CommandBindingConfiguration(PasteCommand.PasteOverwriteCommandName, new[] { Key.P, Key.O }),
|
||||
new CommandBindingConfiguration(PasteCommand.PasteSkipCommandName, new[] { Key.P, Key.S }),
|
||||
|
||||
@@ -39,6 +39,7 @@ public static class Startup
|
||||
serviceCollection.TryAddSingleton<IIconProvider, MaterialIconProvider>();
|
||||
serviceCollection.TryAddSingleton<IModalService, ModalService>();
|
||||
serviceCollection.TryAddSingleton<IDialogService, DialogService>();
|
||||
serviceCollection.TryAddSingleton<ISystemClipboardService, SystemClipboardService>();
|
||||
serviceCollection.TryAddSingleton<IInputInterface>(s => s.GetRequiredService<IDialogService>());
|
||||
|
||||
return serviceCollection
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using FileTime.App.Core.Services;
|
||||
|
||||
namespace FileTime.GuiApp.Services;
|
||||
|
||||
public class SystemClipboardService : ISystemClipboardService
|
||||
{
|
||||
public async Task CopyToClipboardAsync(string text)
|
||||
{
|
||||
if (global::Avalonia.Application.Current?.Clipboard is { } clipboard)
|
||||
{
|
||||
await clipboard.SetTextAsync(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,11 +28,12 @@
|
||||
|
||||
<Grid Background="{DynamicResource AppBackgroundBrush}">
|
||||
<Grid
|
||||
x:DataType="vm:MainWindowViewModel">
|
||||
x:DataType="vm:MainWindowViewModel"
|
||||
IsVisible="{Binding Loading, Converter={x:Static BoolConverters.Not}, FallbackValue=False}">
|
||||
|
||||
<Grid
|
||||
ColumnDefinitions="250,*"
|
||||
RowDefinitions="Auto,*"
|
||||
IsVisible="{Binding Loading, Converter={x:Static BoolConverters.Not}}">
|
||||
RowDefinitions="Auto,*">
|
||||
|
||||
<Grid PointerPressed="HeaderPointerPressed">
|
||||
<Rectangle Fill="#01000000" />
|
||||
|
||||
Reference in New Issue
Block a user