Skip to content

Refactor: more Post events into commands #502

Description

@FelipeDefensor

Following PR #387, several other Post events still match the user-action shape that maps cleanly to commands (single producer, single listener, user-initiated). They were left out of #387 because their listener isn't Player, or because the producer side is multi-source. Tracking here as follow-up.

Loop-related (listener: timeline collection)

  • Post.PLAYER_TOGGLE_LOOP — producer: loop toggle button (tilia/ui/player.py:180); listener: TimelineUIs.on_loop_toggle (tilia/ui/timelines/collection/collection.py:459). Suggested: media.loop.toggle.
  • Post.PLAYER_CANCEL_LOOP — producers: tilia/app.py:239, tilia/media/player/base.py:138,164,260; listener: TimelineUIs.on_loop_cancel (tilia/ui/timelines/collection/collection.py:458). Suggested: media.loop.cancel. Multi-producer, but command semantics are clean.
  • Post.PLAYER_CURRENT_LOOP_CHANGED — producer: TimelineUIs.on_loop_change (tilia/ui/timelines/collection/collection.py:1053); listener: Player.on_loop_changed (tilia/media/player/base.py:70). Suggested: media.loop.change. Programmatic rather than user-initiated, so least clean of the three — could keep as a Post event.

Media load / metadata (single listener, user-initiated)

  • Post.APP_MEDIA_LOAD — producers: CLI (tilia/ui/cli/load_media.py:62), Qt UI (tilia/ui/qtui.py:415,429), drag-drop (tilia/ui/timelines/collection/collection.py:398), tests; listener: App.load_media (tilia/app.py:65). Suggested: media.load.
  • Post.MEDIA_METADATA_FIELD_ADD — producers: CLI metadata (tilia/ui/cli/metadata/set.py:34); listener: FileManager.on_add_media_metadata_field (tilia/file/file_manager.py:71). Suggested: media.metadata.field.add.
  • Post.MEDIA_METADATA_FIELD_SET — producers: metadata window (tilia/ui/windows/metadata.py:125,199), CLI (tilia/ui/cli/metadata/set.py:32,35), tests; listener: FileManager.on_set_media_metadata_field (tilia/file/file_manager.py:70). Suggested: media.metadata.field.set.
  • Post.METADATA_UPDATE_FIELDS — producers: metadata window (tilia/ui/windows/metadata.py:180), tests; listener: FileManager.on_update_media_metadata_fields (tilia/file/file_manager.py:72). Suggested: media.metadata.fields.update.

Pattern reminder

Follow the established media.* pattern from #387:

  1. Move the listener registration from _setup_requests LISTENS set into _setup_commands as commands.register("media.x", self.on_x).
  2. Replace post(Post.X, args) call sites with commands.execute("media.x", args).
  3. Remove the Post.X enum entry.
  4. Update tests in the same commit.

One commit per refactored event.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions