Manages the lifecycle and positioning of notification toasts.
More...
#include <notification_manager.h>
|
| void | showNotification (const QString &header, const QString &text, logging::LogLevel level) |
| | Displays a new notification toast.
|
| QString | showLongNotification (const QString &id, const QString &header, QWidget *contents, logging::LogLevel level) |
| | Displays a new long notification toast.
|
|
| | NotificationManager (QWidget *parentWindow, QObject *parent=nullptr) |
| | Constructs a notification manager.
|
|
void | toggleMinimize (bool minimize) |
| | Minimizes or expands all notifications.
|
|
| void | repositionToasts () |
| | Repositions all active notification toasts.
|
| bool | eventFilter (QObject *watched, QEvent *event) |
| | Event filter to track parent window changes.
|
| QString | updateExistingNotification (const QString &id, QWidget *contents, logging::LogLevel level) |
| | Updates an existing notification with new contents.
|
|
|
QPointer< QWidget > | mParentWindow |
| | Weak pointer to the parent window used for positioning.
|
|
QList< NotificationWidget * > | mToasts |
| | List of active notification toasts.
|
|
bool | mMinimize |
| | Whether toasts should be minimized.
|
Manages the lifecycle and positioning of notification toasts.
This class is responsible for:
- Creating and displaying NotificationWidget instances
- Tracking active notifications (toasts)
- Repositioning notifications when the parent window changes
- Handling dismissal of notifications
It installs an event filter on the parent window to react to resize/move events.
◆ NotificationManager()
| NotificationManager::NotificationManager |
( |
QWidget * | parentWindow, |
|
|
QObject * | parent = nullptr ) |
|
explicit |
Constructs a notification manager.
- Parameters
-
| parentWindow | The window relative to which notifications are positioned. |
| parent | The parent QObject. |
◆ eventFilter()
| bool NotificationManager::eventFilter |
( |
QObject * | watched, |
|
|
QEvent * | event ) |
|
private |
Event filter to track parent window changes.
Used to reposition notifications when the parent window is resized or moved.
- Parameters
-
| watched | The object being observed. |
| event | The event that occurred. |
- Returns
- True if the event was handled, false otherwise.
◆ onToastDismissed
Handles dismissal of a notification toast.
Removes the toast from the internal list and updates layout.
- Parameters
-
| toast | The notification widget that was dismissed. |
◆ repositionToasts()
| void NotificationManager::repositionToasts |
( |
| ) |
|
|
private |
Repositions all active notification toasts.
Typically called after adding/removing a toast or when the parent window changes size.
◆ showLongNotification
| QString NotificationManager::showLongNotification |
( |
const QString & | id, |
|
|
const QString & | header, |
|
|
QWidget * | contents, |
|
|
logging::LogLevel | level ) |
|
slot |
Displays a new long notification toast.
Creates a LongNotificationWidget and adds it to the managed list, positioning it relative to the parent window.
- Parameters
-
| id | The id of the long notification widget |
| header | The title of the notification. |
| contents | The body of the notification. |
| level | The log level determining the visual style. |
- Returns
- QString The ID of the created long notification.
◆ showNotification
| void NotificationManager::showNotification |
( |
const QString & | header, |
|
|
const QString & | text, |
|
|
logging::LogLevel | level ) |
|
slot |
Displays a new notification toast.
Creates a NotificationWidget and adds it to the managed list, positioning it relative to the parent window.
- Parameters
-
| header | The title of the notification. |
| text | The message body of the notification. |
| level | The log level determining the visual style. |
◆ updateExistingNotification()
| QString NotificationManager::updateExistingNotification |
( |
const QString & | id, |
|
|
QWidget * | contents, |
|
|
logging::LogLevel | level ) |
|
private |
Updates an existing notification with new contents.
- Parameters
-
| id | The ID of the notification to update. |
| contents | The new body of the notification. |
- Returns
- QString The updated notification's ID.
The documentation for this class was generated from the following files: