refactor: Dialog "Küren verwalten" als eigene Szene

`scenes/routine/routine_manager_panel.tscn` mit `RoutineManagerPanel`:
Das Panel baut die Zeilen (Öffnen/Umbenennen/Löschen) und meldet die Auswahl
über Signale. Die Abläufe bleiben beim Controller, weil sie Dateien, den
aktuellen Pfad und den Sync brauchen.

- Der Controller füllt das Panel nur noch (`open_for`, `refresh`), prüft
  `is_open()` und schließt es über `close()`.
- `manager_tabs` ist aus dem Controller entfernt: `%Name` gilt nur innerhalb
  der Szene, die den Knoten besitzt.
- Neuer eigener Test `run_routine_manager_panel_tests.gd` (13 Assertions):
  Zeilen, Signalnutzlast, Neuaufbau, Leerzustand, Öffnen/Schließen.

Controller: 8.116 -> 8.082 Zeilen. Suite grün (23 Suiten).
This commit is contained in:
torsten 2026-11-13 15:10:51 +01:00
parent a835831201
commit 7c83128d28
11 changed files with 290 additions and 123 deletions

View file

@ -0,0 +1,77 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://src/whiteboard/view/routine_manager_panel.gd" id="1_manager_panel"]
[node name="RoutineManagerPanel" type="Node"]
unique_name_in_owner = true
script = ExtResource("1_manager_panel")
[node name="RoutineManagerDialog" type="AcceptDialog" parent="."]
unique_name_in_owner = true
title = "Küren verwalten"
size = Vector2i(800, 600)
exclusive = false
ok_button_text = "Schließen"
[node name="ManagerBox" type="VBoxContainer" parent="RoutineManagerDialog"]
offset_left = 12.0
offset_top = 12.0
offset_right = 788.0
offset_bottom = 530.0
theme_override_constants/separation = 4
[node name="ManagerHint" type="Label" parent="RoutineManagerDialog/ManagerBox"]
layout_mode = 2
theme_override_colors/font_color = Color(0.580392, 0.639216, 0.721569, 1)
theme_override_font_sizes/font_size = 14
text = "Lokale Küren löschen oder alte Konfliktkopien aufräumen. Echte Sync-Konflikte löst die App automatisch nach dem neuesten Speicherstand auf."
autowrap_mode = 2
[node name="ManagerTabs" type="TabContainer" parent="RoutineManagerDialog/ManagerBox"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
[node name="RoutinesTab" type="VBoxContainer" parent="RoutineManagerDialog/ManagerBox/ManagerTabs"]
layout_mode = 2
theme_override_constants/separation = 4
[node name="RoutineManagerScroll" type="ScrollContainer" parent="RoutineManagerDialog/ManagerBox/ManagerTabs/RoutinesTab"]
layout_mode = 2
size_flags_vertical = 3
horizontal_scroll_mode = 0
[node name="RoutineManagerList" type="VBoxContainer" parent="RoutineManagerDialog/ManagerBox/ManagerTabs/RoutinesTab/RoutineManagerScroll"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
theme_override_constants/separation = 4
[node name="ConflictsTab" type="VBoxContainer" parent="RoutineManagerDialog/ManagerBox/ManagerTabs"]
layout_mode = 2
theme_override_constants/separation = 4
[node name="ConflictManagerHint" type="Label" parent="RoutineManagerDialog/ManagerBox/ManagerTabs/ConflictsTab"]
layout_mode = 2
theme_override_colors/font_color = Color(0.580392, 0.639216, 0.721569, 1)
theme_override_font_sizes/font_size = 14
text = "Alte sichtbare Kopien wie „Kür (Server …).json“ werden gesucht und nach Bestätigung ins Konfliktarchiv verschoben. Kopien ohne Hauptdatei bleiben als mögliche letzte Fassung erhalten."
autowrap_mode = 2
[node name="ManagerConflictActions" type="HBoxContainer" parent="RoutineManagerDialog/ManagerBox/ManagerTabs/ConflictsTab"]
layout_mode = 2
theme_override_constants/separation = 4
[node name="ManagerScanConflictsButton" type="Button" parent="RoutineManagerDialog/ManagerBox/ManagerTabs/ConflictsTab/ManagerConflictActions"]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 48)
layout_mode = 2
size_flags_horizontal = 3
text = "Konfliktkopien suchen…"
[node name="ManagerOpenArchiveButton" type="Button" parent="RoutineManagerDialog/ManagerBox/ManagerTabs/ConflictsTab/ManagerConflictActions"]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 48)
layout_mode = 2
size_flags_horizontal = 3
text = "Konfliktarchiv öffnen"

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=25 format=3]
[gd_scene load_steps=26 format=3]
[ext_resource type="Script" path="res://src/whiteboard/ctrl/whiteboard_controller.gd" id="1_controller"]
[ext_resource type="Script" path="res://src/whiteboard/view/rink_canvas.gd" id="2_canvas"]
@ -6,6 +6,7 @@
[ext_resource type="Script" path="res://src/whiteboard/view/export_panel.gd" id="3_export_panel"]
[ext_resource type="Script" path="res://src/whiteboard/view/playback_panel.gd" id="3_playback_panel"]
[ext_resource type="PackedScene" path="res://scenes/export/export_panel.tscn" id="14_export_panel_scene"]
[ext_resource type="PackedScene" path="res://scenes/routine/routine_manager_panel.tscn" id="15_manager_panel_scene"]
[ext_resource type="Texture2D" path="res://assets/icons/tools/select.svg" id="4_tool_select"]
[ext_resource type="Texture2D" path="res://assets/icons/tools/line.svg" id="5_tool_line"]
[ext_resource type="Texture2D" path="res://assets/icons/tools/arc_left.svg" id="6_tool_arc_left"]
@ -1296,75 +1297,8 @@ layout_mode = 2
size_flags_horizontal = 3
theme_override_constants/separation = 4
[node name="RoutineManagerDialog" type="AcceptDialog" parent="."]
[node name="RoutineManagerPanel" parent="." instance=ExtResource("15_manager_panel_scene")]
unique_name_in_owner = true
title = "Küren verwalten"
size = Vector2i(800, 600)
exclusive = false
ok_button_text = "Schließen"
[node name="ManagerBox" type="VBoxContainer" parent="RoutineManagerDialog"]
offset_left = 12.0
offset_top = 12.0
offset_right = 788.0
offset_bottom = 530.0
theme_override_constants/separation = 4
[node name="ManagerHint" type="Label" parent="RoutineManagerDialog/ManagerBox"]
layout_mode = 2
theme_override_colors/font_color = Color(0.580392, 0.639216, 0.721569, 1)
theme_override_font_sizes/font_size = 14
text = "Lokale Küren löschen oder alte Konfliktkopien aufräumen. Echte Sync-Konflikte löst die App automatisch nach dem neuesten Speicherstand auf."
autowrap_mode = 2
[node name="ManagerTabs" type="TabContainer" parent="RoutineManagerDialog/ManagerBox"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
[node name="RoutinesTab" type="VBoxContainer" parent="RoutineManagerDialog/ManagerBox/ManagerTabs"]
layout_mode = 2
theme_override_constants/separation = 4
[node name="RoutineManagerScroll" type="ScrollContainer" parent="RoutineManagerDialog/ManagerBox/ManagerTabs/RoutinesTab"]
layout_mode = 2
size_flags_vertical = 3
horizontal_scroll_mode = 0
[node name="RoutineManagerList" type="VBoxContainer" parent="RoutineManagerDialog/ManagerBox/ManagerTabs/RoutinesTab/RoutineManagerScroll"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
theme_override_constants/separation = 4
[node name="ConflictsTab" type="VBoxContainer" parent="RoutineManagerDialog/ManagerBox/ManagerTabs"]
layout_mode = 2
theme_override_constants/separation = 4
[node name="ConflictManagerHint" type="Label" parent="RoutineManagerDialog/ManagerBox/ManagerTabs/ConflictsTab"]
layout_mode = 2
theme_override_colors/font_color = Color(0.580392, 0.639216, 0.721569, 1)
theme_override_font_sizes/font_size = 14
text = "Alte sichtbare Kopien wie „Kür (Server …).json“ werden gesucht und nach Bestätigung ins Konfliktarchiv verschoben. Kopien ohne Hauptdatei bleiben als mögliche letzte Fassung erhalten."
autowrap_mode = 2
[node name="ManagerConflictActions" type="HBoxContainer" parent="RoutineManagerDialog/ManagerBox/ManagerTabs/ConflictsTab"]
layout_mode = 2
theme_override_constants/separation = 4
[node name="ManagerScanConflictsButton" type="Button" parent="RoutineManagerDialog/ManagerBox/ManagerTabs/ConflictsTab/ManagerConflictActions"]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 48)
layout_mode = 2
size_flags_horizontal = 3
text = "Konfliktkopien suchen…"
[node name="ManagerOpenArchiveButton" type="Button" parent="RoutineManagerDialog/ManagerBox/ManagerTabs/ConflictsTab/ManagerConflictActions"]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 48)
layout_mode = 2
size_flags_horizontal = 3
text = "Konfliktarchiv öffnen"
[node name="DeleteRoutineDialog" type="ConfirmationDialog" parent="."]
unique_name_in_owner = true

