core.generator.ui.contents.image_content

File:

EuljiroWorship/core/generator/ui/contents/image_content.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.

UI content widget for editing “image”-style slides.

This module defines core.generator.ui.contents.image_content.ImageContent, a QWidget that allows users to select an image file, preview it, and associate it with caption text for use in image-based slides. Selected images are copied into a local img/ directory for reliable access by overlay HTML files.

In this slide style, the headline field is repurposed to store the relative image path, while the caption field is used as accompanying text displayed alongside the image.

The widget integrates with core.generator.utils.slide_input_submitter.SlideInputSubmitter to support automatic submission and synchronization with the parent generator window.

class core.generator.ui.contents.image_content.ImageContent(*args, **kwargs)[source]

Bases: QWidget

Content editor widget for “image” style slides.

This widget supports selecting an image file, copying it into the local overlay image directory, previewing it, and editing an optional caption.

In the slide schema used by this project:

  • style is fixed to "image".

  • headline stores the (relative) image path used by the overlay.

  • caption stores optional text associated with the image.

The widget integrates with the generator window via core.generator.utils.slide_input_submitter.SlideInputSubmitter so that changes can be submitted automatically.

Parameters:
  • caption (str)

  • headline (str)

caption

Initial caption value passed at construction time.

Type:

str

headline

Initial headline value passed at construction time. For this style, it represents an image path (typically relative).

Type:

str

generator_window

Reference to the generator window that receives live slide updates and manages auto-save/session logic.

headline_label

Label describing the image-path input field.

Type:

QLabel

headline_edit

Input field that stores the relative image path (slide headline).

Type:

QLineEdit

caption_label

Label describing the caption input field.

Type:

QLabel

caption_edit

Input field that stores caption text (slide caption).

Type:

QLineEdit

image_button

Button that opens the file picker to select an image file.

Type:

QPushButton

image_preview

Preview area that displays the selected image (scaled to fit).

Type:

QLabel

submitter

Auto-submit helper that observes inputs and provides updated slide payloads via build_image_slide().

Type:

SlideInputSubmitter

__init__(parent, generator_window, caption='', headline='')[source]

Initialize the image content editor.

Parameters:
  • parent (QWidget) – Parent widget container.

  • generator_window – Reference to the generator window, used for submitting slide data and enabling auto-save behavior.

  • caption (str) – Initial caption text associated with the image.

  • headline (str) – Initial image path (stored in the headline field).

Returns:

None

build_ui()[source]

Construct the UI elements for editing an image slide.

This method builds input fields for caption and image path, a button for selecting an image file, and an image preview area. It also registers the input fields with core.generator.utils.slide_input_submitter.SlideInputSubmitter to enable automatic submission.

Parameters:

None

Returns:

None

select_image()[source]

Prompt the user to select an image file and register it for slide use.

The selected image is copied into the local image directory and its relative path is stored in the headline field. A preview of the image is displayed in the UI.

Parameters:

None

Returns:

None

copy_to_img_folder(source_path)[source]

Copy the selected image file into the local image directory.

If the destination directory does not exist, it is created. If the image already exists at the destination, it is not copied again.

Parameters:

source_path (str) – Absolute path to the source image file.

Returns:

Relative image path suitable for use in overlay HTML (e.g., img/example.png).

Return type:

str

Raises:

OSError – If the file cannot be copied or the destination directory cannot be created.

build_image_slide()[source]

Conditionally generate image slide data.

If no image path has been selected, no slide data is generated. Otherwise, the current inputs are returned as a slide data dictionary.

Parameters:

None

Returns:

Slide data dictionary if an image is selected; otherwise, None.

Return type:

dict | None

get_slide_data()[source]

Generate the slide data dictionary for an image slide.

Parameters:

None

Returns:

Dictionary representing the image slide, including:

  • style

  • caption

  • headline (relative image path)

Return type:

dict

set_content(data)[source]

Restore saved image slide data into the editor UI.

This method populates the caption and image path fields and attempts to load and preview the referenced image.

Parameters:

data (dict) – Slide data dictionary containing caption and image path.

Returns:

None