Skip to content

Settings System Feature

The settings system provides the application-wide settings interface, allowing users to configure theme preferences, logging behavior, and module-specific options.

Overview

This feature provides: - Theme Switching: Toggle between dark and light mode with persistent preference - Logging Configuration: Log level selection (None/Balanced/Detailed) and retention settings - Log Viewer: Browse, select, and preview log files with auto-refresh support - Modular Settings Pages: Sidebar navigation between settings sections via a stacked widget

Architecture

settings_system/
    controller/
        settings_controller.py      # Main controller for navigation and theme toggling
    view/
        settings_view.py            # Main widget hosting the settings UI
        pyui/
            ui_settings_view.py     # Auto-generated from Qt Designer
        ui/
            settings_view.ui        # Qt Designer source file
    model/                          # Reserved for future settings models
    bound_subsystems/
        logging_settings/
            controller/
                log_settings_controller.py  # Log level, retention, file loading logic
            view/
                log_settings_view.py        # Logging config and log viewer widget
    paths.py                        # PathDef definitions for stylesheets

Bound Subsystems

Logging Settings

Manages log configuration and log file viewing: - LogSettingsController: Handles log level changes, retention persistence, file listing with empty-file filtering, large-file truncation, and auto-refresh timer management - LogSettingsView: Split-panel UI with a "What is Logging?" explanation, configuration controls, file browser, and monospace log preview

Key Features

  • Persistent Preferences: Theme and logging settings saved via GlobalSettings and restored on startup
  • Auto-Refresh: File list refreshes automatically every 30s when detailed logging is active
  • Large File Handling: Log files exceeding 3 MB are truncated to the last 20,000 lines
  • Empty File Filtering: Log files with only headers/metadata are hidden from the list
  • Extensible Navigation: Sidebar radio buttons map to a QStackedWidget via SettingsPage enum

Usage

The settings system is instantiated by the main hub orchestration:

from src.main_hub.features.settings_system.view.settings_view import SettingsView
from src.main_hub.features.settings_system.controller.settings_controller import SettingsController

view = SettingsView(logger=logger)
controller = SettingsController(view, parent=parent)

Configuration

Logging-related constants are defined in log_settings_controller.py: - AUTO_REFRESH_INTERVAL_MS: Auto-refresh interval for detailed mode (default: 30s) - MIN_LOG_FILE_SIZE_BYTES: Threshold below which files are treated as empty (default: 50 bytes) - MAX_LOG_DISPLAY_CHARS: Character limit before truncation kicks in (default: 3 MB) - MAX_DISPLAY_LINE_COUNT: Maximum lines displayed from a truncated file (default: 20,000)