Skip to content

Commit

Permalink
Merge branch 'main' into fix-selection-cancel-after-upper-arrow-key
Browse files Browse the repository at this point in the history
  • Loading branch information
RieBi authored Nov 17, 2023
2 parents a83a610 + e483b6c commit 0269eb7
Show file tree
Hide file tree
Showing 124 changed files with 2,083 additions and 1,011 deletions.
2 changes: 1 addition & 1 deletion src/Files.App (Package)/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<Identity
Name="FilesDev"
Publisher="CN=Files"
Version="3.0.3.0" />
Version="3.0.8.0" />

<Properties>
<DisplayName>Files - Dev</DisplayName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using Files.App.Dialogs;
using Microsoft.UI.Xaml.Controls;
using Windows.Foundation.Metadata;

namespace Files.App.Actions
{
Expand Down Expand Up @@ -30,6 +31,9 @@ public override async Task ExecuteAsync()
FileName = fileName,
};

if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
dialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;

var result = await dialog.TryShowAsync();

if (!dialog.CanCreate || result != ContentDialogResult.Primary)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public override RichGlyph Glyph
public override Task ExecuteAsync()
{
if (context.SelectedItem is not null)
WallpaperHelpers.SetAsBackgroundAsync(WallpaperType.LockScreen, context.SelectedItem.ItemPath);
return WallpaperHelpers.SetAsBackgroundAsync(WallpaperType.LockScreen, context.SelectedItem.ItemPath);

return Task.CompletedTask;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public override RichGlyph Glyph
public override Task ExecuteAsync()
{
if (context.SelectedItem is not null)
WallpaperHelpers.SetAsBackgroundAsync(WallpaperType.Desktop, context.SelectedItem.ItemPath);
return WallpaperHelpers.SetAsBackgroundAsync(WallpaperType.Desktop, context.SelectedItem.ItemPath);

return Task.CompletedTask;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ internal abstract class BaseRotateAction : ObservableObject, IAction
{
private readonly IContentPageContext context;

private readonly PreviewPaneViewModel _previewPaneViewModel;
private readonly InfoPaneViewModel _infoPaneViewModel;

public abstract string Label { get; }

Expand All @@ -26,7 +26,7 @@ internal abstract class BaseRotateAction : ObservableObject, IAction
public BaseRotateAction()
{
context = Ioc.Default.GetRequiredService<IContentPageContext>();
_previewPaneViewModel = Ioc.Default.GetRequiredService<PreviewPaneViewModel>();
_infoPaneViewModel = Ioc.Default.GetRequiredService<InfoPaneViewModel>();

context.PropertyChanged += Context_PropertyChanged;
}
Expand All @@ -38,7 +38,7 @@ public async Task ExecuteAsync()

context.ShellPage?.SlimContentPage?.ItemManipulationModel?.RefreshItemsThumbnail();

await _previewPaneViewModel.UpdateSelectedItemPreviewAsync();
await _infoPaneViewModel.UpdateSelectedItemPreviewAsync();
}

private bool IsContextPageTypeAdaptedToCommand()
Expand Down
16 changes: 15 additions & 1 deletion src/Files.App/Actions/Content/Selection/InvertSelectionAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Files.App.Actions
{
internal class InvertSelectionAction : IAction
internal class InvertSelectionAction : ObservableObject, IAction
{
private readonly IContentPageContext context;

Expand Down Expand Up @@ -41,6 +41,8 @@ public bool IsExecutable
public InvertSelectionAction()
{
context = Ioc.Default.GetRequiredService<IContentPageContext>();

context.PropertyChanged += Context_PropertyChanged;
}

public Task ExecuteAsync()
Expand All @@ -49,5 +51,17 @@ public Task ExecuteAsync()

return Task.CompletedTask;
}

private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
switch (e.PropertyName)
{
case nameof(IContentPageContext.PageType):
case nameof(IContentPageContext.HasItem):
case nameof(IContentPageContext.ShellPage):
OnPropertyChanged(nameof(IsExecutable));
break;
}
}
}
}
2 changes: 1 addition & 1 deletion src/Files.App/Actions/Content/Selection/SelectAllAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public bool IsExecutable

bool isCommandPaletteOpen = page.ToolbarViewModel.IsCommandPaletteOpen;
bool isEditing = page.ToolbarViewModel.IsEditModeEnabled;
bool isRenaming = page.SlimContentPage.IsRenamingItem;
bool isRenaming = page.SlimContentPage?.IsRenamingItem ?? false;

