core.generator.utils.slide_input_submitter
- File:
EuljiroWorship/core/generator/utils/slide_input_submitter.py
- Author:
Benjamin Jaedon Choi - https://github.com/saintbenjamin
- Affiliated Church:
The Eulji-ro Presbyterian Church [대한예수교장로회(통합) 을지로교회]
- Address:
The Eulji-ro Presbyterian Church, 24-10, Eulji-ro 20-gil, Jung-gu, Seoul 04549, South Korea
- Telephone:
+82-2-2266-3070
- E-mail:
euljirochurch [at] G.M.A.I.L. (replace [at] with @ and G.M.A.I.L as you understood.)
- License:
MIT License with Attribution Requirement (see LICENSE file for details); Copyright (c) 2025 The Eulji-ro Presbyterian Church.
Handles submission logic for slide input forms in the slide generator UI.
This module defines core.generator.utils.slice_input_submitter.SlideInputSubmitter, which listens for Enter key presses
on specified input widgets and triggers slide generation. It allows Shift+Enter
to insert line breaks in multi-line fields.
- class core.generator.utils.slide_input_submitter.SlideInputSubmitter(*args, **kwargs)[source]
Bases:
QObjectEvent-filter helper that submits slide edits when the user presses Enter.
This class installs itself as an event filter on a set of input widgets and interprets the Enter/Return key as a submission trigger for slide data editing. It provides a uniform, keyboard-driven submission mechanism across different content editors without embedding submission logic into individual widgets.
Key behaviors:
Enter / Return triggers slide submission.
Shift + Enter is treated as a literal newline and does not submit.
Widgets explicitly listed as ignored are excluded from Enter-submit handling.
Submission is performed by invoking a caller-provided slide builder callback. If the callback returns no data, submission is aborted silently. If submission succeeds and the owning generator exposes a save routine, the current slide session is automatically persisted.
This helper is intentionally UI-agnostic: it does not know slide styles, widget semantics, or table structure. Its sole responsibility is to translate keyboard events into submission intent and delegate the actual data construction to the caller.
Note
Submission is performed by calling
build_slide_func(). If it returns a falsy value (None / empty), nothing happens. If the generator exposescore.generator.ui.slide_generator.SlideGenerator.save_slides_to_file(), the submitter will save automatically after a successful build.- Parameters:
inputs (dict[str, PySide6.QtWidgets.QWidget])
generator (PySide6.QtWidgets.QWidget)
build_slide_func (Callable[[], dict | list | None])
- inputs
Mapping of logical input names to widget instances monitored for Enter/Return key submission.
- Type:
dict[str, QWidget]
- generator
Owning generator/controller object. If it provides a save method, it will be invoked after successful submission.
- Type:
QWidget
- build_slide_func
Callback that constructs slide data from current widget state.
- Type:
Callable[[], dict | list | None]
- ignore_widgets
Widgets whose Enter key events should bypass submission handling.
- Type:
list[QWidget]
- __init__(inputs, generator, build_slide_func, ignore_widgets=None)[source]
Initialize the submitter and install event filters on input widgets.
- Parameters:
inputs (dict[str, QWidget]) – Widgets to monitor for Enter-submit.
generator (QWidget) – Receiver/owner that performs persistence operations.
build_slide_func (Callable[[], dict | list | None]) – Slide builder callback.
ignore_widgets (list[QWidget] | None) – Widgets to exclude from Enter-submit.
- eventFilter(obj, event)[source]
Intercept keypress events to detect Enter-submit.
If
objis inignore_widgets, this filter does nothing.- If the key is Enter/Return:
Shift+Enter passes through (newline behavior).
Otherwise, submit and consume the key event.
- Parameters:
obj – Event source object (typically one of the registered widgets).
event – Incoming Qt event.
- Returns:
True if the event was handled here (consumed), else False.
- Return type:
bool
- try_submit_slide()[source]
Build and persist slide data using the registered callback.
Workflow:
Call
build_slide_func()to obtain slide data.If slide data is falsy, do nothing.
If the generator provides
core.generator.ui.slide_generator.SlideGenerator.save_slides_to_file(), save silently.Restore focus to the first registered input widget for fast iteration.