Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 1 addition & 44 deletions src/zebtrack/ui/builders/zone_control_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
Extracted from WidgetFactory to separate concern of zone control construction.
"""

import os
from datetime import datetime
from tkinter import BooleanVar
from typing import TYPE_CHECKING
Expand Down Expand Up @@ -329,7 +328,7 @@ def _show_conclude_next_step_guidance(self) -> None:
with no pending session) there is currently no other cue in the UI, so
point the user at the "Controle Principal" tab. Only applies to live
projects — pre-recorded projects have their own explicit "Iniciar
Análise" / "Enviar Vídeo Selecionado para Análise" buttons.
Análise" button.
"""
zone_controls = getattr(self.gui, "zone_controls", None)
if zone_controls is not None and zone_controls.has_pending_live_session():
Expand All @@ -351,45 +350,3 @@ def _show_conclude_next_step_guidance(self) -> None:
'and click "Start Recording".'
),
)

def _on_send_selected_video_to_analysis(self) -> None:
"""Open analysis configuration for the real video selected in the zone tree."""
tree = getattr(self.gui, "video_selector_tree", None)
selection = tree.selection() if tree is not None else ()
if tree is None or not selection:
self.gui.dialog_manager.show_warning(
_("No Video Selected"),
_("Select a recorded video from the list before sending it for analysis."),
)
return

tags = tree.item(selection[0], "tags") or ()
video_path = str(tags[0]) if tags else ""
is_video_entry = video_path and video_path not in {"group", "day", "subject"}
if not is_video_entry or not os.path.isfile(video_path):
self.gui.dialog_manager.show_info(
_("Video Unavailable"),
_(
"Only recorded videos can be sent for analysis. Planned sessions "
"must be recorded first."
),
)
return

zone_controls = getattr(self.gui, "zone_controls", None)
if zone_controls and zone_controls.has_pending_live_session():
self.gui.dialog_manager.show_info(
_("Recording Pending"),
_(
"Start or cancel the pending recording before sending another "
"video for analysis."
),
)
return

event_dispatcher = getattr(self.gui, "event_dispatcher", None)
if event_dispatcher is None:
log.error("zone_control_builder.send_to_analysis.no_event_dispatcher")
return

event_dispatcher.handle_analyze_single_video_clicked(video_path=video_path)
21 changes: 0 additions & 21 deletions tests/ui/builders/test_zone_control_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,24 +134,3 @@ def test_conclude_video_pre_recorded_project_skips_guidance_dialog():
builder._on_conclude_video()

gui.dialog_manager.show_info.assert_not_called()


def test_send_selected_video_to_analysis_uses_selected_file(tmp_path):
"""The explicit action sends the selected recorded file to the config dialog."""
video_path = tmp_path / "recorded.mp4"
video_path.touch()
tree = Mock()
tree.selection.return_value = ("video-item",)
tree.item.return_value = (str(video_path),)
gui = _conclude_gui(editing_zone=None, edited_points=[])
gui.video_selector_tree = tree
gui.zone_controls = SimpleNamespace(has_pending_live_session=lambda: False)
gui.event_dispatcher = Mock()
gui.dialog_manager = Mock()
builder = ZoneControlBuilder(gui, event_bus_v2=Mock())

builder._on_send_selected_video_to_analysis()

gui.event_dispatcher.handle_analyze_single_video_clicked.assert_called_once_with(
video_path=str(video_path)
)
Loading