Wavelength
Privacy-focused, cross-platform, and open-source communication application
Loading...
Searching...
No Matches
SystemOverrideManager Class Referencefinal

Manages a "system override" sequence involving visual and system-level changes. More...

#include <system_override_manager.h>

Inheritance diagram for SystemOverrideManager:
Collaboration diagram for SystemOverrideManager:

Public Slots

void InitiateOverrideSequence (bool is_first_time)
 Initiates the full system override sequence. Installs input hooks (Windows), changes wallpaper, minimizes windows, sends a notification, and shows the floating animation widget.
 
void RestoreSystemState ()
 Restores the system state to normal. Uninstalls input hooks (Windows), restores the original wallpaper, removes the temporary wallpaper file, closes the floating widget, and emits overrideFinished(). On Windows, attempts to relaunch the application normally and quit the elevated instance.
 

Signals

void overrideFinished ()
 Emitted when the system override sequence has finished and the system state has been restored.
 

Public Member Functions

 SystemOverrideManager (QObject *parent=nullptr)
 Constructs a SystemOverrideManager. Initializes member variables, sets up the system tray icon for notifications, and initializes the media player. Performs COM initialization on Windows.
 
 ~SystemOverrideManager () override
 Destructor. Ensures the system state is restored if the override is active. Cleans up the floating widget, temporary wallpaper file, and uninstalls hooks on Windows. Performs COM uninitialization on Windows.
 

Private Slots

void HandleFloatingWidgetClosed ()
 Slot called when the FloatingEnergySphereWidget emits its widgetClosed signal. Cleans up the widget pointer and triggers system state restoration after a delay.
 

Private Member Functions

bool SendSystemNotification (const QString &title, const QString &message) const
 Sends a system notification using QSystemTrayIcon. Ensures the tray icon is visible before sending.
 
void ShowFloatingAnimationWidget (bool is_first_time)
 Creates, configures, positions, and shows the FloatingEnergySphereWidget. Connects the necessary signals for closing and sequence completion.
 

Static Private Member Functions

static bool ChangeWallpaper ()
 Saves the current wallpaper path and sets the desktop wallpaper to a temporary black image.
 
static bool MinimizeAllWindows ()
 Minimizes all open windows on the desktop (Windows only). Uses COM or a fallback method.
 
static bool RelaunchNormally (const QStringList &arguments=QStringList())
 Attempts to relaunch the application without administrative privileges (Windows only). Used after the override sequence to return to a normal instance.
 
static bool RestoreWallpaper ()
 Restores the original desktop wallpaper saved by ChangeWallpaper(). Also removes the temporary black wallpaper file.
 

Private Attributes

FloatingEnergySphereWidgetfloating_widget_
 Pointer to the floating energy sphere widget instance.
 
QString original_wallpaper_path_
 Stores the path to the user's original desktop wallpaper.
 
bool override_active_
 Flag indicating if the system override sequence is currently active.
 
QString temp_black_wallpaper_path_
 Stores the path to the temporary black wallpaper image file.
 
QSystemTrayIcon * tray_icon_
 System tray icon used for displaying notifications.
 

Detailed Description

Manages a "system override" sequence involving visual and system-level changes.

This class orchestrates a sequence that:

  • Changes the desktop wallpaper to black (saving the original).
  • Minimizes all open windows.
  • Displays a system notification.
  • Shows a full-screen, interactive FloatingEnergySphereWidget.
  • Optionally plays background audio.
  • On Windows, installs low-level keyboard and mouse hooks to block most input, allowing only specific keys needed for an Easter egg within the floating widget.

It handles restoring the system state (wallpaper, unblocking input) when the sequence finishes or is interrupted. It also includes logic for checking admin privileges and relaunching the application with or without elevation on Windows.

Constructor & Destructor Documentation

◆ SystemOverrideManager()

SystemOverrideManager::SystemOverrideManager ( QObject * parent = nullptr)
explicit

Constructs a SystemOverrideManager. Initializes member variables, sets up the system tray icon for notifications, and initializes the media player. Performs COM initialization on Windows.

Parameters
parentOptional parent QObject.

◆ ~SystemOverrideManager()

SystemOverrideManager::~SystemOverrideManager ( )
override

