Enable removing multiple devices at once
ClosedPublic

Authored by umanovskis on Sep 20 2019, 12:05 PM.

Details

Summary

With the device list only allowing one item to be selected, removing
many devices takes a lot of clicking. Allowing multiple selection
solves that with a familiar UI pattern.

Diff Detail

Repository
R97 Bluedevil
Branch
dev-multiselect
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 16954
Build 16972: arc lint + arc unit
umanovskis created this revision.Sep 20 2019, 12:05 PM
Restricted Application added a project: Plasma. Β· View Herald TranscriptSep 20 2019, 12:05 PM
Restricted Application added a subscriber: plasma-devel. Β· View Herald Transcript
umanovskis requested review of this revision.Sep 20 2019, 12:05 PM

Screenshot of the new action:

ngraham added a subscriber: ngraham.
ngraham added inline comments.
src/kcmodule/devices/devices.cpp
241

Need to override the button titles so they say "Remove" and "Cancel". "Yes" and "No" are never acceptable dialog button text.

Also, are you sure this needs a confirmation dialog at all? These are usually seen by the user as very annoying. If you feel like there should be more safety here, consider adding an Undo feature instead, and exposing it with a KMessageWidget/Kirigami.InlineMessage with an Undo button that appears somewhere in the UI after the items are removed.

umanovskis added inline comments.Sep 20 2019, 3:01 PM
src/kcmodule/devices/devices.cpp
241

This is my first time touching any Qt or KDE code so I apologize if my questions seem obvious.

I assume that the confirmation dialog, or undo feature, should act in the same way for removing one and multiple devices. Would I then modify the old function on the same commit here, or a different one?

How would I go about adding Undo? I don't see anything like an existing command stack - would converting the remove command to a QAction be the way, or is there some other convention?

Sorry, I totally missed that there's already a confirmation dialog when removing a device. It's fine to add a new one; we can make all of this better with an undo stack in a future commit. For now I will push a commit that improves the UX of the existing message box, and then you can rebase your patch and follow that example for the new one.

Done in c020ce51a0d6861ce75856f0165bd5cd8bd5508f; you can rebase and copy the format now.

  • Update message box to a more user-friendly format

Rebased and adapted per suggestion above.

ngraham accepted this revision.Sep 24 2019, 12:45 AM
ngraham added inline comments.
src/kcmodule/devices/devices.cpp
209

You could rename this function to removeSelectedDevices() and handle both single and multi-selection behaviors in it.

This revision is now accepted and ready to land.Sep 24 2019, 12:45 AM
  • Handle all device deletion in one function, reducing duplication
umanovskis marked an inline comment as done.Sep 24 2019, 10:20 AM
umanovskis added inline comments.
src/kcmodule/devices/devices.cpp
209

Done, looks cleaner now - there's still an if-statement for different dialog messages but less duplication overall.

ngraham accepted this revision.Sep 24 2019, 1:41 PM

Lovely work. πŸ‘Œ

Thanks! Would you land this for me?

Yep, will do in a little while.

This revision was automatically updated to reflect the committed changes.