View file

@ -287,11 +287,7 @@ const UPDATE_FILE_NAMES := {
@onready var cleanup_conflicts_dialog: ConfirmationDialog = %CleanupConflictsDialog
@onready var cleanup_conflicts_intro: Label = %CleanupConflictsIntro
@onready var cleanup_conflicts_list: VBoxContainer = %CleanupConflictsList
@onready var routine_manager_dialog: AcceptDialog = %RoutineManagerDialog
@onready var manager_tabs: TabContainer = %ManagerTabs
@onready var routine_manager_list: VBoxContainer = %RoutineManagerList
@onready var manager_scan_conflicts_button: Button = %ManagerScanConflictsButton
@onready var manager_open_archive_button: Button = %ManagerOpenArchiveButton
@onready var routine_manager_panel: RoutineManagerPanel = %RoutineManagerPanel
@onready var delete_routine_dialog: ConfirmationDialog = %DeleteRoutineDialog
@onready var delete_routine_text: Label = %DeleteRoutineText
@onready var delete_routine_cloud_check: CheckBox = %DeleteRoutineCloudCheck
@ -516,8 +512,11 @@ func _ready() -> void:
sync_provider_option.item_selected.connect(_on_sync_provider_selected)
sync_connect_button.pressed.connect(_on_sync_connect_pressed)
cleanup_conflicts_dialog.confirmed.connect(_on_cleanup_conflicts_confirmed)
manager_scan_conflicts_button.pressed.connect(_start_conflict_scan)
manager_open_archive_button.pressed.connect(_open_conflicts_folder)
routine_manager_panel.open_requested.connect(_on_manager_open_pressed)
routine_manager_panel.rename_requested.connect(_open_rename_routine_dialog)
routine_manager_panel.delete_requested.connect(_open_delete_routine_dialog)
routine_manager_panel.scan_conflicts_requested.connect(_start_conflict_scan)
routine_manager_panel.open_archive_requested.connect(_open_conflicts_folder)
delete_routine_dialog.confirmed.connect(_on_delete_routine_confirmed)
delete_routine_dialog.canceled.connect(_on_delete_routine_canceled)
rename_routine_dialog.confirmed.connect(_on_rename_routine_confirmed)
@ -6368,7 +6367,7 @@ func _apply_hub_download(overwrite: bool) -> void:
_discard_hub_download(pending)
hub_status_label.text = "Vom Hub geladen: " + target_routine
_refresh_open_list()
if routine_manager_dialog.visible:
if routine_manager_panel.is_open():
_refresh_routine_manager()
_show_message(
"Kür vom Hub geladen:\n\n%s\n\n"
@ -7111,51 +7110,18 @@ func _open_open_dialog() -> void:
func _open_routine_manager() -> void:
manager_tabs.set_tab_title(0, "Küren")
manager_tabs.set_tab_title(1, "Konfliktkopien")
_refresh_routine_manager()
routine_manager_dialog.popup_centered(Vector2i(800, 600))
routine_manager_panel.open_for(
_routine_entries(),
Vector2i(800, 600)
)
func _refresh_routine_manager() -> void:
for child: Node in routine_manager_list.get_children():
child.free()
var entries := _routine_entries()
for file: String in entries:
var row := HBoxContainer.new()
row.add_theme_constant_override("separation", 8)
var open_button := Button.new()
open_button.text = file.get_basename()
open_button.custom_minimum_size = Vector2(0.0, 48.0)
open_button.size_flags_horizontal = Control.SIZE_EXPAND_FILL
open_button.alignment = HORIZONTAL_ALIGNMENT_LEFT
open_button.clip_text = true
open_button.pressed.connect(
_on_manager_open_pressed.bind(ROUTINES_DIR.path_join(file))
)
row.add_child(open_button)
var rename_button := Button.new()
rename_button.text = "Umbenennen"
rename_button.custom_minimum_size = Vector2(132.0, 48.0)
rename_button.pressed.connect(
_open_rename_routine_dialog.bind(file)
)
row.add_child(rename_button)
var delete_button := Button.new()
delete_button.text = "Löschen"
delete_button.custom_minimum_size = Vector2(110.0, 48.0)
delete_button.pressed.connect(_open_delete_routine_dialog.bind(file))
row.add_child(delete_button)
routine_manager_list.add_child(row)
if entries.is_empty():
var label := Label.new()
label.text = "Keine gespeicherten Kürläufe"
routine_manager_list.add_child(label)
routine_manager_panel.refresh(_routine_entries())
func _on_manager_open_pressed(path: String) -> void:
routine_manager_dialog.hide()
routine_manager_panel.close()
_on_open_file_pressed(path)

View file

@ -0,0 +1,82 @@
class_name RoutineManagerPanel
extends Node
## The "Küren verwalten" dialog: one row per routine plus the conflict tools.
##
## The panel renders rows and reports what the user picked. Opening, renaming,
## deleting and the conflict scan stay with the controller, because they touch
## files, the current routine and the sync state.
signal open_requested(file_name: String)
signal rename_requested(file_name: String)
signal delete_requested(file_name: String)
signal scan_conflicts_requested
signal open_archive_requested
@onready var dialog: AcceptDialog = %RoutineManagerDialog
@onready var list: VBoxContainer = %RoutineManagerList
@onready var scan_button: Button = %ManagerScanConflictsButton
@onready var archive_button: Button = %ManagerOpenArchiveButton
func _ready() -> void:
scan_button.pressed.connect(func() -> void: scan_conflicts_requested.emit())
archive_button.pressed.connect(func() -> void: open_archive_requested.emit())
## Shows the dialog for [param entries] (file names, one per routine).
func open_for(entries: Array[String], size: Vector2i) -> void:
refresh(entries)
dialog.popup_centered(size)
dialog.size = size
## Rebuilds the row list. Safe to call while the dialog is open.
func refresh(entries: Array[String]) -> void:
for child: Node in list.get_children():
list.remove_child(child)
child.free()
for file: String in entries:
list.add_child(_build_row(file))
if entries.is_empty():
var label := Label.new()
label.text = "Keine gespeicherten Kürläufe"
list.add_child(label)
func is_open() -> bool:
return dialog.visible
func close() -> void:
dialog.hide()
func _build_row(file: String) -> HBoxContainer:
var row := HBoxContainer.new()
row.add_theme_constant_override("separation", 8)
var open_button := Button.new()
open_button.text = file.get_basename()
open_button.custom_minimum_size = Vector2(0.0, 48.0)
open_button.size_flags_horizontal = Control.SIZE_EXPAND_FILL
open_button.alignment = HORIZONTAL_ALIGNMENT_LEFT
open_button.clip_text = true
open_button.pressed.connect(func() -> void: open_requested.emit(file))
row.add_child(open_button)
var rename_button := Button.new()
rename_button.text = "Umbenennen"
rename_button.custom_minimum_size = Vector2(132.0, 48.0)
rename_button.pressed.connect(func() -> void: rename_requested.emit(file))
row.add_child(rename_button)
var delete_button := Button.new()
delete_button.text = "Löschen"
delete_button.custom_minimum_size = Vector2(110.0, 48.0)
delete_button.pressed.connect(func() -> void: delete_requested.emit(file))
row.add_child(delete_button)
return row

View file

@ -0,0 +1 @@
uid://bu40o821wuiet

View file

@ -0,0 +1,86 @@
extends SceneTree
## Headless test for `RoutineManagerPanel` on its own: rows and signals, no
## WhiteboardController and no routine files.
##
## Run with:
## godot --headless --path rinkplanner --script res://tests/run_routine_manager_panel_tests.gd
const PanelScene := preload("res://scenes/routine/routine_manager_panel.tscn")
var _assertions: int = 0
var _failures: PackedStringArray = PackedStringArray()
func _init() -> void:
_run.call_deferred()
func _run() -> void:
var panel := PanelScene.instantiate() as RoutineManagerPanel
_check(panel != null, "the panel scene carries its script")
if panel == null:
_finish()
return
root.size = Vector2i(1280, 800)
root.add_child(panel)
await process_frame
_check(not panel.is_open(), "the dialog starts closed")
var opened: Array = []
var renamed: Array = []
var deleted: Array = []
panel.open_requested.connect(func(name: String) -> void: opened.append(name))
panel.rename_requested.connect(func(name: String) -> void: renamed.append(name))
panel.delete_requested.connect(func(name: String) -> void: deleted.append(name))
panel.open_for(["b.json", "a.json"], Vector2i(800, 600))
_check(panel.is_open(), "the dialog opens")
_check(panel.list.get_child_count() == 2, "one row per routine")
var first_row := panel.list.get_child(0) as HBoxContainer
_check(first_row != null and first_row.get_child_count() == 3, "a row has open, rename and delete")
if first_row != null and first_row.get_child_count() == 3:
var open_button := first_row.get_child(0) as Button
_check(open_button.text == "b", "the row shows the name without extension")
open_button.pressed.emit()
(first_row.get_child(1) as Button).pressed.emit()
(first_row.get_child(2) as Button).pressed.emit()
_check(opened == ["b.json"], "the open signal carries the file")
_check(renamed == ["b.json"], "the rename signal carries the file")
_check(deleted == ["b.json"], "the delete signal carries the file")
panel.refresh(["c.json"])
_check(panel.list.get_child_count() == 1, "refreshing replaces the rows")
panel.refresh([])
_check(panel.list.get_child_count() == 1, "an empty list shows one hint")
_check(
(panel.list.get_child(0) as Label).text.contains("Keine"),
"the hint says that no routines are stored"
)
panel.close()
_check(not panel.is_open(), "the dialog closes")
panel.queue_free()
await process_frame
_finish()
func _check(condition: bool, message: String) -> void:
_assertions += 1
if not condition:
_failures.append(message)
func _finish() -> void:
if _failures.is_empty():
print("PASS: %d assertions" % _assertions)
quit(0)
return
for failure: String in _failures:
printerr("FAIL: %s" % failure)
printerr("%d of %d assertions failed" % [_failures.size(), _assertions])
quit(1)

View file

@ -0,0 +1 @@
uid://bkwa2hkn4gob7

View file

@ -784,7 +784,7 @@ func _test_controller_wiring() -> void:
manager_item = index
_check(manager_item >= 0, "das Dateimenü bietet die Kürenverwaltung an")
_check(
controller.routine_manager_dialog != null
controller.routine_manager_panel.dialog != null
and controller.delete_routine_dialog != null,
"Verwaltungs- und Löschdialog sind in der Szene verdrahtet"
)
@ -892,13 +892,13 @@ func _test_controller_wiring() -> void:
)
)
controller._refresh_routine_manager()
controller.routine_manager_dialog.show()
controller.routine_manager_panel.dialog.show()
_check(
controller.routine_manager_dialog.visible,
controller.routine_manager_panel.dialog.visible,
"der Verwaltungsdialog lässt sich öffnen"
)
var manager_row: HBoxContainer = null
for child: Node in controller.routine_manager_list.get_children():
for child: Node in controller.routine_manager_panel.list.get_children():
if child is HBoxContainer:
var open_button := child.get_child(0) as Button
if open_button != null and open_button.text == "sync-test-manager":
@ -995,7 +995,7 @@ func _test_controller_wiring() -> void:
)
)
controller._refresh_routine_manager()
controller.routine_manager_dialog.hide()
controller.routine_manager_panel.dialog.hide()
controller.sync_settings_dialog.hide()
# Ohne Refresh-Token öffnet "Jetzt synchronisieren" die Einstellungen.