Skip to content

Feature: Added option to restore all items in recycle bin #9795

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
ebe915e
Adding Restore action in recycle bin contextual menu when not selecti…
QuaintMako Aug 18, 2022
4c1ff5e
Removed the submenu for Restore Recycle Bin
QuaintMako Aug 18, 2022
892c8c8
[WIP] Creating the command for the Recycle bin restoration.
QuaintMako Aug 18, 2022
cf6ec01
Revert "[WIP] Creating the command for the Recycle bin restoration."
QuaintMako Aug 19, 2022
c26ebfe
Restore recycle bin now works correctly in a first draft.
QuaintMako Aug 19, 2022
6b193ba
Using the Restore Item command in the Restore Recycle Bin command do …
QuaintMako Aug 19, 2022
37877f6
Created the required localizations.
QuaintMako Aug 19, 2022
7e744c0
Added Restore Recycle Bin action to the toolbar view model.
QuaintMako Aug 19, 2022
53aad16
Found a better suited icon for restore.
QuaintMako Aug 22, 2022
266b811
Set new icon and changed label name.
QuaintMako Aug 26, 2022
07e7c87
Removed wrongfully pushed files.
QuaintMako Aug 26, 2022
442415e
Restore and empty actions buttons are now reevaluted when selecting i…
QuaintMako Aug 28, 2022
6969c52
Added a Restore Selection action (not implemented yet) button + did s…
QuaintMako Aug 29, 2022
2f94219
Restoring a selection of items via the inner navigation toolbar is no…
QuaintMako Aug 29, 2022
37827ab
Merge branch 'main' into 9561_NoRestoreActionInRecycleBin
QuaintMako Aug 29, 2022
ccda69e
Removed <SubType> attribute wrongfully pushed.
QuaintMako Aug 29, 2022
bdba097
Removed another <SubType> attribute.
QuaintMako Aug 29, 2022
0dae095
Removed instruction wrongfully brought back during merge.
QuaintMako Aug 29, 2022
afb9ed3
[WIP] Empty a selection of file in the recycle bin is under way.
QuaintMako Aug 29, 2022
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
6 changes: 2 additions & 4 deletions src/Files.Uwp/Files.Uwp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -1127,9 +1127,7 @@
<PRIResource Include="Strings\de-DE\Resources.resw" />
<PRIResource Include="Strings\es-ES\Resources.resw" />
<PRIResource Include="Strings\fr-FR\Resources.resw" />
<PRIResource Include="Strings\en-US\Resources.resw">
<SubType>Designer</SubType>
</PRIResource>
<PRIResource Include="Strings\en-US\Resources.resw" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
Expand Down Expand Up @@ -1684,4 +1682,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
8 changes: 8 additions & 0 deletions src/Files.Uwp/Helpers/ContextFlyoutItemHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,14 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseLayoutMenuItems(Curren
ShowInRecycleBin = true,
},
new ContextMenuFlyoutItemViewModel()
{
Text = "RestoreRecycleBin".GetLocalized(),
Glyph = "\xE10D",
Command = commandsViewModel.RestoreRecycleBinCommand,
ShowItem = currentInstanceViewModel.IsPageTypeRecycleBin,
ShowInRecycleBin = true,
},
new ContextMenuFlyoutItemViewModel()
{
ItemType = ItemType.Separator,
Tag = "OverflowSeparator",
Expand Down
20 changes: 20 additions & 0 deletions src/Files.Uwp/Interacts/BaseLayoutCommandImplementationModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,26 @@ public virtual async void EmptyRecycleBin(RoutedEventArgs e)
await RecycleBinHelpers.S_EmptyRecycleBin();
}

public virtual async void RestoreRecycleBin(RoutedEventArgs e)
{
var ConfirmEmptyBinDialog = new ContentDialog()
{
Title = "ConfirmRestoreBinDialogTitle".GetLocalized(),
Content = "ConfirmRestoreBinDialogContent".GetLocalized(),
PrimaryButtonText = "Yes".GetLocalized(),
SecondaryButtonText = "Cancel".GetLocalized(),
DefaultButton = ContentDialogButton.Primary
};

ContentDialogResult result = await ConfirmEmptyBinDialog.ShowAsync();

if (result == ContentDialogResult.Primary)
{
SlimContentPage.ItemManipulationModel.SelectAllItems();
this.RestoreItem(e);
}
}

