UI Config Manager#

class UIConfigManager[source]#

Manages the user interface configuration settings.

This includes the management of header and footer text for exported PDFs, custom fonts, font paths, and an optional branding logo. The class also handles the downloading of default fonts if they are not already present.

property config: Dict[source]#

Retrieves the current UI configuration from property list, or creates default configuration.

Returns:

Retrieved UI configuration settings or default config.

Return type:

Dict

property fonts_present: bool#

This property verifies if the required font files (regular and bold) are present in the expected directory.

Returns:

True if the fonts are present.

Return type:

bool

create_default_config()[source]#

This method writes default values for header text, footer text, font paths and optional branding logo into the property list file. It also ensures that the necessary fonts are downloaded if they are not already present.

reset_config() bool[source]#

Removes all existing UI settings from the property list file.

This method is useful if the user wants to reconfigure the UI elements of PDF reports, such as header/footer text, font choices, and branding logo.

See Resetting Patcher for more details.

Returns:

True if the reset was successful.

Return type:

bool

setup_ui()[source]#

Guides the user through configuring UI settings for PDF reports, including header/footer text, font choices, and an optional branding logo.

Note

This function is used solely by the Setup class during initial setup.

configure_font() Dict[str, str][source]#

Allows the user to specify a custom font or use the default provided by the application. The chosen fonts are copied to the appropriate directory for use in PDF report generation.

Returns:

A dictionary containing the font name, regular font path, and bold font path.

Return type:

Dict [str, str]

Configures the logo file for PDF reports based on user input.

If a logo file is specified, it is validated and copied to Patcher’s Application Support directory. Similar to configure_font() this method is solely used in conjunction with the Setup class.

Returns:

The path to the saved logo file, or None if no logo is configured.

Return type:

Optional [str]

Raises:
  • SetupError – If the provided logo path does not exist.

  • PatcherError – If the provided logo fails pillow validation.

  • PatcherError – If the logo file could not be copied to the destination path.

get_logo_path() str | None[source]#

Retrieves the logo path from the UI configuration.

Returns:

The logo path as a string if it exists, else None.

Return type:

Union str | None]