-
-
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 remote-tracking branch 'upstream/main' into fix-icon-codes
- Loading branch information
Showing
128 changed files
with
3,181 additions
and
2,638 deletions.
There are no files selected for viewing
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,47 @@ | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using CommunityToolkit.Mvvm.DependencyInjection; | ||
using Files.App.Commands; | ||
using Files.App.Contexts; | ||
using Files.App.Extensions; | ||
using System.ComponentModel; | ||
using System.Threading.Tasks; | ||
using Windows.System; | ||
|
||
namespace Files.App.Actions | ||
{ | ||
internal class RefreshItemsAction : ObservableObject, IAction | ||
{ | ||
private readonly IContentPageContext context = Ioc.Default.GetRequiredService<IContentPageContext>(); | ||
|
||
public string Label { get; } = "Refresh".GetLocalizedResource(); | ||
public string Description { get; } = "TODO"; | ||
|
||
public RichGlyph Glyph { get; } = new("\uE72C"); | ||
|
||
public HotKey HotKey { get; } = new(VirtualKey.R, VirtualKeyModifiers.Control); | ||
|
||
public HotKey SecondHotKey { get; } = new(VirtualKey.F5); | ||
|
||
public bool IsExecutable => context.CanRefresh; | ||
|
||
public RefreshItemsAction() | ||
{ | ||
context.PropertyChanged += Context_PropertyChanged; | ||
} | ||
|
||
public async Task ExecuteAsync() | ||
{ | ||
context.ShellPage?.Refresh_Click(); | ||
} | ||
|
||
private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) | ||
{ | ||
switch (e.PropertyName) | ||
{ | ||
case nameof(IContentPageContext.CanRefresh): | ||
OnPropertyChanged(nameof(IsExecutable)); | ||
break; | ||
} | ||
} | ||
} | ||
} |
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
33 changes: 33 additions & 0 deletions
33
src/Files.App/Actions/Content/Selection/ToggleSelectAction.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,33 @@ | ||
using Files.App.Commands; | ||
using Files.App.Extensions; | ||
using Microsoft.UI.Xaml.Controls.Primitives; | ||
using Microsoft.UI.Xaml.Input; | ||
using System.Threading.Tasks; | ||
using Windows.System; | ||
|
||
namespace Files.App.Actions | ||
{ | ||
internal class ToggleSelectAction : IAction | ||
{ | ||
public string Label { get; } = "ToggleSelect".GetLocalizedResource(); | ||
public string Description => "TODO: Need to be described."; | ||
|
||
public HotKey HotKey { get; } = new(VirtualKey.Space, VirtualKeyModifiers.Control); | ||
|
||
public bool IsExecutable => GetFocusedElement() is not null; | ||
|
||
public Task ExecuteAsync() | ||
{ | ||
if (GetFocusedElement() is SelectorItem item) | ||
{ | ||
item.IsSelected = !item.IsSelected; | ||
} | ||
return Task.CompletedTask; | ||
} | ||
|
||
private static SelectorItem? GetFocusedElement() | ||
{ | ||
return FocusManager.GetFocusedElement(App.Window.Content.XamlRoot) as SelectorItem; | ||
} | ||
} | ||
} |
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,67 @@ | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using CommunityToolkit.Mvvm.DependencyInjection; | ||
using Files.App.Commands; | ||
using Files.App.Contexts; | ||
using Files.App.Extensions; | ||
using System.Threading.Tasks; | ||
using Windows.System; | ||
|
||
namespace Files.App.Actions | ||
{ | ||
internal class RenameAction : ObservableObject, IAction | ||
{ | ||
private readonly IContentPageContext context = Ioc.Default.GetRequiredService<IContentPageContext>(); | ||
|
||
public string Label { get; } = "Rename".GetLocalizedResource(); | ||
|
||
public string Description { get; } = "TODO"; | ||
|
||
public HotKey HotKey { get; } = new(VirtualKey.F2); | ||
|
||
public RichGlyph Glyph { get; } = new(opacityStyle: "ColorIconRename"); | ||
|
||
public bool IsExecutable => | ||
context.ShellPage is not null && | ||
IsPageTypeValid() && | ||
context.ShellPage.SlimContentPage is not null && | ||
IsSelectionValid(); | ||
|
||
public RenameAction() | ||
{ | ||
context.PropertyChanged += Context_PropertyChanged; | ||
} | ||
|
||
public Task ExecuteAsync() | ||
{ | ||
context.ShellPage?.SlimContentPage?.ItemManipulationModel.StartRenameItem(); | ||
return Task.CompletedTask; | ||
} | ||
|
||
private void Context_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e) | ||
{ | ||
switch (e.PropertyName) | ||
{ | ||
case nameof(IContentPageContext.ShellPage): | ||
case nameof(IContentPageContext.PageType): | ||
case nameof(IContentPageContext.HasSelection): | ||
case nameof(IContentPageContext.SelectedItems): | ||
OnPropertyChanged(nameof(IsExecutable)); | ||
break; | ||
} | ||
} | ||
|
||
private bool IsSelectionValid() | ||
{ | ||
return context.HasSelection && context.SelectedItems.Count == 1; | ||
} | ||
|
||
private bool IsPageTypeValid() | ||
{ | ||
return context.PageType is | ||
not ContentPageTypes.None and | ||
not ContentPageTypes.Home and | ||
not ContentPageTypes.RecycleBin and | ||
not ContentPageTypes.ZipFolder; | ||
} | ||
} | ||
} |
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,49 @@ | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using CommunityToolkit.Mvvm.DependencyInjection; | ||
using Files.App.Commands; | ||
using Files.App.Contexts; | ||
using Files.App.Extensions; | ||
using System.ComponentModel; | ||
using System.Threading.Tasks; | ||
using Windows.System; | ||
|
||
namespace Files.App.Actions | ||
{ | ||
internal class SearchAction : ObservableObject, IAction | ||
{ | ||
private readonly IContentPageContext context = Ioc.Default.GetRequiredService<IContentPageContext>(); | ||
|
||
public string Label { get; } = "Search".GetLocalizedResource(); | ||
|
||
public string Description { get; } = "TODO: Need to be described."; | ||
|
||
public HotKey HotKey { get; } = new(VirtualKey.F, VirtualKeyModifiers.Control); | ||
|
||
public HotKey SecondHotKey { get; } = new(VirtualKey.F3); | ||
|
||
public RichGlyph Glyph { get; } = new(); | ||
|
||
public bool IsExecutable => !context.IsSearchBoxVisible; | ||
|
||
public SearchAction() | ||
{ | ||
context.PropertyChanged += Context_PropertyChanged; | ||
} | ||
|
||
public Task ExecuteAsync() | ||
{ | ||
context.ShellPage!.ToolbarViewModel.SwitchSearchBoxVisibility(); | ||
return Task.CompletedTask; | ||
} | ||
|
||
private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) | ||
{ | ||
switch (e.PropertyName) | ||
{ | ||
case nameof(IContentPageContext.IsSearchBoxVisible): | ||
OnPropertyChanged(nameof(IsExecutable)); | ||
break; | ||
} | ||
} | ||
} | ||
} |
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,50 @@ | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using CommunityToolkit.Mvvm.DependencyInjection; | ||
using Files.App.Commands; | ||
using Files.App.Contexts; | ||
using Files.App.Extensions; | ||
using System.ComponentModel; | ||
using System.Threading.Tasks; | ||
using Windows.System; | ||
|
||
namespace Files.App.Actions | ||
{ | ||
internal class NavigateBackAction : ObservableObject, IAction | ||
{ | ||
private readonly IContentPageContext context = Ioc.Default.GetRequiredService<IContentPageContext>(); | ||
|
||
public string Label { get; } = "Back".GetLocalizedResource(); | ||
|
||
public string Description { get; } = "NavigateBack".GetLocalizedResource(); | ||
|
||
public HotKey HotKey { get; } = new(VirtualKey.Left, VirtualKeyModifiers.Menu); | ||
public HotKey SecondHotKey { get; } = new(VirtualKey.Back); | ||
public HotKey ThirdHotKey { get; } = new(VirtualKey.XButton1); | ||
public HotKey MediaHotKey { get; } = new(VirtualKey.GoBack); | ||
|
||
public RichGlyph Glyph { get; } = new("\uE72B"); | ||
|
||
public bool IsExecutable => context.CanGoBack; | ||
|
||
public NavigateBackAction() | ||
{ | ||
context.PropertyChanged += Context_PropertyChanged; | ||
} | ||
|
||
public Task ExecuteAsync() | ||
{ | ||
context.ShellPage!.Back_Click(); | ||
return Task.CompletedTask; | ||
} | ||
|
||
private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) | ||
{ | ||
switch (e.PropertyName) | ||
{ | ||
case nameof(IContentPageContext.CanGoBack): | ||
OnPropertyChanged(nameof(IsExecutable)); | ||
break; | ||
} | ||
} | ||
} | ||
} |
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,49 @@ | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using CommunityToolkit.Mvvm.DependencyInjection; | ||
using Files.App.Commands; | ||
using Files.App.Contexts; | ||
using Files.App.Extensions; | ||
using System.ComponentModel; | ||
using System.Threading.Tasks; | ||
using Windows.System; | ||
|
||
namespace Files.App.Actions | ||
{ | ||
internal class NavigateForwardAction : ObservableObject, IAction | ||
{ | ||
private readonly IContentPageContext context = Ioc.Default.GetRequiredService<IContentPageContext>(); | ||
|
||
public string Label { get; } = "Forward".GetLocalizedResource(); | ||
|
||
public string Description { get; } = "NavigateForward".GetLocalizedResource(); | ||
|
||
public HotKey HotKey { get; } = new(VirtualKey.Right, VirtualKeyModifiers.Menu); | ||
public HotKey SecondHotKey { get; } = new(VirtualKey.XButton2); | ||
public HotKey MediaHotKey { get; } = new(VirtualKey.GoForward); | ||
|
||
public RichGlyph Glyph { get; } = new("\uE72A"); | ||
|
||
public bool IsExecutable => context.CanGoForward; | ||
|
||
public NavigateForwardAction() | ||
{ | ||
context.PropertyChanged += Context_PropertyChanged; | ||
} | ||
|
||
public Task ExecuteAsync() | ||
{ | ||
context.ShellPage!.Forward_Click(); | ||
return Task.CompletedTask; | ||
} | ||
|
||
private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) | ||
{ | ||
switch (e.PropertyName) | ||
{ | ||
case nameof(IContentPageContext.CanGoForward): | ||
OnPropertyChanged(nameof(IsExecutable)); | ||
break; | ||
} | ||
} | ||
} | ||
} |
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,48 @@ | ||
| ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using CommunityToolkit.Mvvm.DependencyInjection; | ||
using Files.App.Commands; | ||
using Files.App.Contexts; | ||
using Files.App.Extensions; | ||
using System.ComponentModel; | ||
using System.Threading.Tasks; | ||
using Windows.System; | ||
|
||
namespace Files.App.Actions | ||
{ | ||
internal class NavigateUpAction : ObservableObject, IAction | ||
{ | ||
private readonly IContentPageContext context = Ioc.Default.GetRequiredService<IContentPageContext>(); | ||
|
||
public string Label { get; } = "Up".GetLocalizedResource(); | ||
|
||
public string Description { get; } = "NavigateUp".GetLocalizedResource(); | ||
|
||
public HotKey HotKey { get; } = new(VirtualKey.Up, VirtualKeyModifiers.Menu); | ||
|
||
public RichGlyph Glyph { get; } = new("\uE74A"); | ||
|
||
public bool IsExecutable => context.CanNavigateToParent; | ||
|
||
public NavigateUpAction() | ||
{ | ||
context.PropertyChanged += Context_PropertyChanged; | ||
} | ||
|
||
public Task ExecuteAsync() | ||
{ | ||
context.ShellPage!.Up_Click(); | ||
return Task.CompletedTask; | ||
} | ||
|
||
private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) | ||
{ | ||
switch (e.PropertyName) | ||
{ | ||
case nameof(IContentPageContext.CanNavigateToParent): | ||
OnPropertyChanged(nameof(IsExecutable)); | ||
break; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.