[Folder View] Disable the actions themselves rather than just not adding them to the menu
ClosedPublic

Authored by broulik on Aug 30 2018, 9:51 AM.

Details

Summary

Folder View is built on the assumption that actions can only be triggered from the context menu.
This isn't true as keyboard shortcuts can trigger actions which will only get their correct state just before the menu opens. Moreover, often the action itself isn't disabled/hidden but just not added to the menu, which means it can still be triggered using a keyboard shortcut.
This patch changes the context menu to always include all (most of them, anyway) actions but instead have updateActions() disable or hide them as needed.
Also, take into account KFileItemListProperties for more actions (e.g. Cut, Paste, Rename, Trash, …) like Dolphin does it.

Test Plan

This change is a bit delicate as there's quite a few states to be in: remote files selected, a file inside trash, trash itself, link to trash on the desktop, readonly directory, etc

  • Made my desktop folder read-only (requires D15161 to work properly)
  • Paste, Cut, Rename options were disabled, Trash option was hidden
  • In trash:/ "Delete" and "Empty Trash" showed up fine
  • Some options that make no sense for trash (Rename, "Create New") are hidden, like in Dolphin
  • Pressing Delete, F2, Ctrl+X, etc do nothing when the actions are disabled

Together with D15160 this allows locking down the desktop for the user when you make the desktop folder read-only

Diff Detail

Repository
R119 Plasma Desktop
Lint
Lint Skipped
Unit
Unit Tests Skipped
broulik created this revision.Aug 30 2018, 9:51 AM
Restricted Application added a project: Plasma. · View Herald TranscriptAug 30 2018, 9:51 AM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
broulik requested review of this revision.Aug 30 2018, 9:51 AM
broulik updated this revision to Diff 40687.
broulik edited the test plan for this revision. (Show Details)
  • Also check for rename action when pressing F2
hein accepted this revision.Sep 5 2018, 4:40 PM

Good patch!

This revision is now accepted and ready to land.Sep 5 2018, 4:40 PM
This revision was automatically updated to reflect the committed changes.