YODAU 1.0
YEAR OF THE DEPEND ADULT UNDERGARMENT
Loading...
Searching...
No Matches
settings_panel.hpp
Go to the documentation of this file.
1#ifndef YODAU_FRONTEND_WIDGETS_SETTINGS_PANEL_HPP
2#define YODAU_FRONTEND_WIDGETS_SETTINGS_PANEL_HPP
3
4#include <QColor>
5#include <QGroupBox>
6#include <QSet>
7#include <QStringList>
8#include <QWidget>
9
10class QButtonGroup;
11class QCheckBox;
12class QComboBox;
13class QLineEdit;
14class QPlainTextEdit;
15class QPushButton;
16class QRadioButton;
17class QTabWidget;
18class QTreeWidget;
19class QTreeWidgetItem;
20
21/**
22 * @file settings_panel.hpp
23 * @brief Declares the settings side panel widget.
24 *
25 * The settings panel provides three main tabs:
26 * - **Add stream**: UI for creating new streams from a file, local
27 * camera/device, or a network URL.
28 * - **Streams**: list of known streams with per-stream visibility toggles and
29 * a simple event log.
30 * - **Active**: controls for selecting an active stream, choosing edit mode
31 * (draw new line vs. use template), editing draft line parameters, and adding
32 * templates/lines to the active stream. Includes an active log view.
33 *
34 * This widget emits high-level signals describing user intent. The controller
35 * is expected to connect these signals to backend actions and to call the
36 * public "setter" methods to keep UI state in sync with the backend.
37 */
38
39/**
40 * @brief Side panel that exposes stream and line controls to the user.
41 *
42 * The panel itself is a pure UI component:
43 * - It stores minimal UI state (existing names, active color selections, etc.).
44 * - It does not access backend directly.
45 * - It is driven by a controller that listens to signals and calls setters.
46 *
47 * Threading:
48 * - This is a QWidget and must only be used from the Qt GUI thread.
49 */
50class settings_panel final : public QWidget {
52public:
53 /**
54 * @brief Construct the settings panel.
55 *
56 * Builds all UI tabs and initializes default mode to "file".
57 *
58 * @param parent Optional parent widget.
59 */
60 explicit settings_panel(QWidget* parent = nullptr);
61
62 // existing names
63
64 /**
65 * @brief Replace the set of existing (reserved) names.
66 *
67 * Used to validate uniqueness of new stream/line/template names.
68 *
69 * @param names Set of names already used by backend/UI.
70 */
71 void set_existing_names(QSet<QString> names);
72
73 /**
74 * @brief Add one name to the existing-name set.
75 *
76 * @param name Name to reserve.
77 */
78 void add_existing_name(const QString& name);
79
80 /**
81 * @brief Remove one name from the existing-name set.
82 *
83 * @param name Name to unreserve.
84 */
85 void remove_existing_name(const QString& name);
86
87 // streams tab
88
89 /**
90 * @brief Add a stream row to the streams list.
91 *
92 * If the stream already exists in the list, the call is ignored.
93 *
94 * @param name Stream name.
95 * @param source Human-readable source description (type:path/url).
96 * @param checked Initial "show in grid" state.
97 */
99 const QString& name, const QString& source, bool checked = false
100 ) const;
101
102 /**
103 * @brief Set the "show" checkbox state for a stream entry.
104 *
105 * @param name Stream name.
106 * @param checked New checked state.
107 */
108 void set_stream_checked(const QString& name, bool checked) const;
109
110 /**
111 * @brief Remove a stream entry from the streams list.
112 *
113 * @param name Stream name to remove.
114 */
115 void remove_stream_entry(const QString& name) const;
116
117 /**
118 * @brief Remove all stream entries and clear name reservations.
119 */
121
122 /**
123 * @brief Append a line to the streams-tab event log.
124 *
125 * Prepends the current timestamp automatically.
126 *
127 * @param text Log line.
128 */
129 void append_event(const QString& text) const;
130
131 // add tab
132
133 /**
134 * @brief Set detected local sources (e.g., /dev/video*).
135 *
136 * Updates the local-sources combo box.
137 *
138 * @param sources List of local source identifiers.
139 */
140 void set_local_sources(const QStringList& sources) const;
141
142 /**
143 * @brief Clear all add-tab input fields and reset validation.
144 */
145 void clear_add_inputs() const;
146
147 /**
148 * @brief Append a line to the add-tab log.
149 *
150 * @param text Log line.
151 */
152 void append_add_log(const QString& text) const;
153
154 // active tab: streams
155
156 /**
157 * @brief Set the list of streams that can be selected as active.
158 *
159 * Ensures the current selection remains valid if possible,
160 * otherwise falls back to "none".
161 *
162 * @param names Candidate active stream names.
163 */
164 void set_active_candidates(const QStringList& names) const;
165
166 /**
167 * @brief Programmatically select the active stream.
168 *
169 * If @p name is empty or not among candidates, selects "none".
170 *
171 * @param name Stream name to select as active, or empty to clear.
172 */
173 void set_active_current(const QString& name) const;
174
175 // active tab: templates / lines
176
177 /**
178 * @brief Add one template name as a candidate in the templates combo.
179 *
180 * If already present, no change is made.
181 *
182 * @param name Template name to add.
183 */
184 void add_template_candidate(const QString& name) const;
185
186 /**
187 * @brief Replace the list of template candidates.
188 *
189 * Removes duplicates, inserts a "none" item, and selects it by default.
190 *
191 * @param names Template candidate names.
192 */
193 void set_template_candidates(const QStringList& names) const;
194
195 /**
196 * @brief Reset the "new line" form in the active tab.
197 *
198 * Clears name, sets closed=false, resets color to red, and emits
199 * @ref active_line_params_changed to reflect the reset.
200 */
202
203 /**
204 * @brief Reset the templates form to "none" selection.
205 */
207
208 /**
209 * @brief Programmatically set active draft "closed" checkbox.
210 *
211 * This does not emit signals.
212 *
213 * @param closed New closed state.
214 */
215 void set_active_line_closed(bool closed) const;
216
217 /**
218 * @brief Get currently selected template name.
219 *
220 * @return Template name, trimmed. May be "none" or empty.
221 */
223
224 /**
225 * @brief Get current preview color for templates.
226 *
227 * @return Preview color.
228 */
230
231 /**
232 * @brief Append a line to the active-tab log.
233 *
234 * Prepends the current timestamp automatically.
235 *
236 * @param msg Log line.
237 */
238 void append_active_log(const QString& msg) const;
239
240 /**
241 * @brief Clear the active-tab log view.
242 */
243 void clear_active_log() const;
244
245signals:
246 // add tab
247
248 /**
249 * @brief User requested adding a file stream.
250 *
251 * @param path File path.
252 * @param name Desired stream name (may be empty).
253 * @param loop Whether to loop playback.
254 */
255 void add_file_stream(const QString& path, const QString& name, bool loop);
256
257 /**
258 * @brief User requested adding a local capture stream.
259 *
260 * @param source Local device identifier/path.
261 * @param name Desired stream name (may be empty).
262 */
263 void add_local_stream(const QString& source, const QString& name);
264
265 /**
266 * @brief User requested adding a URL stream.
267 *
268 * @param url Network URL.
269 * @param name Desired stream name (may be empty).
270 */
271 void add_url_stream(const QString& url, const QString& name);
272
273 /**
274 * @brief User requested re-detection of local sources.
275 */
277
278 // streams tab
279
280 /**
281 * @brief Emitted when a stream's "show in grid" state changes.
282 *
283 * @param name Stream name.
284 * @param show New visibility state.
285 */
286 void show_stream_changed(const QString& name, bool show);
287
288 // active tab
289
290 /**
291 * @brief Emitted when the active stream selection changes.
292 *
293 * Empty name indicates "none".
294 *
295 * @param name Active stream name or empty.
296 */
297 void active_stream_selected(const QString& name);
298
299 /**
300 * @brief Emitted when edit mode changes.
301 *
302 * @param drawing_new true for "draw new line", false for "use template".
303 */
304 void active_edit_mode_changed(bool drawing_new);
305
306 /**
307 * @brief Emitted when any draft-line parameter changes.
308 *
309 * @param name Draft/template name (may be empty).
310 * @param color Draft color.
311 * @param closed Whether the draft is closed.
312 */
314 const QString& name, const QColor& color, bool closed
315 );
316
317 /**
318 * @brief Emitted when user clicks "add line" in active tab.
319 *
320 * @param name Desired line name (may be empty).
321 * @param closed Whether the line is closed.
322 */
323 void active_line_save_requested(const QString& name, bool closed);
324
325 /**
326 * @brief Emitted when user requests undo of the last draft point.
327 */
329
330 /**
331 * @brief Emitted when label visibility toggle changes.
332 *
333 * @param on true to enable labels in active view.
334 */
336
337 /**
338 * @brief Emitted when template selection changes.
339 *
340 * Empty name indicates "none".
341 *
342 * @param template_name Selected template name or empty.
343 */
344 void active_template_selected(const QString& template_name);
345
346 /**
347 * @brief Emitted when template preview color changes.
348 *
349 * @param color New preview color.
350 */
351 void active_template_color_changed(const QColor& color);
352
353 /**
354 * @brief Emitted when user adds a template instance to active stream.
355 *
356 * @param template_name Template to add.
357 * @param color Color to render that instance with.
358 */
360 const QString& template_name, const QColor& color
361 );
362
363private:
364 /**
365 * @brief Input mode for the add-tab.
366 */
367 enum class input_mode { file, local, url };
368
369 // ui build
370 /** @brief Build all tabs and root layout. */
371 void build_ui();
372 /** @brief Build the "add stream" tab. */
374 /** @brief Build the "streams" tab. */
376 /** @brief Build the "active" tab. */
378
379 /** @brief Build active-stream selection box. */
380 QWidget* build_active_stream_box(QWidget* parent);
381 /** @brief Build edit-mode radio group. */
382 QWidget* build_edit_mode_box(QWidget* parent);
383 /** @brief Build "new line" form box. */
384 QWidget* build_new_line_box(QWidget* parent);
385 /** @brief Build templates form box. */
386 QWidget* build_templates_box(QWidget* parent);
387
388 // add tab helpers
389 /** @brief Switch add-tab mode and refresh enabled/visible controls. */
390 void set_mode(input_mode mode);
391 /** @brief Update visibility/enabled state of add-tab tool boxes. */
392 void update_add_tools() const;
393 /** @brief Update enabled state of the "add" button based on validation. */
394 void update_add_enabled() const;
395
396 /** @brief File chooser handler. */
397 void on_choose_file();
398 /** @brief "Add" button handler. */
399 void on_add_clicked();
400 /** @brief "Refresh local sources" handler. */
401 void on_refresh_local();
402 /** @brief Handler for name edit changes (validation). */
403 void on_name_changed(QString text) const;
404
405 /** @brief Resolve the name for the current input (trimmed). */
407 /** @brief Check if @p name is not already reserved. */
408 bool name_is_unique(const QString& name) const;
409 /** @brief Validate that required input fields for current mode are filled.
410 */
411 bool current_input_valid() const;
412
413 /** @brief Apply/remove UI error styling for name edit. */
414 void set_name_error(bool error) const;
415
416 // active tab helpers
417 /** @brief Show/hide active-tab tool boxes based on selection/mode. */
418 void update_active_tools() const;
419 /** @brief Paint a QPushButton background to match a chosen color. */
420 void set_btn_color(QPushButton* btn, const QColor& c) const;
421
422private slots:
423 /** @brief Active-stream combo change handler. */
425 /** @brief Edit-mode radio click handler. */
426 void on_active_mode_clicked(int id);
427
428 /** @brief "Choose line color" click handler. */
430 /** @brief "Undo point" click handler. */
432 /** @brief "Add line" click handler. */
434 /** @brief Line name edit finished handler. */
436 /** @brief Closed-checkbox toggle handler. */
437 void on_active_line_closed_toggled(bool checked);
438
439 /** @brief Template combo change handler. */
440 void on_active_template_combo_changed(const QString& text);
441 /** @brief "Choose template color" click handler. */
443 /** @brief "Add template" click handler. */
445
446 /** @brief Streams list item change handler (checkbox column). */
447 void on_stream_item_changed(QTreeWidgetItem* item, int column);
448
449private:
450 // common
451 /** @brief Tab widget hosting add/streams/active tabs. */
452 QTabWidget* tabs;
453 /** @brief Reserved names used for uniqueness checks. */
455
456 // add tab
458 QLineEdit* name_edit;
459
460 QButtonGroup* mode_group;
461 QRadioButton* file_radio;
462 QRadioButton* local_radio;
463 QRadioButton* url_radio;
465
467 QLineEdit* file_path_edit;
468 QPushButton* choose_file_btn;
469 QCheckBox* loop_checkbox;
470
473 QPushButton* refresh_local_btn;
474
476 QLineEdit* url_edit;
477
478 QPushButton* add_btn;
479 QPlainTextEdit* add_log_view;
480
481 // streams tab
483 QTreeWidget* streams_list;
484 QPlainTextEdit* event_log_view;
485
486 // active tab
487 QWidget* active_tab { nullptr };
488 QComboBox* active_combo { nullptr };
489 QCheckBox* active_labels_cb = nullptr;
490
492 QButtonGroup* active_mode_group { nullptr };
493 QRadioButton* active_mode_draw_radio { nullptr };
494 QRadioButton* active_mode_template_radio { nullptr };
495
497 QLineEdit* active_line_name_edit { nullptr };
498 QCheckBox* active_line_closed_cb { nullptr };
499 QPushButton* active_line_color_btn { nullptr };
501 QPushButton* active_line_undo_btn { nullptr };
502 QPushButton* active_line_save_btn { nullptr };
503
505 QComboBox* active_template_combo { nullptr };
506 QPushButton* active_template_color_btn { nullptr };
508 QPushButton* active_template_add_btn { nullptr };
509
510 QPlainTextEdit* active_log_view = nullptr;
511};
512
513#endif // YODAU_FRONTEND_WIDGETS_SETTINGS_PANEL_HPP
void clear_active()
Clear active mode and return the active cell to the grid.
Definition board.cpp:66
board(QWidget *parent=nullptr)
Construct the board widget.
Definition board.cpp:8
void set_active_stream(const QString &name)
Make a stream active by name.
Definition board.cpp:34
stream_cell * active_cell() const
Get the currently active (focused) stream cell, if any.
Definition board.cpp:32
grid_view * grid_mode() const
Access the grid view (thumbnail mode).
Definition board.cpp:30
stream_cell * take_active_cell()
Detach and return the active cell without putting it back to grid.
Definition board.cpp:80
bool drawing_new_mode
True if active edit mode is "draw new line".
void on_active_template_selected(const QString &template_name)
Handler for selecting a template while in template mode.
static QString points_str_from_pct(const std::vector< QPointF > &pts)
Convert draft points to backend format string.
void on_active_line_undo_requested()
Handler for undoing last draft point.
void update_analysis_caps()
Update backend analysis interval based on visible tile count.
void update_repaint_caps()
Update repaint interval caps for all visible tiles.
void on_backend_event(const yodau::backend::event &e)
Handle a single backend event (GUI-thread safe).
QColor draft_line_color
Draft line preview color.
void on_active_template_color_changed(const QColor &color)
Handler for changing template preview color.
QMap< QString, std::vector< stream_cell::line_instance > > per_stream_lines
Per-stream persistent line instances keyed by stream name.
QMap< QString, bool > stream_loops
Remembered stream loop flags keyed by stream name.
stream_cell * active_cell_checked(const QString &fail_prefix)
Get active cell or log a failure.
void on_active_template_add_requested(const QString &template_name, const QColor &color)
Handler for adding the selected template to the active stream.
QMap< QString, QUrl > stream_sources
Remembered stream sources (as QUrl) keyed by stream name.
void on_active_edit_mode_changed(bool drawing_new)
Handler for toggling active edit mode.
static QString now_ts()
Current wall-clock timestamp as human-readable string.
void on_backend_events(const std::vector< yodau::backend::event > &evs)
Handle a batch of backend events.
yodau::backend::stream_manager * stream_mgr
Backend stream manager (non-owning).
void handle_add_url(const QString &url, const QString &name)
Handler for adding a network URL stream from UI.
void on_active_line_params_changed(const QString &name, const QColor &color, bool closed)
Handler for changes to "new line" draft parameters.
QSet< QString > used_template_names_for_stream(const QString &stream) const
Collect template names already used by a stream.
void register_stream_in_ui(const QString &final_name, const QString &source_desc)
Add newly created backend stream into UI structures.
void handle_backend_event(const QString &text)
Append a textual message to the "active log" in settings.
void setup_grid_connections()
Connect grid_view signals to controller handlers.
void handle_show_stream_changed(const QString &name, bool show)
Handler for stream visibility toggles in UI.
void apply_added_line(stream_cell *cell, const QString &final_name, const std::vector< QPointF > &pts, bool closed)
Apply effects of a newly added line to UI and state.
void log_active(const QString &msg) const
Append a message to the active log (if settings exists).
void handle_detect_local_sources()
Handler for detecting available local sources.
stream_cell * tile_for_stream_name(const QString &name) const
Resolve a tile widget for a given stream name.
QStringList template_candidates_excluding(const QSet< QString > &used) const
List templates not present in a given used set.
void handle_back_to_grid()
Return to grid mode (clear active stream).
QMap< QString, tpl_line > templates
Template registry keyed by template name.
void on_active_line_save_requested(const QString &name, bool closed)
Handler for saving a newly drawn draft line.
void handle_thumb_activate(const QString &name)
Convenience alias for activating a thumbnail stream.
void on_active_labels_enabled_changed(bool on)
Handler for toggling persistent label visibility in active view.
void sync_active_cell_lines() const
Push per-stream persistent lines into the active UI cell.
void handle_add_local(const QString &source, const QString &name)
Handler for adding a local capture device from UI.
void sync_active_persistent()
Sync persistent line overlays and template candidates for active stream.
int active_interval_ms
Repaint interval for active (focused) stream in ms.
grid_view * grid
Grid view extracted from board (non-owning).
yodau::backend::frame frame_from_image(const QImage &image) const
Convert a QImage into backend frame.
void setup_settings_connections()
Connect settings_panel signals to controller slots.
void handle_enlarge_requested(const QString &name)
Handle focus/enlarge requests from grid tiles.
void apply_template_preview(const QString &template_name)
Apply a template preview into the active cell draft.
settings_panel * settings
Settings panel (non-owning).
void handle_add_stream_common(const QString &source, const QString &name, const QString &type, bool loop)
shared implementation for add-stream commands.
bool active_labels_enabled
Whether labels are enabled in active cell.
static int repaint_interval_for_count(int n)
Choose repaint interval given number of visible streams.
board * main_zone
Main board/zone widget (non-owning).
QString active_name
Name of currently active stream (empty if none).
void init_from_backend()
Populate settings UI from backend at startup.
QString draft_line_name
Draft line name being edited.
int idle_interval_ms
Repaint interval for idle grid streams in ms.
bool draft_line_closed
Draft line closed flag.
void on_gui_frame(const QString &stream_name, const QImage &image)
Slot receiving GUI frames from stream tiles.
grid_view(QWidget *parent=nullptr)
Construct an empty grid view.
Definition grid_view.cpp:13
void remove_stream(const QString &name)
Remove a stream cell from the grid.
Definition grid_view.cpp:60
void add_stream(const QString &name)
Add a new stream cell to the grid.
Definition grid_view.cpp:40
stream_cell * peek_stream_cell(const QString &name) const
Get a pointer to a cell without removing it.
void stream_enlarge(const QString &name)
Emitted when a stream cell requests focus/enlargement.
QLineEdit * name_edit
void add_stream_entry(const QString &name, const QString &source, bool checked=false) const
Add a stream row to the streams list.
void active_line_undo_requested()
Emitted when user requests undo of the last draft point.
QWidget * build_streams_tab()
Build the "streams" tab.
QPushButton * active_line_undo_btn
QSet< QString > existing_names
Reserved names used for uniqueness checks.
void on_active_template_add_clicked()
"Add template" click handler.
QPushButton * choose_file_btn
void show_stream_changed(const QString &name, bool show)
Emitted when a stream's "show in grid" state changes.
settings_panel(QWidget *parent=nullptr)
Construct the settings panel.
void append_event(const QString &text) const
Append a line to the streams-tab event log.
QLineEdit * active_line_name_edit
void set_btn_color(QPushButton *btn, const QColor &c) const
Paint a QPushButton background to match a chosen color.
void append_active_log(const QString &msg) const
Append a line to the active-tab log.
void clear_add_inputs() const
Clear all add-tab input fields and reset validation.
bool current_input_valid() const
Validate that required input fields for current mode are filled.
QWidget * build_templates_box(QWidget *parent)
Build templates form box.
QGroupBox * active_mode_box
void reset_active_template_form()
Reset the templates form to "none" selection.
QRadioButton * url_radio
QPushButton * refresh_local_btn
void reset_active_line_form()
Reset the "new line" form in the active tab.
QWidget * build_active_tab()
Build the "active" tab.
void update_add_enabled() const
Update enabled state of the "add" button based on validation.
void build_ui()
Build all tabs and root layout.
QPushButton * add_btn
QPlainTextEdit * event_log_view
void on_active_template_color_clicked()
"Choose template color" click handler.
void set_stream_checked(const QString &name, bool checked) const
Set the "show" checkbox state for a stream entry.
void active_template_selected(const QString &template_name)
Emitted when template selection changes.
QPlainTextEdit * add_log_view
void add_local_stream(const QString &source, const QString &name)
User requested adding a local capture stream.
void set_name_error(bool error) const
Apply/remove UI error styling for name edit.
void on_active_line_color_clicked()
"Choose line color" click handler.
void on_active_line_closed_toggled(bool checked)
Closed-checkbox toggle handler.
void remove_stream_entry(const QString &name) const
Remove a stream entry from the streams list.
QPushButton * active_template_add_btn
void on_add_clicked()
"Add" button handler.
QTreeWidget * streams_list
QTabWidget * tabs
Tab widget hosting add/streams/active tabs.
void append_add_log(const QString &text) const
Append a line to the add-tab log.
void on_active_template_combo_changed(const QString &text)
Template combo change handler.
void clear_stream_entries()
Remove all stream entries and clear name reservations.
QWidget * build_active_stream_box(QWidget *parent)
Build active-stream selection box.
void add_existing_name(const QString &name)
Add one name to the existing-name set.
QPushButton * active_template_color_btn
void set_active_line_closed(bool closed) const
Programmatically set active draft "closed" checkbox.
QPushButton * active_line_save_btn
void active_stream_selected(const QString &name)
Emitted when the active stream selection changes.
void active_line_save_requested(const QString &name, bool closed)
Emitted when user clicks "add line" in active tab.
bool name_is_unique(const QString &name) const
Check if name is not already reserved.
input_mode current_mode
void active_edit_mode_changed(bool drawing_new)
Emitted when edit mode changes.
void active_labels_enabled_changed(bool on)
Emitted when label visibility toggle changes.
void active_line_params_changed(const QString &name, const QColor &color, bool closed)
Emitted when any draft-line parameter changes.
QString resolved_name_for_current_input() const
Resolve the name for the current input (trimmed).
QComboBox * active_combo
void on_active_mode_clicked(int id)
Edit-mode radio click handler.
QCheckBox * active_line_closed_cb
QGroupBox * add_local_box
void set_local_sources(const QStringList &sources) const
Set detected local sources (e.g., /dev/video*).
input_mode
Input mode for the add-tab.
QRadioButton * active_mode_draw_radio
void update_add_tools() const
Update visibility/enabled state of add-tab tool boxes.
QCheckBox * loop_checkbox
void active_template_add_requested(const QString &template_name, const QColor &color)
Emitted when user adds a template instance to active stream.
void active_template_color_changed(const QColor &color)
Emitted when template preview color changes.
QCheckBox * active_labels_cb
void on_active_line_save_clicked()
"Add line" click handler.
void remove_existing_name(const QString &name)
Remove one name from the existing-name set.
void detect_local_sources_requested()
User requested re-detection of local sources.
QString active_template_current() const
Get currently selected template name.
void set_template_candidates(const QStringList &names) const
Replace the list of template candidates.
QColor active_template_preview_color() const
Get current preview color for templates.
QComboBox * local_sources_combo
void add_template_candidate(const QString &name) const
Add one template name as a candidate in the templates combo.
QGroupBox * add_url_box
QGroupBox * active_line_box
QButtonGroup * active_mode_group
QWidget * build_edit_mode_box(QWidget *parent)
Build edit-mode radio group.
QWidget * build_add_tab()
Build the "add stream" tab.
QRadioButton * local_radio
void set_active_candidates(const QStringList &names) const
Set the list of streams that can be selected as active.
void on_active_line_name_finished()
Line name edit finished handler.
void set_mode(input_mode mode)
Switch add-tab mode and refresh enabled/visible controls.
QRadioButton * file_radio
void on_name_changed(QString text) const
Handler for name edit changes (validation).
void on_refresh_local()
"Refresh local sources" handler.
void on_active_line_undo_clicked()
"Undo point" click handler.
void clear_active_log() const
Clear the active-tab log view.
void set_existing_names(QSet< QString > names)
Replace the set of existing (reserved) names.
QPushButton * active_line_color_btn
QPlainTextEdit * active_log_view
QLineEdit * file_path_edit
QButtonGroup * mode_group
void on_stream_item_changed(QTreeWidgetItem *item, int column)
Streams list item change handler (checkbox column).
void update_active_tools() const
Show/hide active-tab tool boxes based on selection/mode.
QLineEdit * url_edit
void set_active_current(const QString &name) const
Programmatically select the active stream.
QRadioButton * active_mode_template_radio
QWidget * build_new_line_box(QWidget *parent)
Build "new line" form box.
QGroupBox * add_file_box
void on_choose_file()
File chooser handler.
void add_url_stream(const QString &url, const QString &name)
User requested adding a URL stream.
QGroupBox * active_templates_box
QComboBox * active_template_combo
void add_event(const QPointF &pos_pct, const QColor &color)
Add a transient event marker.
QImage last_frame
Most recent received frame as an image.
void mousePressEvent(QMouseEvent *event) override
Mouse press handler for drawing draft points.
int repaint_interval_ms
Minimum repaint interval in ms.
QHash< QString, QDateTime > line_highlights
Line highlight timestamps by line name.
std::vector< QPointF > draft_line_points_pct
Draft polyline points in percentage coordinates.
void set_loop(bool on)
Enable or disable looping for file-based playback.
void mouseMoveEvent(QMouseEvent *event) override
Mouse move handler for hover updates while drawing.
QMediaPlayer * player
Media player for file/URL sources.
void update_icon()
Update focus button icon/tooltip based on active state.
QPushButton * close_btn
UI close button (top-right).
void draw_hover_point(QPainter &p) const
Draw hover point indicator (if any).
bool is_active() const
Check whether this cell is currently active (focused).
bool active
Whether the cell is focused/active.
bool drawing_enabled
Whether interactive drawing is enabled.
QString draft_line_name
Draft line name.
std::vector< line_instance > persistent_lines
Persisted lines to render.
bool labels_enabled
Whether persistent line labels are shown when active.
void set_active(bool val)
Set active (focused) state.
void set_repaint_interval_ms(int ms)
Set minimum repaint interval for video frame updates.
QHash< QString, hit_info > line_hits
Optional hit positions per line name.
void draw_stream_name(QPainter &p) const
Draw stream name overlay at top-left.
void set_source(const QUrl &source)
Set media player source.
void set_persistent_lines(const std::vector< line_instance > &lines)
Replace all persistent lines.
bool draft_closed() const
Get whether current draft line is closed.
void set_camera_id(const QByteArray &id)
Switch to camera input by device id.
void paintEvent(QPaintEvent *event) override
Paint handler.
void draw_preview_segment(QPainter &p) const
Draw preview segment from last draft point to hover point.
QCamera * camera
Active camera (if using live input).
QColor draft_line_color
Draft line color.
void set_labels_enabled(bool on)
Enable or disable rendering of persistent line labels.
void draw_draft(QPainter &p) const
Draw the draft line (if any).
QVideoSink * sink
Video sink feeding decoded frames into the widget.
QByteArray camera_id
Selected camera id.
int line_highlight_ttl_ms
Highlight time-to-live in ms.
void clear_draft()
Clear all draft data (points, hover point, preview flag).
void clear_persistent_lines()
Remove all persistent lines.
QMediaCaptureSession * session
Capture session binding camera to sink.
QLabel * name_label
Optional name label (unused in current implementation).
void leaveEvent(QEvent *event) override
Leave handler to clear hover state.
void draw_persistent(QPainter &p) const
Draw all persistent lines and their labels/highlights.
void on_camera_error(QCamera::Error error)
Slot called on camera errors.
QElapsedTimer repaint_timer
Timer throttling repaint frequency.
void draw_events(QPainter &p)
Draw transient events and prune expired ones.
void set_draft_preview(bool on)
Enable or disable draft preview mode.
QPointF to_px(const QPointF &pos_pct) const
Convert percentage coordinates to pixel position.
void set_draft_points_pct(const std::vector< QPointF > &pts)
Replace current draft points (percentage coordinates).
const QString & get_name() const
Get logical name of this stream cell.
bool loop_enabled
Whether playback looping is enabled.
QPushButton * focus_btn
UI focus/enlarge button (top-right).
QString name
Logical stream name.
void draw_poly_with_points(QPainter &p, const std::vector< QPointF > &pts_pct, const QColor &color, bool closed, Qt::PenStyle style, qreal width) const
Draw a polyline/polygon with point markers.
void add_persistent_line(const line_instance &line)
Append a persistent line to the list.
void draw_hover_coords(QPainter &p) const
Draw hover coordinate text (if enabled).
QColor draft_color() const
Get current draft line color.
QPointF label_pos_px(const line_instance &l) const
Compute label anchor position for a line in pixel coordinates.
void set_drawing_enabled(bool on)
Enable or disable interactive drawing on this cell.
bool draft_line_closed
Draft line closed flag.
QString draft_name() const
Get current draft line name.
QString last_error
Last error string to display when no frame is available.
QVector< event_instance > events
Transient events currently displayed.
void keyPressEvent(QKeyEvent *event) override
Key press handler for draft undo.
void build_ui()
Build child UI widgets (buttons, sink/player connections).
std::vector< QPointF > draft_points_pct() const
Get current draft polyline points (percentage coordinates).
void on_media_status_changed(QMediaPlayer::MediaStatus status)
Slot called on media status changes.
bool draft_preview
Whether draft line is shown in preview mode.
QPointF to_pct(const QPointF &pos_px) const
Convert pixel position to percentage coordinates.
bool is_draft_preview() const
Check whether the draft is in preview-only mode.
std::optional< QPointF > hover_point_pct
Current hover position in percentage coordinates.
Central coordinator for streams, geometry, frame processing and events.
Represents a single video stream and its analytic connections.
Definition stream.hpp:64
event_kind
High-level classification of backend events.
Definition event.hpp:19
pixel_format
Pixel format of a frame buffer.
Definition frame.hpp:16
stream_type
Source/transport type of a video stream.
Definition stream.hpp:23
#define str_label(text)
Create a user-visible localized label.
Definition str_label.hpp:29
Stored template geometry (percentage coordinates).
std::vector< QPointF > pts_pct
Template vertices in percentage coordinates.
bool closed
Whether template is closed.
Instance of a transient visual event marker.
QPointF pos_pct
Event position in percentage coordinates.
QDateTime ts
Timestamp when event was added.
Hit info attached to a line highlight.
QDateTime ts
Hit timestamp.
QPointF pos_pct
Hit position in percentage coordinates.
Instance of a persistent (saved) line to be rendered on the stream.
Generic event produced by the backend.
Definition event.hpp:44
event_kind kind
Type of the event.
Definition event.hpp:50
std::string line_name
Name of the line / ROI / rule responsible for this event.
Definition event.hpp:86
Video frame container.
Definition frame.hpp:44
int width
Frame width in pixels.
Definition frame.hpp:48
int stride
Number of bytes per row.
Definition frame.hpp:60
int height
Frame height in pixels.
Definition frame.hpp:53
pixel_format format
Pixel format of the buffer.
Definition frame.hpp:67