Application layer¶
Application orchestration components: main window, app services, and bootstrap flow.
📦 EzQt_App¶
EzQt_App
¶
Bases: QMainWindow
Main EzQt_App application.
This class represents the main application window with all its components (menu, pages, settings, etc.).
Initialize the EzQt_App application.
no_menu
¶
no_menu() -> EzQt_App
Disable the left menu for this application instance.
Returns:
| Name | Type | Description |
|---|---|---|
EzQt_App |
EzQt_App
|
Self instance for chaining. |
no_settings_panel
¶
no_settings_panel() -> EzQt_App
Disable the settings slide-in panel for this application instance.
Returns:
| Name | Type | Description |
|---|---|---|
EzQt_App |
EzQt_App
|
Self instance for chaining. |
build
¶
build() -> EzQt_App
Explicitly build the UI layout.
Automatically called on first show() if not called.
Returns:
| Name | Type | Description |
|---|---|---|
EzQt_App |
EzQt_App
|
Self instance for chaining. |
showEvent
¶
Ensure UI is built before showing the window.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
QShowEvent
|
The QShowEvent instance. |
required |
set_app_theme
¶
Update and apply the application theme based on current settings.
The theme was already persisted and applied to SettingsService by
_on_theme_selector_changed before this slot fires. We only need to
trigger a full UI refresh here.
refresh_theme
¶
refresh_theme() -> EzQt_App
Re-apply the theme stylesheet and polish all widgets.
Call this after adding custom widgets to the application to ensure
that QSS rules (especially #objectName selectors) are correctly
evaluated against the newly added widgets. Also refreshes all
ThemeIcon instances so that icons added after build() (e.g.
via add_menu()) are correctly coloured for the current theme.
Returns:
| Name | Type | Description |
|---|---|---|
self |
EzQt_App
|
Allows method chaining. |
Example::
window = EzQt_App().build()
window.show()
add_things_to_my_app(window, Icons)
window.refresh_theme()
set_app_icon
¶
Set the application logo in the header.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
icon
|
str | QPixmap
|
Path to icon or QPixmap object. |
required |
y_shrink
|
int
|
Vertical shrink factor. |
0
|
y_offset
|
int
|
Vertical offset adjustment. |
0
|
add_menu
¶
Add a new menu item and corresponding page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Label for the menu and page. |
required |
icon
|
str
|
Icon name or path. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
QWidget |
QWidget
|
The created page widget. |
resizeEvent
¶
Handle window resize events to update UI components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_event
|
QResizeEvent
|
The QResizeEvent instance (unused). |
required |
mousePressEvent
¶
Handle mouse press events for window dragging and diagnostics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
QMouseEvent
|
The QMouseEvent instance. |
required |
set_credits
¶
Set credit text in the bottom bar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
credits
|
Any
|
Text or object to display as credits. |
required |
set_version
¶
Set version text in the bottom bar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
version
|
str
|
Version string to display. |
required |
get_translation_stats
¶
Retrieve current translation statistics.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict[str, Any]
|
Statistics about translated and missing strings. |
enable_auto_translation
¶
Enable or disable automatic translation collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enabled
|
bool
|
Whether to enable auto-translation. |
True
|
collect_strings_for_translation
¶
collect_strings_for_translation(widget: QWidget | None = None, recursive: bool = True) -> dict[str, Any]
Scan widgets for translatable strings and add them to the collector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
widget
|
QWidget | None
|
Root widget to start scanning from (default: self). |
None
|
recursive
|
bool
|
Whether to scan child widgets recursively. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict[str, Any]
|
Summary of the collection process. |
get_new_strings
¶
Get all newly discovered strings since last save.
Returns:
| Type | Description |
|---|---|
set[str]
|
set[str]: Set of new translatable strings. |
get_string_collector_stats
¶
Get statistics from the string collector.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict[str, Any]
|
Collector statistics. |
📦 AppService¶
AppService
¶
Central orchestration service for application lifecycle.
Aggregates config, asset, resource and settings operations into a single cohesive snake_case API used by widgets, CLI and bootstrap.
check_assets_requirements
staticmethod
¶
check_assets_requirements(base_path: Path | None = None, bin_path: Path | None = None, overwrite_policy: str = 'ask') -> None
Generate asset binaries, QRC and RC files at APP_PATH.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_path
|
Path | None
|
Optional base path for assets. |
None
|
bin_path
|
Path | None
|
Optional binary path. |
None
|
overwrite_policy
|
str
|
Policy for overwriting existing files (default: "ask"). |
'ask'
|
make_required_files
staticmethod
¶
make_required_files(mk_theme: bool = True, mk_config: bool = True, mk_translations: bool = True, base_path: Path | None = None, bin_path: Path | None = None, overwrite_policy: str = 'ask') -> None
Copy YAML, QSS theme and translation files into project directories.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mk_theme
|
bool
|
When True also copies the QSS theme file. |
True
|
mk_config
|
bool
|
When True copies configuration files. |
True
|
mk_translations
|
bool
|
When True copies translation files. |
True
|
base_path
|
Path | None
|
Optional base path. |
None
|
bin_path
|
Path | None
|
Optional binary path. |
None
|
overwrite_policy
|
str
|
Policy for overwriting (default: "ask"). |
'ask'
|
set_project_root
staticmethod
¶
Set the project root directory used by the config service.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_root
|
Path
|
The Path to the project root. |
required |
load_config
staticmethod
¶
Load a named configuration from its YAML file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_name
|
str
|
Logical name of the configuration (e.g. "app"). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict[str, Any]
|
The loaded configuration data. |
get_config_value
staticmethod
¶
Get a value from a named configuration using dot-separated path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_name
|
str
|
Logical name of the configuration. |
required |
key_path
|
str
|
Dot-separated key path, e.g. "app.name". |
required |
default
|
Any
|
Value returned when the path is absent. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The configuration value or default. |
save_config
staticmethod
¶
Persist a named configuration to its YAML file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_name
|
str
|
Logical name of the configuration. |
required |
data
|
dict[str, Any]
|
Full configuration dict to write. |
required |
write_yaml_config
staticmethod
¶
Write a single value into a YAML config using a key list immediately.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
list[str]
|
List where keys[0] is config name and keys[1:] is the path. |
required |
val
|
Any
|
Value to assign at the leaf key. |
required |
stage_config_value
staticmethod
¶
Mutate a config value in the shared cache and mark it dirty for flush.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
list[str]
|
List where keys[0] is config name and keys[1:] is the path. |
required |
val
|
Any
|
Value to assign at the leaf key. |
required |
flush_all
staticmethod
¶
Write all dirty configs to disk and clear the dirty set.
copy_package_configs_to_project
staticmethod
¶
Copy package default configs into the child project directory.
get_package_resource
staticmethod
¶
Return a Path to an installed package resource.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resource_path
|
str
|
Relative path inside the package. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path
|
Absolute path to the resource. |
get_package_resource_content
staticmethod
¶
Return the text content of an installed package resource.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resource_path
|
str
|
Relative path inside the package. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Content of the resource. |
load_fonts_resources
staticmethod
¶
Load .ttf font files into Qt's font database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app
|
bool
|
Whether to also load fonts from the bin/fonts/ directory. |
False
|
load_app_settings
staticmethod
¶
Load app settings from YAML and apply to SettingsService.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict[str, Any]
|
Loaded settings. |
📦 InitService¶
InitService
¶
Coordinates initialization with a single options object.
run
¶
run(options: InitOptions | None = None) -> InitResult
Run initialization sequence with normalized options.
📦 InitOptions¶
InitOptions
dataclass
¶
InitOptions(project_root: Path | None = None, bin_path: Path | None = None, mk_theme: bool = True, mk_config: bool = True, mk_translations: bool = True, build_resources: bool = True, generate_main: bool = False, verbose: bool = True, overwrite_policy: OverwritePolicy = ASK)
Options driving initialization behavior across API and CLI.
Attributes:
| Name | Type | Description |
|---|---|---|
project_root |
Path | None
|
Absolute path to the project root directory. When
|
bin_path |
Path | None
|
Directory where generated assets ( |
mk_theme |
bool
|
Generate QSS theme files under |
mk_config |
bool
|
Generate the |
mk_translations |
bool
|
Generate the |
build_resources |
bool
|
Compile the QRC file with |
generate_main |
bool
|
Write a |
verbose |
bool
|
Print step-by-step progress to stdout. |
overwrite_policy |
OverwritePolicy
|
Controls behavior when generated files already
exist. See :class: |
📦 InitializationSequence¶
InitializationSequence
¶
InitializationSequence(options: InitOptions | None = None)
Orchestrates the ordered initialization steps for EzQt_App.
Each step is registered with a name, description, callable and a required flag. If a required step fails the sequence stops immediately; non-required steps are allowed to fail silently.
add_step
¶
Append a new step to the sequence.