Skip to content

Drag to reorder the toolbar and favourites pickers - #895

Merged
marcinz606 merged 1 commit into
mainfrom
feat/toolbar-dnd
Aug 18, 2026
Merged

Drag to reorder the toolbar and favourites pickers#895
marcinz606 merged 1 commit into
mainfrom
feat/toolbar-dnd

Conversation

@marcinz606

Copy link
Copy Markdown
Owner

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 — a QListWidget in InternalMove mode with a reordered signal. QListWidget implements an internal move as a remove plus an insert, so rowsMoved never fires; the drop event is the only reliable signal, and the list is read back as the truth afterwards.
  • The up/down arrows are gone, and so is the X: the left column's checkboxes already remove an item, and _set_checked existed only to keep the two in step. _rebuild_chosen loses its now-unused select_row argument.
  • Both hints gained a leading "Drag to reorder."

docs/USER_GUIDE.md — the Favourites bullet and both canvas-toolbar paragraphs say drag rather than arrow buttons.

Net −43 lines.

Verification

make all green. test_dialog_reads_the_dropped_order_back moves a row the way InternalMove does and asserts the read-back order; test_chosen_list_takes_internal_drags guards the drag configuration itself. The retired _move_up/_move_down/_remove_selected tests 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 QDropEvent offscreen 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.

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.
@marcinz606
marcinz606 merged commit a445d6b into main Aug 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant