Class Application#

Inheritance Relationships#

Base Type#

  • public QObject

Class Documentation#

class Application : public QObject#

Top-level application object — owns all subsystem managers and orchestrates startup and shutdown ordering.

Created once in main() (inside the auth loop) and destroyed when the user quits or switches profiles. All subsystem managers are owned here and accessible via typed accessors.

See also

ProfileManager, AppSettings, RecordManager

Lifecycle
Application app;
app.initialize("cognitive_lab");   // loads settings, opens cameras, shows window
QApplication::exec();             // run the event loop
// shutdown() is called automatically via QCoreApplication::aboutToQuit

Note

Not a singleton — a fresh instance is created for each profile session so there is no stale state when the user switches profiles.

Public Functions

explicit Application(QObject *parent = nullptr)#
~Application() override#
void initialize(const QString &username = "guest", bool isAdmin = false)#

Initialises all subsystems and shows the main window.

Must be called exactly once after QApplication is constructed. The method:

  1. Opens a per-profile log file.

  2. Loads AppSettings from the profile’s settings.json (falls back to defaults if the file does not exist).

  3. Creates TriggerManager and installs keyboard event filters.

  4. Creates AudioManager.

  5. Creates VideoManager and opens configured cameras.

  6. Creates RecordManager.

  7. Creates and shows MainWindow.

Parameters:
  • username – Active profile name. Pass "guest" for an unauthenticated session that uses default paths.

  • isAdmin – Whether username's profile has Profile::Role::Admin. Gates per-user recording access control: an admin’s session browser/Analysis tab aggregate every known profile’s recordings instead of being scoped to just their own, and a one-time flat-session-folder migration runs only when this is true.

void shutdown()#

Saves settings and closes the window.

Connected to QCoreApplication::aboutToQuit automatically — calling it manually is safe but unnecessary in normal usage.

AppSettings &settings()#
Returns:

A mutable reference to the current session’s AppSettings.

const AppSettings &settings() const#
Returns:

An immutable reference to the current session’s AppSettings.

QString active_username() const#
Returns:

The username of the currently active profile ("guest" if no profile was selected at login).

TriggerManager *trigger_manager() const#
Returns:

The application-wide TriggerManager, or nullptr before initialize() has been called.

AudioManager *audio_manager() const#
Returns:

The application-wide AudioManager.

VideoManager *video_manager() const#
Returns:

The application-wide VideoManager.

RecordManager *record_manager() const#
Returns:

The application-wide RecordManager.

Signals

void initialized()#

Emitted at the end of initialize() when all subsystems are ready.

void shutdown_complete()#

Emitted at the end of shutdown() after all resources are released.