public virtual async void QuickLook(RoutedEventArgs e)
{
await QuickLookHelpers.ToggleQuickLook(associatedInstance);
Expand Down
5 changes: 5 additions & 0 deletions src/Files.Uwp/Interacts/BaseLayoutCommandsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ private void InitializeCommands()
UnpinDirectoryFromFavoritesCommand = new RelayCommand<RoutedEventArgs>(CommandsModel.UnpinDirectoryFromFavorites);
OpenItemCommand = new RelayCommand<RoutedEventArgs>(CommandsModel.OpenItem);
EmptyRecycleBinCommand = new RelayCommand<RoutedEventArgs>(CommandsModel.EmptyRecycleBin);
RestoreRecycleBinCommand = new RelayCommand<RoutedEventArgs>(CommandsModel.RestoreRecycleBin);
QuickLookCommand = new RelayCommand<RoutedEventArgs>(CommandsModel.QuickLook);
CopyItemCommand = new RelayCommand<RoutedEventArgs>(CommandsModel.CopyItem);
CutItemCommand = new RelayCommand<RoutedEventArgs>(CommandsModel.CutItem);
Expand Down Expand Up @@ -107,6 +108,10 @@ private void InitializeCommands()

public ICommand EmptyRecycleBinCommand { get; private set; }

public ICommand EmptySelectionRecycleBinCommand { get; private set; }

public ICommand RestoreRecycleBinCommand { get; private set; }

public ICommand QuickLookCommand { get; private set; }

public ICommand CopyItemCommand { get; private set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public interface IBaseLayoutCommandImplementationModel : IDisposable

void EmptyRecycleBin(RoutedEventArgs e);

void RestoreRecycleBin(RoutedEventArgs e);

void QuickLook(RoutedEventArgs e);

void CopyItem(RoutedEventArgs e);
Expand Down
17 changes: 16 additions & 1 deletion src/Files.Uwp/Strings/en-GB/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,12 @@
<data name="ConfirmEmptyBinDialogTitle" xml:space="preserve">
<value>Empty recycle bin</value>
</data>
<data name="ConfirmRestoreBinDialogContent" xml:space="preserve">
<value>Are you sure you want to restore all these items?</value>
</data>
<data name="ConfirmRestoreBinDialogTitle" xml:space="preserve">
<value>Restore recycle bin</value>
</data>
<data name="ItemSizeBytes" xml:space="preserve">
<value>bytes</value>
</data>
Expand Down Expand Up @@ -2516,7 +2522,16 @@ We use App Center to keep track of app usage, find bugs, and fix crashes. All in
<value>Error importing settings</value>
</data>
<data name="EmptyRecycleBin" xml:space="preserve">
<value>Empty Recycle Bin</value>
<value>Empty recycle bin</value>
</data>
<data name="EmptySelectionRecycleBin" xml:space="preserve">
<value>Empty selection</value>
</data>
<data name="RestoreAllItemsRecycleBin" xml:space="preserve">
<value>Restore recycle bin</value>
</data>
<data name="RestoreSelectionRecycleBin" xml:space="preserve">
<value>Restore selection</value>
</data>
<data name="Sidebar" xml:space="preserve">
<value>Sidebar</value>
Expand Down
42 changes: 40 additions & 2 deletions src/Files.Uwp/UserControls/InnerNavigationToolbar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,52 @@
x:Name="EmptyRecycleBinButton"
x:Load="{x:Bind ViewModel.InstanceViewModel.IsPageTypeRecycleBin, Mode=OneWay, FallbackValue=False}"
AccessKey="B"
Command="{x:Bind ViewModel.EmptyRecycleBinCommand, Mode=OneWay}"
IsEnabled="{x:Bind ViewModel.CanEmptyRecycleBin, Mode=OneWay}"
Command="{x:Bind ViewModel.EmptyAllFilesRecycleBinCommand, Mode=OneWay}"
IsEnabled="{x:Bind ViewModel.CanEmptyAllItemsRecycleBin, Mode=OneWay}"
Label="{helpers:ResourceString Name=EmptyRecycleBin}"
ToolTipService.ToolTip="{helpers:ResourceString Name=EmptyRecycleBin}">
<AppBarButton.Icon>
<FontIcon FontFamily="{StaticResource RecycleBinIcons}" Glyph="&#xEF88;" />
</AppBarButton.Icon>
</AppBarButton>
<AppBarButton
x:Name="EmptySelectionRecycleBin"
x:Load="{x:Bind ViewModel.InstanceViewModel.IsPageTypeRecycleBin, Mode=OneWay, FallbackValue=False}"
AccessKey="B"
Command="{x:Bind ViewModel.EmptySelectionRecycleBinCommand, Mode=OneWay}"
IsEnabled="{x:Bind ViewModel.CanEmptySelectionRecycleBin, Mode=OneWay}"
Label="{helpers:ResourceString Name=EmptySelectionRecycleBin}"
ToolTipService.ToolTip="{helpers:ResourceString Name=EmptySelectionRecycleBin}">
<AppBarButton.Icon>
<FontIcon FontFamily="{StaticResource RecycleBinIcons}" Glyph="&#xEF88;" />
</AppBarButton.Icon>
</AppBarButton>
<AppBarButton
x:Name="RestoreRecycleBinButton"
x:Load="{x:Bind ViewModel.InstanceViewModel.IsPageTypeRecycleBin, Mode=OneWay, FallbackValue=False}"
AccessKey="R"
Command="{x:Bind ViewModel.RestoreAllItemsRecycleBinCommand, Mode=OneWay}"
IsEnabled="{x:Bind ViewModel.CanRestoreAllItemsRecycleBin, Mode=OneWay}"
Visibility="{x:Bind ViewModel.CanRestoreAllItemsRecycleBin, Mode=OneWay}"
Label="{helpers:ResourceString Name=RestoreAllItemsRecycleBin}"
ToolTipService.ToolTip="{helpers:ResourceString Name=RestoreAllItemsRecycleBin}">
<AppBarButton.Icon>
<FontIcon Glyph="&#xE845;" />
</AppBarButton.Icon>
</AppBarButton>
<AppBarButton
x:Name="RestoreSelectionRecycleBinButton"
x:Load="{x:Bind ViewModel.InstanceViewModel.IsPageTypeRecycleBin, Mode=OneWay, FallbackValue=False}"
AccessKey="R"
Command="{x:Bind ViewModel.RestoreSelectionRecycleBinCommand, Mode=OneWay}"
IsEnabled="{x:Bind ViewModel.CanRestoreSelectionRecycleBin, Mode=OneWay}"
Visibility="{x:Bind ViewModel.CanRestoreSelectionRecycleBin, Mode=OneWay}"
Label="{helpers:ResourceString Name=RestoreSelectionRecycleBin}"
ToolTipService.ToolTip="{helpers:ResourceString Name=RestoreSelectionRecycleBin}">
<AppBarButton.Icon>
<FontIcon Glyph="&#xE845;" />
</AppBarButton.Icon>
</AppBarButton>
<AppBarButton
x:Name="ExtractButton"
Width="Auto"
Expand Down
27 changes: 23 additions & 4 deletions src/Files.Uwp/ViewModels/ToolbarViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,10 @@ public void SwitchSearchBoxVisibility()
public void UpdateAdditionalActions()
{
OnPropertyChanged(nameof(HasAdditionalAction));
OnPropertyChanged(nameof(CanEmptyRecycleBin));
OnPropertyChanged(nameof(CanEmptyAllItemsRecycleBin));
OnPropertyChanged(nameof(CanEmptySelectionRecycleBin));
OnPropertyChanged(nameof(CanRestoreAllItemsRecycleBin));
OnPropertyChanged(nameof(CanRestoreSelectionRecycleBin));
}

private AddressToolbar AddressToolbar => (Window.Current.Content as Frame).FindDescendant<AddressToolbar>();
Expand Down Expand Up @@ -875,7 +878,13 @@ public void SearchRegion_LostFocus(object sender, RoutedEventArgs e)

public ICommand CutCommand { get; set; }

public ICommand EmptyRecycleBinCommand { get; set; }
public ICommand EmptyAllFilesRecycleBinCommand { get; set; }

public ICommand EmptySelectionRecycleBinCommand { get; set; }

public ICommand RestoreAllItemsRecycleBinCommand { get; set; }

public ICommand RestoreSelectionRecycleBinCommand { get; set; }

public ICommand PropertiesCommand { get; set; }

Expand Down Expand Up @@ -1207,7 +1216,10 @@ public bool HasItem
{
if (SetProperty(ref hasItem, value))
{
OnPropertyChanged(nameof(CanEmptyRecycleBin));
OnPropertyChanged(nameof(CanEmptyAllItemsRecycleBin));
OnPropertyChanged(nameof(CanEmptySelectionRecycleBin));
OnPropertyChanged(nameof(CanRestoreAllItemsRecycleBin));
OnPropertyChanged(nameof(CanRestoreSelectionRecycleBin));
}
}
}
Expand All @@ -1233,6 +1245,10 @@ public List<ListedItem> SelectedItems
OnPropertyChanged(nameof(IsMultipleImageSelected));
OnPropertyChanged(nameof(IsFont));
OnPropertyChanged(nameof(HasAdditionalAction));
OnPropertyChanged(nameof(CanEmptyAllItemsRecycleBin));
OnPropertyChanged(nameof(CanEmptySelectionRecycleBin));
OnPropertyChanged(nameof(CanRestoreAllItemsRecycleBin));
OnPropertyChanged(nameof(CanRestoreSelectionRecycleBin));
}
}
}
Expand All @@ -1242,7 +1258,10 @@ public List<ListedItem> SelectedItems
public bool CanShare => SelectedItems is not null && SelectedItems.Any() && DataTransferManager.IsSupported() && !SelectedItems.Any(x => (x.IsShortcutItem && !x.IsLinkItem) || x.IsHiddenItem || (x.PrimaryItemAttribute == StorageItemTypes.Folder && !x.IsZipItem));
public bool CanRename => SelectedItems is not null && SelectedItems.Count == 1;
public bool CanViewProperties => SelectedItems is not null && SelectedItems.Any();
public bool CanEmptyRecycleBin => InstanceViewModel.IsPageTypeRecycleBin && HasItem;
public bool CanEmptyAllItemsRecycleBin => InstanceViewModel.IsPageTypeRecycleBin && HasItem && (SelectedItems is null || SelectedItems is not null && SelectedItems.Count == 0);
public bool CanEmptySelectionRecycleBin => InstanceViewModel.IsPageTypeRecycleBin && HasItem && SelectedItems is not null && SelectedItems is not null && SelectedItems.Count > 0;
public bool CanRestoreAllItemsRecycleBin => InstanceViewModel.IsPageTypeRecycleBin && HasItem && (SelectedItems is null || SelectedItems is not null && SelectedItems.Count == 0);
public bool CanRestoreSelectionRecycleBin => InstanceViewModel.IsPageTypeRecycleBin && HasItem && SelectedItems is not null && SelectedItems is not null && SelectedItems.Count > 0;
public bool CanExtract => SelectedItems is not null && SelectedItems.Count == 1 && FileExtensionHelpers.IsZipFile(SelectedItems.First().FileExtension) && !InstanceViewModel.IsPageTypeRecycleBin;
public string ExtractToText => SelectedItems is not null && SelectedItems.Count == 1 ? string.Format("ExtractToChildFolder".GetLocalized() + "\\", Path.GetFileNameWithoutExtension(selectedItems.First().ItemName)) : "ExtractToChildFolder".GetLocalized();
public bool IsPowerShellScript => SelectedItems is not null && SelectedItems.Count == 1 && FileExtensionHelpers.IsPowerShellFile(SelectedItems.First().FileExtension) && !InstanceViewModel.IsPageTypeRecycleBin;
Expand Down
5 changes: 4 additions & 1 deletion src/Files.Uwp/Views/ColumnShellPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,10 @@ private void InitToolbarCommands()
ToolbarViewModel.Share = new RelayCommand(() => SlimContentPage?.CommandsViewModel.ShareItemCommand.Execute(null));
ToolbarViewModel.DeleteCommand = new RelayCommand(() => SlimContentPage?.CommandsViewModel.DeleteItemCommand.Execute(null));
ToolbarViewModel.CutCommand = new RelayCommand(() => SlimContentPage?.CommandsViewModel.CutItemCommand.Execute(null));
ToolbarViewModel.EmptyRecycleBinCommand = new RelayCommand(() => SlimContentPage?.CommandsViewModel.EmptyRecycleBinCommand.Execute(null));
ToolbarViewModel.EmptyAllFilesRecycleBinCommand = new RelayCommand(() => SlimContentPage?.CommandsViewModel.EmptyRecycleBinCommand.Execute(null));
ToolbarViewModel.EmptySelectionRecycleBinCommand = new RelayCommand(() => SlimContentPage?.CommandsViewModel.EmptySelectedItemsRecycleBin.Execute(null));
ToolbarViewModel.RestoreAllItemsRecycleBinCommand = new RelayCommand(() => SlimContentPage?.CommandsViewModel.RestoreRecycleBinCommand.Execute(null));
ToolbarViewModel.RestoreSelectionRecycleBinCommand = new RelayCommand(() => SlimContentPage?.CommandsViewModel.RestoreItemCommand.Execute(null));
ToolbarViewModel.RunWithPowerShellCommand = new RelayCommand(async () => await Win32Helpers.InvokeWin32ComponentAsync("powershell", this, PathNormalization.NormalizePath(SlimContentPage?.SelectedItem.ItemPath)));
ToolbarViewModel.PropertiesCommand = new RelayCommand(() => SlimContentPage?.CommandsViewModel.ShowPropertiesCommand.Execute(null));
ToolbarViewModel.SetAsBackgroundCommand = new RelayCommand(() => SlimContentPage?.CommandsViewModel.SetAsDesktopBackgroundItemCommand.Execute(null));
Expand Down
5 changes: 4 additions & 1 deletion src/Files.Uwp/Views/ModernShellPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,10 @@ private void InitToolbarCommands()
ToolbarViewModel.Share = new RelayCommand(() => SlimContentPage?.CommandsViewModel.ShareItemCommand.Execute(null));
ToolbarViewModel.DeleteCommand = new RelayCommand(() => SlimContentPage?.CommandsViewModel.DeleteItemCommand.Execute(null));
ToolbarViewModel.CutCommand = new RelayCommand(() => SlimContentPage?.CommandsViewModel.CutItemCommand.Execute(null));
ToolbarViewModel.EmptyRecycleBinCommand = new RelayCommand(() => SlimContentPage?.CommandsViewModel.EmptyRecycleBinCommand.Execute(null));
ToolbarViewModel.EmptyAllFilesRecycleBinCommand = new RelayCommand(() => SlimContentPage?.CommandsViewModel.EmptyRecycleBinCommand.Execute(null));
ToolbarViewModel.EmptySelectionRecycleBinCommand = new RelayCommand(() => SlimContentPage?.CommandsViewModel.EmptySelectedItemsRecycleBin.Execute(null));
ToolbarViewModel.RestoreAllItemsRecycleBinCommand = new RelayCommand(() => SlimContentPage?.CommandsViewModel.RestoreRecycleBinCommand.Execute(null));
ToolbarViewModel.RestoreSelectionRecycleBinCommand = new RelayCommand(() => SlimContentPage?.CommandsViewModel.RestoreItemCommand.Execute(null));
ToolbarViewModel.RunWithPowerShellCommand = new RelayCommand(async () => await Win32Helpers.InvokeWin32ComponentAsync("powershell", this, PathNormalization.NormalizePath(SlimContentPage?.SelectedItem.ItemPath)));
ToolbarViewModel.PropertiesCommand = new RelayCommand(() => SlimContentPage?.CommandsViewModel.ShowPropertiesCommand.Execute(null));
ToolbarViewModel.SetAsBackgroundCommand = new RelayCommand(() => SlimContentPage?.CommandsViewModel.SetAsDesktopBackgroundItemCommand.Execute(null));
Expand Down