Drag to reorder the toolbar and favourites pickers - #895
Merged
Conversation
The chosen column takes internal drags, so an item moves by being dragged to where it belongs rather than by walking it there one arrow press at a time. QListWidget implements an internal move as a remove plus an insert, so rowsMoved never fires and the drop event is the only reliable signal; the list is read back as the truth afterwards. The X button goes with the arrows: the left column's checkboxes already remove an item, and _set_checked existed only to keep the two in step.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #894. The chosen column of the shared picker now takes internal drags, so an item moves by being dragged where it belongs instead of being walked there one arrow press at a time. Applies to both users of the dialog: Edit Toolbar… and Edit Favourites.
What changed
negpy/desktop/view/widgets/favourites_dialog.py_ReorderList— aQListWidgetinInternalMovemode with areorderedsignal. QListWidget implements an internal move as a remove plus an insert, sorowsMovednever fires; the drop event is the only reliable signal, and the list is read back as the truth afterwards._set_checkedexisted only to keep the two in step._rebuild_chosenloses its now-unusedselect_rowargument.docs/USER_GUIDE.md— the Favourites bullet and both canvas-toolbar paragraphs say drag rather than arrow buttons.Net −43 lines.
Verification
make allgreen.test_dialog_reads_the_dropped_order_backmoves a row the wayInternalMovedoes and asserts the read-back order;test_chosen_list_takes_internal_dragsguards the drag configuration itself. The retired_move_up/_move_down/_remove_selectedtests are deleted with the code.Driven offscreen with the real toolbar catalogue: the footer holds only Restore Defaults / Cancel / Apply, the list reports
InternalMove+MoveAction, a moved row reads back in the new order, and Restore Defaults still returns the stock row.The drag gesture itself is Qt's, and simulating a synthetic
QDropEventoffscreen does not exercise it faithfully (the event carries no source, so the view declines the internal move), so that part is left to Qt rather than covered by a test that would pass for the wrong reason.