Wavelength
Privacy-focused, cross-platform, and open-source communication application
Loading...
Searching...
No Matches
system_override_manager.h
Go to the documentation of this file.
1#ifndef SYSTEM_OVERRIDE_MANAGER_H
2#define SYSTEM_OVERRIDE_MANAGER_H
3
4#ifdef Q_OS_WIN
5#include <windows.h>
6#endif
7
8#include <QObject>
9
10class QSystemTrayIcon;
12
29class SystemOverrideManager final : public QObject {
30 Q_OBJECT
31
32public:
39 explicit SystemOverrideManager(QObject *parent = nullptr);
40
47 ~SystemOverrideManager() override;
48
49#ifdef Q_OS_WIN
54 static bool IsRunningAsAdmin();
55
62 static bool RelaunchAsAdmin(const QStringList& arguments = QStringList());
63#endif
64
65signals:
70
71public slots:
78 void InitiateOverrideSequence(bool is_first_time);
79
86 void RestoreSystemState();
87
88private slots:
94
95private:
100 static bool ChangeWallpaper();
101
107 static bool RestoreWallpaper();
108
116 [[nodiscard]] bool SendSystemNotification(const QString &title, const QString &message) const;
117
123 static bool MinimizeAllWindows();
124
130 void ShowFloatingAnimationWidget(bool is_first_time);
131
133 QSystemTrayIcon *tray_icon_;
136
143
150 static bool RelaunchNormally(const QStringList &arguments = QStringList());
151
152#ifdef Q_OS_WIN
162 static LRESULT CALLBACK LowLevelKeyboardProc(int n_code, WPARAM w_param, LPARAM l_param);
163
168 static bool InstallKeyboardHook();
169
173 static void UninstallKeyboardHook();
175 static HHOOK keyboard_hook_;
176
185 static LRESULT CALLBACK LowLevelMouseProc(int n_code, WPARAM w_param, LPARAM l_param);
186
191 static bool InstallMouseHook();
192
196 static void UninstallMouseHook();
198 static HHOOK mouse_hook_;
199#endif
200};
201
202#endif // SYSTEM_OVERRIDE_MANAGER_H
An OpenGL widget displaying a floating, interactive energy sphere.
Definition floating_energy_sphere_widget.h:45
void RestoreSystemState()
Restores the system state to normal. Uninstalls input hooks (Windows), restores the original wallpape...
Definition system_override_manager.cpp:322
QString original_wallpaper_path_
Stores the path to the user's original desktop wallpaper.
Definition system_override_manager.h:138
void HandleFloatingWidgetClosed()
Slot called when the FloatingEnergySphereWidget emits its widgetClosed signal. Cleans up the widget p...
Definition system_override_manager.cpp:316
void InitiateOverrideSequence(bool is_first_time)
Initiates the full system override sequence. Installs input hooks (Windows), changes wallpaper,...
Definition system_override_manager.cpp:86
bool SendSystemNotification(const QString &title, const QString &message) const
Sends a system notification using QSystemTrayIcon. Ensures the tray icon is visible before sending.
Definition system_override_manager.cpp:238
SystemOverrideManager(QObject *parent=nullptr)
Constructs a SystemOverrideManager. Initializes member variables, sets up the system tray icon for no...
Definition system_override_manager.cpp:39
FloatingEnergySphereWidget * floating_widget_
Pointer to the floating energy sphere widget instance.
Definition system_override_manager.h:135
static bool RelaunchNormally(const QStringList &arguments=QStringList())
Attempts to relaunch the application without administrative privileges (Windows only)....
Definition system_override_manager.cpp:378
static bool RestoreWallpaper()
Restores the original desktop wallpaper saved by ChangeWallpaper(). Also removes the temporary black ...
Definition system_override_manager.cpp:202
~SystemOverrideManager() override
Destructor. Ensures the system state is restored if the override is active. Cleans up the floating wi...
Definition system_override_manager.cpp:64
bool override_active_
Flag indicating if the system override sequence is currently active.
Definition system_override_manager.h:142
void overrideFinished()
Emitted when the system override sequence has finished and the system state has been restored.
QString temp_black_wallpaper_path_
Stores the path to the temporary black wallpaper image file.
Definition system_override_manager.h:140
void ShowFloatingAnimationWidget(bool is_first_time)
Creates, configures, positions, and shows the FloatingEnergySphereWidget. Connects the necessary sign...
Definition system_override_manager.cpp:285
QSystemTrayIcon * tray_icon_
System tray icon used for displaying notifications.
Definition system_override_manager.h:133
static bool MinimizeAllWindows()
Minimizes all open windows on the desktop (Windows only). Uses COM or a fallback method.
Definition system_override_manager.cpp:261
static bool ChangeWallpaper()
Saves the current wallpaper path and sets the desktop wallpaper to a temporary black image.
Definition system_override_manager.cpp:145