Skip to content

Commit 04d7dca

Browse files
authored
Merge branch 'main' into 5bfa/tweak-security
2 parents a0eefbc + ad193fe commit 04d7dca

File tree

118 files changed

+1149
-906
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+1149
-906
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using CommunityToolkit.Mvvm.ComponentModel;
2+
using CommunityToolkit.Mvvm.DependencyInjection;
3+
using Files.App.Commands;
4+
using Files.App.Contexts;
5+
using Files.App.Extensions;
6+
using System.ComponentModel;
7+
using System.Threading.Tasks;
8+
using Windows.System;
9+
10+
namespace Files.App.Actions
11+
{
12+
internal class RefreshItemsAction : ObservableObject, IAction
13+
{
14+
private readonly IContentPageContext context = Ioc.Default.GetRequiredService<IContentPageContext>();
15+
16+
public string Label { get; } = "Refresh".GetLocalizedResource();
17+
public string Description { get; } = "TODO";
18+
19+
public RichGlyph Glyph { get; } = new("\uE72C");
20+
21+
public HotKey HotKey { get; } = new(VirtualKey.R, VirtualKeyModifiers.Control);
22+
23+
public HotKey SecondHotKey { get; } = new(VirtualKey.F5);
24+
25+
public bool IsExecutable => context.CanRefresh;
26+
27+
public RefreshItemsAction()
28+
{
29+
context.PropertyChanged += Context_PropertyChanged;
30+
}
31+
32+
public async Task ExecuteAsync()
33+
{
34+
context.ShellPage?.Refresh_Click();
35+
}
36+
37+
private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
38+
{
39+
switch (e.PropertyName)
40+
{
41+
case nameof(IContentPageContext.CanRefresh):
42+
OnPropertyChanged(nameof(IsExecutable));
43+
break;
44+
}
45+
}
46+
}
47+
}

src/Files.App/Actions/Content/Run/RunAsAdminAction.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
using Files.App.Extensions;
66
using Files.App.Shell;
77
using Files.Backend.Helpers;
8-
using System;
9-
using System.Collections.Generic;
10-
using System.Linq;
11-
using System.Text;
128
using System.Threading.Tasks;
139

1410
namespace Files.App.Actions
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using Files.App.Commands;
2+
using Files.App.Extensions;
3+
using Microsoft.UI.Xaml.Controls.Primitives;
4+
using Microsoft.UI.Xaml.Input;
5+
using System.Threading.Tasks;
6+
using Windows.System;
7+
8+
namespace Files.App.Actions
9+
{
10+
internal class ToggleSelectAction : IAction
11+
{
12+
public string Label { get; } = "ToggleSelect".GetLocalizedResource();
13+
public string Description => "TODO: Need to be described.";
14+
15+
public HotKey HotKey { get; } = new(VirtualKey.Space, VirtualKeyModifiers.Control);
16+
17+
public bool IsExecutable => GetFocusedElement() is not null;
18+
19+
public Task ExecuteAsync()
20+
{
21+
if (GetFocusedElement() is SelectorItem item)
22+
{
23+
item.IsSelected = !item.IsSelected;
24+
}
25+
return Task.CompletedTask;
26+
}
27+
28+
private static SelectorItem? GetFocusedElement()
29+
{
30+
return FocusManager.GetFocusedElement(App.Window.Content.XamlRoot) as SelectorItem;
31+
}
32+
}
33+
}

