Skip to content

App Preferences

app.shared.app_preferences

View source code

Module for app preferences; provides reusable helpers across application layers.

See Also

Layer: Shared utilities. Context: Provides reusable helpers across application layers at this architectural boundary.

DEFAULT_DETECTION_MODEL_NAME = 'None' module-attribute

DEFAULT_MIN_DETECTION_CONFIDENCE = 0.25 module-attribute

DEFAULT_CHOSEN_LABELS = ['person', 'cat', 'dog'] module-attribute

DEFAULT_TRACKING_STRATEGY = 'hungarian' module-attribute

DEFAULT_TRACKING_SOURCE = 'b' module-attribute

DEFAULT_REID_EMBEDDING_DIM = 256 module-attribute

DEFAULT_MIN_IOU = 0.3 module-attribute

DEFAULT_MIN_TRACKER_CONFIDENCE = 0.1 module-attribute

DEFAULT_CONFIDENCE_DECAY = 0.05 module-attribute

DEFAULT_OFFLINE_STITCHING_ENABLED = True module-attribute

DEFAULT_MAX_STITCH_GAP = 25 module-attribute

DEFAULT_GSI_SMOOTHNESS = 10.0 module-attribute

DEFAULT_DRAW_BOXES = True module-attribute

DEFAULT_BOX_BORDER_WIDTH = 2 module-attribute

DEFAULT_SHOW_PREVIEW_MASK = False module-attribute

DEFAULT_PREVIEW_BLUR_ENABLED = False module-attribute

DEFAULT_BLUR_ENABLED = False module-attribute

DEFAULT_BLUR_STRENGTH = 15.0 module-attribute

DEFAULT_THEME = 'system' module-attribute

SUPPORTED_THEMES = ('system', 'light', 'dark') module-attribute

AppPreferences dataclass

Persisted application defaults and last-used locations.

Note

Default processing options are copied into sessions when they are created; edits to a session do not mutate these global preferences.

Layer: Shared utilities. Context: Provides reusable cross-layer behavior without owning workflow state.

chosen_labels_text: str property

Return the chosen labels as display text.

RETURNS DESCRIPTION
str

Configured default labels joined with comma-space separators.

default_blur_enabled: bool = DEFAULT_BLUR_ENABLED class-attribute instance-attribute

default_blur_strength: float = DEFAULT_BLUR_STRENGTH class-attribute instance-attribute

default_box_border_width: int = DEFAULT_BOX_BORDER_WIDTH class-attribute instance-attribute

default_chosen_labels: list[str] = field(default_factory=lambda: list(DEFAULT_CHOSEN_LABELS)) class-attribute instance-attribute

default_confidence_decay: float = DEFAULT_CONFIDENCE_DECAY class-attribute instance-attribute

default_detection_model_name: str = DEFAULT_DETECTION_MODEL_NAME class-attribute instance-attribute

default_draw_boxes: bool = DEFAULT_DRAW_BOXES class-attribute instance-attribute

default_export_directory: str = '' class-attribute instance-attribute

default_export_prefix: str = '' class-attribute instance-attribute

default_export_suffix: str = '_exported' class-attribute instance-attribute

default_gsi_smoothness: float = DEFAULT_GSI_SMOOTHNESS class-attribute instance-attribute

default_max_stitch_gap: int = DEFAULT_MAX_STITCH_GAP class-attribute instance-attribute

default_min_detection_confidence: float = DEFAULT_MIN_DETECTION_CONFIDENCE class-attribute instance-attribute

default_min_iou: float = DEFAULT_MIN_IOU class-attribute instance-attribute

default_min_tracker_confidence: float = DEFAULT_MIN_TRACKER_CONFIDENCE class-attribute instance-attribute

default_offline_stitching_enabled: bool = DEFAULT_OFFLINE_STITCHING_ENABLED class-attribute instance-attribute

default_preview_blur_enabled: bool = DEFAULT_PREVIEW_BLUR_ENABLED class-attribute instance-attribute

