Tracker: Disallow Restore from Trash if no selection

TargetVolumeIsReadOnly() doesn't make sense here because we
know the trash's volume is not read-only, we need to check
that you have a selection to enable Restore. Currently
(since hrev56978) Restore option is always enabled but it
shouldn't be if you have nothing selected.

It would be nice to also check if the restored location is
not read-only because you put something in the Trash then
remounted the volume read-only, but that's too much work.

Fixes yet another regression from hrev56978.

Also missed a delete convenience method call in hrev57402.

Call CanMoveToTrashOrDuplicate() to check if delete is allowed.
This method does a bit more work, it checks if the selection
includes the Desktop, the root volume, or the trash itself
which you are not allowed to delete.

Otherwise the same, this shouldn't make a big difference.

Change-Id: Ie188f25bd969a5aaeec9ff397fa5750872ccf97f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7138
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
John Scipione 2023-11-24 12:48:29 -05:00 committed by waddlesplash
parent ceeea27b72
commit f5029bd569

View File

@ -3282,10 +3282,9 @@ BContainerWindow::UpdateMenu(BMenu* menu, UpdateMenuContext context)
EnableNamedMenuItem(menu, kOpenSelection, selectCount > 0);
EnableNamedMenuItem(menu, kGetInfo, selectCount > 0);
EnableNamedMenuItem(menu, kIdentifyEntry, selectCount > 0);
EnableNamedMenuItem(menu, kRestoreFromTrash,
!PoseView()->TargetVolumeIsReadOnly());
EnableNamedMenuItem(menu, kDelete, selectCount > 0
&& !PoseView()->SelectedVolumeIsReadOnly());
EnableNamedMenuItem(menu, kRestoreFromTrash, selectCount > 0);
EnableNamedMenuItem(menu, kDelete,
PoseView()->CanMoveToTrashOrDuplicate());
}
if (context == kMenuBarContext || context == kPosePopUpContext) {