Destructor. Ensures the system state is restored if the override is active. Cleans up the floating widget, temporary wallpaper file, and uninstalls hooks on Windows. Performs COM uninitialization on Windows.

Here is the call graph for this function:

Member Function Documentation

◆ ChangeWallpaper()

bool SystemOverrideManager::ChangeWallpaper ( )
staticprivate

Saves the current wallpaper path and sets the desktop wallpaper to a temporary black image.

Returns
True on success, false otherwise.
Here is the caller graph for this function:

◆ HandleFloatingWidgetClosed

void SystemOverrideManager::HandleFloatingWidgetClosed ( )
privateslot

Slot called when the FloatingEnergySphereWidget emits its widgetClosed signal. Cleans up the widget pointer and triggers system state restoration after a delay.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitiateOverrideSequence

void SystemOverrideManager::InitiateOverrideSequence ( bool is_first_time)
slot

Initiates the full system override sequence. Installs input hooks (Windows), changes wallpaper, minimizes windows, sends a notification, and shows the floating animation widget.

Parameters
is_first_timeFlag indicating if this is the first time the sequence is run (affects floating widget's audio).
Here is the call graph for this function:

◆ MinimizeAllWindows()

bool SystemOverrideManager::MinimizeAllWindows ( )
staticprivate

Minimizes all open windows on the desktop (Windows only). Uses COM or a fallback method.

Returns
True on success, false otherwise.
Here is the caller graph for this function:

◆ overrideFinished

void SystemOverrideManager::overrideFinished ( )
signal

Emitted when the system override sequence has finished and the system state has been restored.

Here is the caller graph for this function:

◆ RelaunchNormally()

bool SystemOverrideManager::RelaunchNormally ( const QStringList & arguments = QStringList())
staticprivate

Attempts to relaunch the application without administrative privileges (Windows only). Used after the override sequence to return to a normal instance.

Parameters
argumentsOptional command-line arguments to pass to the relaunched instance.
Returns
True if the relaunch was successfully initiated, false otherwise.
Here is the caller graph for this function:

◆ RestoreSystemState

void SystemOverrideManager::RestoreSystemState ( )
slot

Restores the system state to normal. Uninstalls input hooks (Windows), restores the original wallpaper, removes the temporary wallpaper file, closes the floating widget, and emits overrideFinished(). On Windows, attempts to relaunch the application normally and quit the elevated instance.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RestoreWallpaper()

bool SystemOverrideManager::RestoreWallpaper ( )
staticprivate

Restores the original desktop wallpaper saved by ChangeWallpaper(). Also removes the temporary black wallpaper file.

Returns
True if the original wallpaper was successfully restored, false otherwise.
Here is the caller graph for this function:

◆ SendSystemNotification()

bool SystemOverrideManager::SendSystemNotification ( const QString & title,
const QString & message ) const
nodiscardprivate

Sends a system notification using QSystemTrayIcon. Ensures the tray icon is visible before sending.

Parameters
titleThe title of the notification.
messageThe main text content of the notification.
Returns
True if the notification was sent successfully, false otherwise.
Here is the caller graph for this function:

◆ ShowFloatingAnimationWidget()

void SystemOverrideManager::ShowFloatingAnimationWidget ( bool is_first_time)
private

Creates, configures, positions, and shows the FloatingEnergySphereWidget. Connects the necessary signals for closing and sequence completion.

Parameters
is_first_timeFlag passed to the FloatingEnergySphereWidget constructor.
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ floating_widget_

FloatingEnergySphereWidget* SystemOverrideManager::floating_widget_
private

Pointer to the floating energy sphere widget instance.

◆ original_wallpaper_path_

QString SystemOverrideManager::original_wallpaper_path_
private

Stores the path to the user's original desktop wallpaper.

◆ override_active_

bool SystemOverrideManager::override_active_
private

Flag indicating if the system override sequence is currently active.

◆ temp_black_wallpaper_path_

QString SystemOverrideManager::temp_black_wallpaper_path_
private

Stores the path to the temporary black wallpaper image file.

◆ tray_icon_

QSystemTrayIcon* SystemOverrideManager::tray_icon_
private

System tray icon used for displaying notifications.


The documentation for this class was generated from the following files: