Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/Files.App/Actions/Content/Archives/DecompressArchive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
using Files.App.Contexts;
using Files.App.Extensions;
using Files.App.Helpers;
using Files.Backend.Helpers;
using System.ComponentModel;
using System.IO;
using System.Threading.Tasks;

namespace Files.App.Actions
Expand All @@ -19,8 +21,9 @@ internal class DecompressArchive : BaseUIAction, IAction
public HotKey HotKey { get; } = new(Keys.E, KeyModifiers.Ctrl);

public override bool IsExecutable =>
IsContextPageTypeAdaptedToCommand() &&
ArchiveHelpers.CanDecompress(context.SelectedItems) &&
(IsContextPageTypeAdaptedToCommand() &&
ArchiveHelpers.CanDecompress(context.SelectedItems)
|| CanDecompressInsideArchive()) &&
UIHelpers.CanShowDialog;

public DecompressArchive()
Expand All @@ -40,13 +43,20 @@ and not ContentPageTypes.ZipFolder
and not ContentPageTypes.None;
}

private bool CanDecompressInsideArchive()
{
return context.PageType is ContentPageTypes.ZipFolder &&
!context.HasSelection &&
context.Folder is not null &&
FileExtensionHelpers.IsZipFile(Path.GetExtension(context.Folder.ItemPath));
}

private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
switch (e.PropertyName)
{
case nameof(IContentPageContext.SelectedItems):
if (IsContextPageTypeAdaptedToCommand())
OnPropertyChanged(nameof(IsExecutable));
OnPropertyChanged(nameof(IsExecutable));
break;
}
}
Expand Down