-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/Files-community/Files
- Loading branch information
Showing
103 changed files
with
1,711 additions
and
857 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
src/Files.App/Actions/Content/QuickLook/LaunchQuickLookAction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using CommunityToolkit.Mvvm.DependencyInjection; | ||
using Files.App.Commands; | ||
using Files.App.Contexts; | ||
using Files.App.Extensions; | ||
using Files.App.Helpers; | ||
using Files.App.Shell; | ||
using Files.Backend.Helpers; | ||
using System.Threading.Tasks; | ||
using Windows.System; | ||
|
||
namespace Files.App.Actions | ||
{ | ||
internal class LaunchQuickLookAction : ObservableObject, IAction | ||
{ | ||
private readonly IContentPageContext context = Ioc.Default.GetRequiredService<IContentPageContext>(); | ||
|
||
public HotKey HotKey { get; } = new(VirtualKey.Space); | ||
|
||
public bool IsExecutable => context.SelectedItems.Count == 1 && | ||
(!context.ShellPage?.ToolbarViewModel?.IsEditModeEnabled ?? false) && | ||
(!context.ShellPage?.SlimContentPage?.IsRenamingItem ?? false); | ||
|
||
public string Label => "LaunchQuickLook".GetLocalizedResource(); | ||
|
||
public LaunchQuickLookAction() | ||
{ | ||
context.PropertyChanged += Context_PropertyChanged; | ||
} | ||
|
||
public async Task ExecuteAsync() | ||
{ | ||
await QuickLookHelpers.ToggleQuickLook(context.SelectedItem!.ItemPath); | ||
} | ||
|
||
public void Context_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e) | ||
{ | ||
switch (e.PropertyName) | ||
{ | ||
case nameof(IContentPageContext.SelectedItems): | ||
OnPropertyChanged(nameof(IsExecutable)); | ||
var _ = SwitchQuickLookPreview(); | ||
break; | ||
} | ||
} | ||
|
||
private async Task SwitchQuickLookPreview() | ||
{ | ||
if (IsExecutable) | ||
await QuickLookHelpers.ToggleQuickLook(context.SelectedItem!.ItemPath, true); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using CommunityToolkit.Mvvm.DependencyInjection; | ||
using Files.App.Commands; | ||
using Files.App.Contexts; | ||
using Files.App.Extensions; | ||
using Files.App.Helpers; | ||
using System; | ||
using System.Threading.Tasks; | ||
using Windows.ApplicationModel.DataTransfer; | ||
using Windows.System; | ||
|
||
namespace Files.App.Actions | ||
{ | ||
internal class CopyPathAction : IAction | ||
{ | ||
private readonly IContentPageContext context = Ioc.Default.GetRequiredService<IContentPageContext>(); | ||
|
||
public string Label { get; } = "CopyLocation".GetLocalizedResource(); | ||
|
||
public RichGlyph Glyph { get; } = new RichGlyph(opacityStyle: "ColorIconCopyLocation"); | ||
|
||
public HotKey HotKey { get; } = new(VirtualKey.C, VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift); | ||
|
||
public async Task ExecuteAsync() | ||
{ | ||
if (context.ShellPage?.SlimContentPage is not null) | ||
{ | ||
var path = context.ShellPage.SlimContentPage.SelectedItem is not null | ||
? context.ShellPage.SlimContentPage.SelectedItem.ItemPath | ||
: context.ShellPage.FilesystemViewModel.WorkingDirectory; | ||
|
||
if (FtpHelpers.IsFtpPath(path)) | ||
path = path.Replace("\\", "/", StringComparison.Ordinal); | ||
|
||
DataPackage data = new(); | ||
data.SetText(path); | ||
|
||
Clipboard.SetContent(data); | ||
Clipboard.Flush(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using CommunityToolkit.Mvvm.DependencyInjection; | ||
using Files.App.Commands; | ||
using Files.App.Contexts; | ||
using Files.App.DataModels; | ||
using Files.App.Extensions; | ||
using Files.App.Helpers; | ||
using System.ComponentModel; | ||
using System.Threading.Tasks; | ||
using Windows.System; | ||
|
||
namespace Files.App.Actions | ||
{ | ||
internal class PasteItemAction : ObservableObject, IAction | ||
{ | ||
private readonly IContentPageContext context = Ioc.Default.GetRequiredService<IContentPageContext>(); | ||
|
||
public string Label { get; } = "Paste".GetLocalizedResource(); | ||
|
||
public RichGlyph Glyph { get; } = new(opacityStyle: "ColorIconPaste"); | ||
|
||
public HotKey HotKey { get; } = new(VirtualKey.V, VirtualKeyModifiers.Control); | ||
|
||
private bool isExecutable; | ||
public bool IsExecutable => isExecutable; | ||
|
||
public PasteItemAction() | ||
{ | ||
isExecutable = GetIsExecutable(); | ||
|
||
context.PropertyChanged += Context_PropertyChanged; | ||
App.AppModel.PropertyChanged += AppModel_PropertyChanged; | ||
} | ||
|
||
public async Task ExecuteAsync() | ||
{ | ||
if (context.ShellPage is null) | ||
return; | ||
|
||
string path = context.ShellPage.FilesystemViewModel.WorkingDirectory; | ||
await UIFilesystemHelpers.PasteItemAsync(path, context.ShellPage); | ||
} | ||
|
||
public bool GetIsExecutable() | ||
{ | ||
return App.AppModel.IsPasteEnabled | ||
&& context.PageType is not ContentPageTypes.Home and not ContentPageTypes.RecycleBin and not ContentPageTypes.SearchResults; | ||
} | ||
|
||
private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) | ||
{ | ||
if (e.PropertyName is nameof(IContentPageContext.PageType)) | ||
SetProperty(ref isExecutable, GetIsExecutable(), nameof(IsExecutable)); | ||
} | ||
private void AppModel_PropertyChanged(object? sender, PropertyChangedEventArgs e) | ||
{ | ||
if (e.PropertyName is nameof(AppModel.IsPasteEnabled)) | ||
SetProperty(ref isExecutable, GetIsExecutable(), nameof(IsExecutable)); | ||
} | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
src/Files.App/Actions/FileSystem/PasteItemToSelectionAction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using CommunityToolkit.Mvvm.DependencyInjection; | ||
using Files.App.Commands; | ||
using Files.App.Contexts; | ||
using Files.App.DataModels; | ||
using Files.App.Extensions; | ||
using Files.App.Filesystem; | ||
using Files.App.Helpers; | ||
using System.ComponentModel; | ||
using System.Threading.Tasks; | ||
using Windows.System; | ||
|
||
namespace Files.App.Actions | ||
{ | ||
internal class PasteItemToSelectionAction : ObservableObject, IAction | ||
{ | ||
private readonly IContentPageContext context = Ioc.Default.GetRequiredService<IContentPageContext>(); | ||
|
||
public string Label { get; } = "Paste".GetLocalizedResource(); | ||
|
||
public RichGlyph Glyph { get; } = new(opacityStyle: "ColorIconPaste"); | ||
|
||
public HotKey HotKey { get; } = new(VirtualKey.V, VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift); | ||
|
||
private bool isExecutable; | ||
public bool IsExecutable => isExecutable; | ||
|
||
public PasteItemToSelectionAction() | ||
{ | ||
isExecutable = GetIsExecutable(); | ||
|
||
context.PropertyChanged += Context_PropertyChanged; | ||
App.AppModel.PropertyChanged += AppModel_PropertyChanged; | ||
} | ||
|
||
public async Task ExecuteAsync() | ||
{ | ||
if (context.ShellPage is null) | ||
return; | ||
|
||
string path = context.SelectedItem is ListedItem selectedItem | ||
? selectedItem.ItemPath | ||
: context.ShellPage.FilesystemViewModel.WorkingDirectory; | ||
|
||
await UIFilesystemHelpers.PasteItemAsync(path, context.ShellPage); | ||
} | ||
|
||
public bool GetIsExecutable() | ||
{ | ||
if (!App.AppModel.IsPasteEnabled) | ||
return false; | ||
if (context.PageType is ContentPageTypes.Home or ContentPageTypes.RecycleBin or ContentPageTypes.SearchResults) | ||
return false; | ||
if (!context.HasSelection) | ||
return true; | ||
return context.SelectedItem?.PrimaryItemAttribute is Windows.Storage.StorageItemTypes.Folder; | ||
} | ||
|
||
private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) | ||
{ | ||
switch (e.PropertyName) | ||
{ | ||
case nameof(IContentPageContext.PageType): | ||
case nameof(IContentPageContext.SelectedItem): | ||
SetProperty(ref isExecutable, GetIsExecutable(), nameof(IsExecutable)); | ||
break; | ||
} | ||
} | ||
private void AppModel_PropertyChanged(object? sender, PropertyChangedEventArgs e) | ||
{ | ||
if (e.PropertyName is nameof(AppModel.IsPasteEnabled)) | ||
SetProperty(ref isExecutable, GetIsExecutable(), nameof(IsExecutable)); | ||
} | ||
} | ||
} |
Oops, something went wrong.