default_reid_embedding_dim: int = DEFAULT_REID_EMBEDDING_DIM class-attribute instance-attribute

default_show_preview_mask: bool = DEFAULT_SHOW_PREVIEW_MASK class-attribute instance-attribute

default_theme: str = DEFAULT_THEME class-attribute instance-attribute

default_tracking_source: str = DEFAULT_TRACKING_SOURCE class-attribute instance-attribute

default_tracking_strategy: str = DEFAULT_TRACKING_STRATEGY class-attribute instance-attribute

last_project_directory: str = '' class-attribute instance-attribute

startup_fullscreen: bool = False class-attribute instance-attribute

__init__(startup_fullscreen: bool = False, default_theme: str = DEFAULT_THEME, default_detection_model_name: str = DEFAULT_DETECTION_MODEL_NAME, default_min_detection_confidence: float = DEFAULT_MIN_DETECTION_CONFIDENCE, default_chosen_labels: list[str] = (lambda: list(DEFAULT_CHOSEN_LABELS))(), default_tracking_strategy: str = DEFAULT_TRACKING_STRATEGY, default_tracking_source: str = DEFAULT_TRACKING_SOURCE, default_reid_embedding_dim: int = DEFAULT_REID_EMBEDDING_DIM, default_min_iou: float = DEFAULT_MIN_IOU, default_min_tracker_confidence: float = DEFAULT_MIN_TRACKER_CONFIDENCE, default_confidence_decay: float = DEFAULT_CONFIDENCE_DECAY, default_offline_stitching_enabled: bool = DEFAULT_OFFLINE_STITCHING_ENABLED, default_max_stitch_gap: int = DEFAULT_MAX_STITCH_GAP, default_gsi_smoothness: float = DEFAULT_GSI_SMOOTHNESS, default_draw_boxes: bool = DEFAULT_DRAW_BOXES, default_box_border_width: int = DEFAULT_BOX_BORDER_WIDTH, default_show_preview_mask: bool = DEFAULT_SHOW_PREVIEW_MASK, default_preview_blur_enabled: bool = DEFAULT_PREVIEW_BLUR_ENABLED, default_blur_enabled: bool = DEFAULT_BLUR_ENABLED, default_blur_strength: float = DEFAULT_BLUR_STRENGTH, last_project_directory: str = '', default_export_directory: str = '', default_export_prefix: str = '', default_export_suffix: str = '_exported') -> None

to_processing_settings_kwargs() -> dict[str, object]

Map persisted defaults to settings accepted by a new session.

RETURNS DESCRIPTION
dict[str, object]

Processing setting names and values without preference prefixes.

Note

The chosen labels list is copied so a session cannot mutate global defaults.

Example

kwargs = preferences.to_processing_settings_kwargs()

AppPreferencesStore

Load and persist AppPreferences through a settings backend.

Note

Stored key names are stable across launches and support injected test backends.

Layer: Shared utilities. Context: Provides reusable cross-layer behavior without owning workflow state.

__init__(settings: _SettingsBackend | None = None) -> None

PARAMETER DESCRIPTION
settings

Optional backend, defaulting to QSettings.

TYPE: _SettingsBackend | None DEFAULT: None

Raises: ImportError: If Qt settings are requested but PySide6 is unavailable.

Note

Inject a small backend in tests to avoid persistent machine settings.

Example

store = AppPreferencesStore(fake_settings)

load() -> AppPreferences

Load preferences and coerce raw backend values to field types.

RETURNS DESCRIPTION
AppPreferences

Preferences populated with saved values or dataclass defaults.

Note

Invalid scalar values fall back to the corresponding current default.

Example

preferences = store.load()

save(preferences: AppPreferences) -> None

Persist all preferences and synchronize the backend.

PARAMETER DESCRIPTION
preferences

Values to write under the store's stable preference keys.

TYPE: AppPreferences

Raises: Exception: Propagates failures from the settings backend.

Note

The label list is stored as a comma-separated string for compatibility.

Example

store.save(AppPreferences(default_max_stitch_gap=25))