return isCommandPaletteOpen || (!isEditing && !isRenaming);
}
Expand Down
2 changes: 2 additions & 0 deletions src/Files.App/Actions/FileSystem/AddItemAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ await UIFilesystemHelpers.CreateFileFromDialogResultTypeAsync(
viewModel.ResultType.ItemInfo,
context.ShellPage!);
}

viewModel.ResultType.ItemType = AddItemDialogItemType.Cancel;
}

private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
Expand Down
5 changes: 4 additions & 1 deletion src/Files.App/Actions/FileSystem/OpenItemAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ public OpenItemAction()

public Task ExecuteAsync()
{
return NavigationHelpers.OpenSelectedItemsAsync(context.ShellPage);
if (context.ShellPage is not null)
return NavigationHelpers.OpenSelectedItemsAsync(context.ShellPage);

return Task.CompletedTask;
}

private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
Expand Down
3 changes: 3 additions & 0 deletions src/Files.App/Actions/Navigation/OpenInNewWindowItemAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ public string Label
public string Description
=> "OpenInNewWindowDescription".GetLocalizedResource();

public HotKey HotKey
=> new(Keys.Enter, KeyModifiers.MenuCtrl);

public RichGlyph Glyph
=> new(opacityStyle: "ColorIconOpenInNewWindow");

Expand Down
10 changes: 5 additions & 5 deletions src/Files.App/Actions/Show/ToggleDetailsPaneAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ namespace Files.App.Actions
{
internal class ToggleDetailsPaneAction : ObservableObject, IToggleAction
{
private readonly PreviewPaneViewModel viewModel;
private readonly IPreviewPaneSettingsService previewSettingsService = Ioc.Default.GetRequiredService<IPreviewPaneSettingsService>();
private readonly InfoPaneViewModel viewModel;
private readonly IInfoPaneSettingsService infoPaneSettingsService = Ioc.Default.GetRequiredService<IInfoPaneSettingsService>();

public string Label
=> "ToggleDetailsPane".GetLocalizedResource();
Expand All @@ -25,21 +25,21 @@ public bool IsOn

public ToggleDetailsPaneAction()
{
viewModel = Ioc.Default.GetRequiredService<PreviewPaneViewModel>();
viewModel = Ioc.Default.GetRequiredService<InfoPaneViewModel>();
viewModel.PropertyChanged += ViewModel_PropertyChanged;
}

public Task ExecuteAsync()
{
viewModel.IsEnabled = true;
previewSettingsService.ShowPreviewOnly = false;
infoPaneSettingsService.SelectedTab = InfoPaneTabs.Details;

return Task.CompletedTask;
}

private void ViewModel_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName is nameof(PreviewPaneViewModel.IsEnabled))
if (e.PropertyName is nameof(InfoPaneViewModel.IsEnabled))
OnPropertyChanged(nameof(IsOn));
}
}
Expand Down
9 changes: 6 additions & 3 deletions src/Files.App/Actions/Show/ToggleInfoPaneAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Files.App.Actions
{
internal class ToggleInfoPaneAction : ObservableObject, IToggleAction
{
private readonly PreviewPaneViewModel viewModel;
private readonly InfoPaneViewModel viewModel;

public string Label
=> "ToggleInfoPane".GetLocalizedResource();
Expand All @@ -16,12 +16,15 @@ public string Description
public RichGlyph Glyph
=> new(opacityStyle: "ColorIconRightPane");

public HotKey HotKey
=> new(Keys.I, KeyModifiers.MenuCtrl);

public bool IsOn
=> viewModel.IsEnabled;

public ToggleInfoPaneAction()
{
viewModel = Ioc.Default.GetRequiredService<PreviewPaneViewModel>();
viewModel = Ioc.Default.GetRequiredService<InfoPaneViewModel>();
viewModel.PropertyChanged += ViewModel_PropertyChanged;
}

Expand All @@ -34,7 +37,7 @@ public Task ExecuteAsync()

private void ViewModel_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName is nameof(PreviewPaneViewModel.IsEnabled))
if (e.PropertyName is nameof(InfoPaneViewModel.IsEnabled))
OnPropertyChanged(nameof(IsOn));
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/Files.App/Actions/Show/TogglePreviewPaneAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ namespace Files.App.Actions
{
internal class TogglePreviewPaneAction : ObservableObject, IToggleAction
{
private readonly PreviewPaneViewModel viewModel;
private readonly IPreviewPaneSettingsService previewSettingsService = Ioc.Default.GetRequiredService<IPreviewPaneSettingsService>();
private readonly InfoPaneViewModel viewModel;
private readonly IInfoPaneSettingsService infoPaneSettingsService = Ioc.Default.GetRequiredService<IInfoPaneSettingsService>();

public string Label
=> "TogglePreviewPane".GetLocalizedResource();
Expand All @@ -25,21 +25,21 @@ public bool IsOn

public TogglePreviewPaneAction()
{
viewModel = Ioc.Default.GetRequiredService<PreviewPaneViewModel>();
viewModel = Ioc.Default.GetRequiredService<InfoPaneViewModel>();
viewModel.PropertyChanged += ViewModel_PropertyChanged;
}

public Task ExecuteAsync()
{
viewModel.IsEnabled = true;
previewSettingsService.ShowPreviewOnly = true;
infoPaneSettingsService.SelectedTab = InfoPaneTabs.Preview;

return Task.CompletedTask;
}

private void ViewModel_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName is nameof(PreviewPaneViewModel.IsEnabled))
if (e.PropertyName is nameof(InfoPaneViewModel.IsEnabled))
OnPropertyChanged(nameof(IsOn));
}
}
Expand Down
17 changes: 15 additions & 2 deletions src/Files.App/Actions/Start/PinToStartAction.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using CommunityToolkit.Mvvm.DependencyInjection;
using Files.Core.Storage;

