YODAU 1.0
YEAR OF THE DEPEND ADULT UNDERGARMENT
Loading...
Searching...
No Matches
str_label.hpp
Go to the documentation of this file.
1#ifndef YODAU_FRONTEND_HELPERS_STR_LABEL_HPP
2#define YODAU_FRONTEND_HELPERS_STR_LABEL_HPP
3
4#include <QString>
5
6/**
7 * @def str_label(text)
8 * @brief Create a user-visible localized label.
9 *
10 * This macro provides a lightweight abstraction over translation/localization:
11 * - If KC_KDE is defined, it expands to KDE's @c i18n(text) for runtime
12 * translation using KLocalizedString.
13 * - Otherwise it expands to @c QStringLiteral(text) to produce an efficient,
14 * compile-time UTF-16 QString.
15 *
16 * Usage:
17 * @code
18 * auto title = str_label("Settings");
19 * @endcode
20 *
21 * @param text Narrow string literal to translate or wrap as a QString.
22 * @return A localized QString.
23 */
24
25#ifdef KC_KDE
26#include <KLocalizedString>
27#define str_label(text) i18n(text)
28#else
29#define str_label(text) QStringLiteral(text)
30#endif
31
32#endif // YODAU_FRONTEND_HELPERS_STR_LABEL_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.
void active_line_undo_requested()
Emitted when user requests undo of the last draft point.
settings_panel(QWidget *parent=nullptr)
Construct the settings panel.
void clear_add_inputs() const
Clear all add-tab input fields and reset validation.
void reset_active_template_form()
Reset the templates form to "none" selection.
void reset_active_line_form()
Reset the "new line" form in the active tab.
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 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