src/Files.App/Actions/FileSystem/CopyPathAction.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using CommunityToolkit.Mvvm.ComponentModel;
2-
using CommunityToolkit.Mvvm.DependencyInjection;
1+
using CommunityToolkit.Mvvm.DependencyInjection;
32
using Files.App.Commands;
43
using Files.App.Contexts;
54
using Files.App.Extensions;
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
using CommunityToolkit.Mvvm.ComponentModel;
2+
using CommunityToolkit.Mvvm.DependencyInjection;
3+
using Files.App.Commands;
4+
using Files.App.Contexts;
5+
using Files.App.Extensions;
6+
using System.Threading.Tasks;
7+
using Windows.System;
8+
9+
namespace Files.App.Actions
10+
{
11+
internal class RenameAction : ObservableObject, IAction
12+
{
13+
private readonly IContentPageContext context = Ioc.Default.GetRequiredService<IContentPageContext>();
14+
15+
public string Label { get; } = "Rename".GetLocalizedResource();
16+
17+
public string Description { get; } = "TODO";
18+
19+
public HotKey HotKey { get; } = new(VirtualKey.F2);
20+
21+
public RichGlyph Glyph { get; } = new(opacityStyle: "ColorIconRename");
22+
23+
public bool IsExecutable =>
24+
context.ShellPage is not null &&
25+
IsPageTypeValid() &&
26+
context.ShellPage.SlimContentPage is not null &&
27+
IsSelectionValid();
28+
29+
public RenameAction()
30+
{
31+
context.PropertyChanged += Context_PropertyChanged;
32+
}
33+
34+
public Task ExecuteAsync()
35+
{
36+
context.ShellPage?.SlimContentPage?.ItemManipulationModel.StartRenameItem();
37+
return Task.CompletedTask;
38+
}
39+
40+
private void Context_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
41+
{
42+
switch (e.PropertyName)
43+
{
44+
case nameof(IContentPageContext.ShellPage):
45+
case nameof(IContentPageContext.PageType):
46+
case nameof(IContentPageContext.HasSelection):
47+
case nameof(IContentPageContext.SelectedItems):
48+
OnPropertyChanged(nameof(IsExecutable));
49+
break;
50+
}
51+
}
52+
53+
private bool IsSelectionValid()
54+
{
55+
return context.HasSelection && context.SelectedItems.Count == 1;
56+
}
57+
58+
private bool IsPageTypeValid()
59+
{
60+
return context.PageType is
61+
not ContentPageTypes.None and
62+
not ContentPageTypes.Home and
63+
not ContentPageTypes.RecycleBin and
64+
not ContentPageTypes.ZipFolder;
65+
}
66+
}
67+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using CommunityToolkit.Mvvm.ComponentModel;
2+
using CommunityToolkit.Mvvm.DependencyInjection;
3+
using Files.App.Commands;
4+
using Files.App.Contexts;
5+
using Files.App.Extensions;
6+
using System.ComponentModel;
7+
using System.Threading.Tasks;
8+
using Windows.System;
9+
10+
namespace Files.App.Actions
11+
{
12+
internal class NavigateBackAction : ObservableObject, IAction
13+
{
14+
private readonly IContentPageContext context = Ioc.Default.GetRequiredService<IContentPageContext>();
15+
16+
public string Label { get; } = "Back".GetLocalizedResource();
17+
18+
public string Description { get; } = "NavigateBack".GetLocalizedResource();
19+
20+
public HotKey HotKey { get; } = new(VirtualKey.Left, VirtualKeyModifiers.Menu);
21+
public HotKey SecondHotKey { get; } = new(VirtualKey.Back);
22+
public HotKey ThirdHotKey { get; } = new(VirtualKey.XButton1);
23+
public HotKey MediaHotKey { get; } = new(VirtualKey.GoBack);
24+
25+
public RichGlyph Glyph { get; } = new("\uE72B");
26+
27+
public bool IsExecutable => context.CanGoBack;
28+
29+
public NavigateBackAction()
30+
{
31+
context.PropertyChanged += Context_PropertyChanged;
32+
}
33+
34+
public Task ExecuteAsync()
35+
{
36+
context.ShellPage!.Back_Click();
37+
return Task.CompletedTask;
38+
}
39+
40+
private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
41+
{
42+
switch (e.PropertyName)
43+
{
44+
case nameof(IContentPageContext.CanGoBack):
45+
OnPropertyChanged(nameof(IsExecutable));
46+
break;
47+
}
48+
}
49+
}
50+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using CommunityToolkit.Mvvm.ComponentModel;
2+
using CommunityToolkit.Mvvm.DependencyInjection;
3+
using Files.App.Commands;
4+
using Files.App.Contexts;
5+
using Files.App.Extensions;
6+
using System.ComponentModel;
7+
using System.Threading.Tasks;
8+
using Windows.System;
9+
10+
namespace Files.App.Actions
11+
{
12+
internal class NavigateForwardAction : ObservableObject, IAction
13+
{
14+
private readonly IContentPageContext context = Ioc.Default.GetRequiredService<IContentPageContext>();
15+
16+
public string Label { get; } = "Forward".GetLocalizedResource();
17+
18+
public string Description { get; } = "NavigateForward".GetLocalizedResource();
19+
20+
public HotKey HotKey { get; } = new(VirtualKey.Right, VirtualKeyModifiers.Menu);
21+
public HotKey SecondHotKey { get; } = new(VirtualKey.XButton2);
22+
public HotKey MediaHotKey { get; } = new(VirtualKey.GoForward);
23+
24+
public RichGlyph Glyph { get; } = new("\uE72A");
25+
26+
public bool IsExecutable => context.CanGoForward;
27+
28+
public NavigateForwardAction()
29+
{
30+
context.PropertyChanged += Context_PropertyChanged;
31+
}
32+
33+
public Task ExecuteAsync()
34+
{
35+
context.ShellPage!.Forward_Click();
36+
return Task.CompletedTask;
37+
}
38+
39+
private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
40+
{
41+
switch (e.PropertyName)
42+
{
43+
case nameof(IContentPageContext.CanGoForward):
44+
OnPropertyChanged(nameof(IsExecutable));
45+
break;
46+
}
47+
}
48+
}
49+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+

2+
using CommunityToolkit.Mvvm.ComponentModel;
3+
using CommunityToolkit.Mvvm.DependencyInjection;
4+
using Files.App.Commands;
5+
using Files.App.Contexts;
6+
using Files.App.Extensions;
7+
using System.ComponentModel;
8+
using System.Threading.Tasks;
9+
using Windows.System;
10+
11+
namespace Files.App.Actions
12+
{
13+
internal class NavigateUpAction : ObservableObject, IAction
14+
{
15+
private readonly IContentPageContext context = Ioc.Default.GetRequiredService<IContentPageContext>();
16+
17+
public string Label { get; } = "Up".GetLocalizedResource();
18+
19+
public string Description { get; } = "NavigateUp".GetLocalizedResource();
20+
21+
public HotKey HotKey { get; } = new(VirtualKey.Up, VirtualKeyModifiers.Menu);
22+
23+
public RichGlyph Glyph { get; } = new("\uE74A");
24+
25+
public bool IsExecutable => context.CanNavigateToParent;
26+
27+
public NavigateUpAction()
28+
{
29+
context.PropertyChanged += Context_PropertyChanged;
30+
}
31+
32+
public Task ExecuteAsync()
33+
{
34+
context.ShellPage!.Up_Click();
35+
return Task.CompletedTask;
36+
}
37+
38+
private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
39+
{
40+
switch (e.PropertyName)
41+
{
42+
case nameof(IContentPageContext.CanNavigateToParent):
43+
OnPropertyChanged(nameof(IsExecutable));
44+
break;
45+
}
46+
}
47+
}
48+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using CommunityToolkit.Mvvm.ComponentModel;
2+
using CommunityToolkit.Mvvm.DependencyInjection;
3+
using Files.App.Commands;
4+
using Files.App.Contexts;
5+
using Files.App.Extensions;
6+
using Files.App.UserControls.MultitaskingControl;
7+
using System.ComponentModel;
8+
using System.Threading.Tasks;
9+
using Windows.System;
10+
11+
namespace Files.App.Actions
12+
{
13+
internal class ReopenClosedTabAction : ObservableObject, IAction
14+
{
15+
private readonly IMultitaskingContext context = Ioc.Default.GetRequiredService<IMultitaskingContext>();
16+
17+
public string Label { get; } = "ReopenClosedTab".GetLocalizedResource();
18+
19+
public string Description { get; } = "TODO: Need to be described";
20+
21+
public HotKey HotKey { get; } = new(VirtualKey.T, VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift);
22+
23+
public bool IsExecutable =>
24+
context.Control is not null &&
25+
!BaseMultitaskingControl.IsRestoringClosedTab &&
26+
BaseMultitaskingControl.RecentlyClosedTabs.Count > 0;
27+
28+
public ReopenClosedTabAction()
29+
{
30+
context.PropertyChanged += Context_PropertyChanged;
31+
BaseMultitaskingControl.StaticPropertyChanged += BaseMultitaskingControl_StaticPropertyChanged;
32+
}
33+
34+
public Task ExecuteAsync()
35+
{
36+
context.Control!.ReopenClosedTab();
37+
return Task.CompletedTask;
38+
}
39+
40+
private void Context_PropertyChanged(object? _, PropertyChangedEventArgs e)
41+
{
42+
if (e.PropertyName is nameof(IMultitaskingContext.Control))
43+
OnPropertyChanged(nameof(IsExecutable));
44+
}
45+
46+
private void BaseMultitaskingControl_StaticPropertyChanged(object? sender, PropertyChangedEventArgs e)
47+
{
48+
OnPropertyChanged(nameof(IsExecutable));
49+
}
50+
}
51+
}

0 commit comments

Comments
 (0)