namespace Files.App.Actions
{
internal class PinToStartAction : IAction
{
private IStorageService StorageService { get; } = Ioc.Default.GetRequiredService<IStorageService>();

private IStartMenuService StartMenuService { get; } = Ioc.Default.GetRequiredService<IStartMenuService>();

public IContentPageContext context;

public string Label
Expand All @@ -29,11 +36,17 @@ public async Task ExecuteAsync()
if (context.SelectedItems.Count > 0 && context.ShellPage?.SlimContentPage?.SelectedItems is not null)
{
foreach (ListedItem listedItem in context.ShellPage.SlimContentPage.SelectedItems)
await App.SecondaryTileHelper.TryPinFolderAsync(listedItem.ItemPath, listedItem.Name);
{
var folder = await StorageService.GetFolderAsync(listedItem.ItemPath);
await StartMenuService.PinAsync(folder, listedItem.Name);
}
}
else if (context.ShellPage?.FilesystemViewModel?.CurrentFolder is not null)
{
await App.SecondaryTileHelper.TryPinFolderAsync(context.ShellPage.FilesystemViewModel.CurrentFolder.ItemPath, context.ShellPage.FilesystemViewModel.CurrentFolder.Name);
var currentFolder = context.ShellPage.FilesystemViewModel.CurrentFolder;
var folder = await StorageService.GetFolderAsync(currentFolder.ItemPath);

await StartMenuService.PinAsync(folder, currentFolder.Name);
}
}
}
Expand Down
16 changes: 14 additions & 2 deletions src/Files.App/Actions/Start/UnpinFromStartAction.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.Core.Storage;

namespace Files.App.Actions
{
internal class UnpinFromStartAction : IAction
{
private IStorageService StorageService { get; } = Ioc.Default.GetRequiredService<IStorageService>();

private IStartMenuService StartMenuService { get; } = Ioc.Default.GetRequiredService<IStartMenuService>();

public IContentPageContext context;

public string Label
Expand All @@ -26,11 +32,17 @@ public async Task ExecuteAsync()
if (context.SelectedItems.Count > 0)
{
foreach (ListedItem listedItem in context.ShellPage?.SlimContentPage.SelectedItems)
await App.SecondaryTileHelper.UnpinFromStartAsync(listedItem.ItemPath);
{
var folder = await StorageService.GetFolderAsync(listedItem.ItemPath);
await StartMenuService.UnpinAsync(folder);
}
}
else
{
await App.SecondaryTileHelper.UnpinFromStartAsync(context.ShellPage?.FilesystemViewModel.CurrentFolder.ItemPath);
var currentFolder = context.ShellPage.FilesystemViewModel.CurrentFolder;
var folder = await StorageService.GetFolderAsync(currentFolder.ItemPath);

await StartMenuService.UnpinAsync(folder);
}
}
}
Expand Down
Loading

0 comments on commit 0269eb7

Please sign in to comment.