Maki
Formally verfied low-code orchestration
Loading...
Searching...
No Matches
NotificationManager Class Reference

Manages the lifecycle and positioning of notification toasts. More...

#include <notification_manager.h>

Inheritance diagram for NotificationManager:

Public Slots

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.

Public Member Functions

 NotificationManager (QWidget *parentWindow, QObject *parent=nullptr)
 Constructs a notification manager.
void toggleMinimize (bool minimize)
 Minimizes or expands all notifications.

Private Slots

void onToastDismissed (NotificationWidget *toast)
 Handles dismissal of a notification toast.

Private Member Functions

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.

Private Attributes

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.

Detailed Description

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.

Constructor & Destructor Documentation

◆ NotificationManager()

NotificationManager::NotificationManager ( QWidget * parentWindow,
QObject * parent = nullptr )
explicit

Constructs a notification manager.

Parameters
parentWindowThe window relative to which notifications are positioned.
parentThe parent QObject.

Member Function Documentation

◆ 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
watchedThe object being observed.
eventThe event that occurred.
Returns
True if the event was handled, false otherwise.

◆ onToastDismissed

void NotificationManager::onToastDismissed ( NotificationWidget * toast)
privateslot

Handles dismissal of a notification toast.

Removes the toast from the internal list and updates layout.

Parameters
toastThe 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
idThe id of the long notification widget
headerThe title of the notification.
contentsThe body of the notification.
levelThe 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
headerThe title of the notification.
textThe message body of the notification.
levelThe 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
idThe ID of the notification to update.
contentsThe new body of the notification.
Returns
QString The updated notification's ID.

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