settings_class
Classes
|
A class representing a single configuration setting. |
|
Manages system settings, including storage, retrieval, and grouping. |
- class Setting(key: str, factory_value: Any, value_type: type, description: str)[source]
Bases:
objectA class representing a single configuration setting.
- key
The name/identifier of the setting.
- Type:
str
- value
The current value of the setting.
- Type:
Any
- value_type
The expected type of the value (e.g., int, float, str, enum).
- Type:
type
- description
A description of what the setting controls.
- Type:
str
- type0
The base type (e.g., list if value_type is list[int]).
- Type:
type
- type1
The inner type for lists (e.g., int if value_type is list[int]).
- Type:
type | None
- class Settings(main_settings: list[Setting], sound_settings: list[Setting], screen_settings: list[Setting], touchscreen_settings: list[Setting], telegram_settings: list[Setting], directory_settings: list[Setting], sync_settings: list[Setting], server_settings: list[Setting], device_settings: list[Setting], hourly_alarm_settings: list[Setting], cycle_alarm_settings: list[Setting], session_alarm_settings: list[Setting], cam_framerate_settings: list[Setting], corridor_settings: list[Setting], extra_settings: list[Setting], controller_settings: list[Setting], bpod_settings: list[Setting], camera_settings: list[Setting], motor_settings: list[Setting], visual_settings: list[Setting], hidden_settings: list[Setting])[source]
Bases:
objectManages system settings, including storage, retrieval, and grouping.
Settings are grouped by category (main, sound, screen, etc.) and backed by QSettings for persistent storage.
- restore_factory_settings() None[source]
Reset all restorable settings to their factory default values.
- restore_visual_settings() None[source]
Reset visual settings to their factory default values.
- restore_directory_settings() None[source]
Reset directory settings to their factory default values.
- create_factory_settings() None[source]
Initialize all settings with their factory defaults in QSettings.
- add_new_settings() None[source]
Add any missing settings to QSettings with their default values.
- check_settings() None[source]
Ensure all required settings exist in storage.
If it’s the first launch, creates all factory settings. Otherwise, adds any new settings that are missing.
- get(key: str) Any[source]
Retrieve the value of a setting.
- Parameters:
key (str) – The identifier of the setting.
- Returns:
The value of the setting converted to its appropriate type, or None if the setting or value is invalid.
- Return type:
Any
- get_text(key: str) str[source]
Get the string representation of the value of a setting.
- get_values(key: str) list[source]
Get the possible values of a setting when it is a enum or list of enums
- get_index(key: str) int[source]
Get the index of the value of a setting when it is a enum or list of enums
- get_indices(key: str) list[int][source]
Get the index of the value of a setting when it is a enum or list of enums
- get_description(key: str) str[source]
Get the description of a setting.
- get_type(key: str) type | None[source]
Get the type of a setting.
- set(key: str, value: Any) None[source]
- sync() None[source]
- print() None[source]