Notification

Qualified name: mv::util::Notification

class Notification : public QWidget

Notification widget class.

For showing stacked notifications in a toaster-like way (see the notifications class).

Note: This class is developed for internal use only

Author

Thomas Kroes

Public Types

enum class DurationType

Duration types.

Values:

enumerator Fixed
enumerator Calculated

Standard 5000 ms.

enumerator Task

Calculated based on the number of characters.

Notification is visible as long as the task is running

Public Functions

explicit Notification(const QString &title, const QString &description, const QIcon &icon, Notification *previousNotification, const DurationType &durationType, QWidget *parent = nullptr)

Construct a notification with title, description, icon, previousNotification and pointer to parent widget.

Parameters:
  • titleNotification title

  • descriptionNotification description

  • iconNotification icon

  • previousNotification – Pointer to previous notification (maybe nullptr)

  • durationType – Duration type of the notification

  • parent – Pointer to parent widget

explicit Notification(QPointer<Task> task, Notification *previousNotification, QWidget *parent = nullptr)

Construct a notification with task, previousNotification and pointer to parent widget.

Parameters:
  • taskTask containing the notification details

  • previousNotification – Pointer to previous notification (maybe nullptr)

  • parent – Pointer to parent widget

bool isClosing() const

Get whether the notification is closing.

Returns:

Boolean determining Whether the notification is closing or not

Notification *getPreviousNotification() const

Get previous notification.

Returns:

Pointer to previous notification (maybe nullptr)

void setPreviousNotification(Notification *previousNotification)

Set previous notification to previousNotification.

Parameters:

previousNotification – Pointer to previous notification (maybe nullptr)

Notification *getNextNotification() const

Get next notification.

Returns:

Pointer to next notification (maybe nullptr)

void setNextNotification(Notification *nextNotification)

Set next notification to nextNotification.

Parameters:

nextNotification – Pointer to next notification (maybe nullptr)

QIcon getIcon() const

Get the notification icon.

Returns:

Notification icon

void setIcon(const QIcon &icon)

Set the notification icon to icon and update the icon label.

Parameters:

iconNotification icon

QString getTitle() const

Get the notification title.

Returns:

Notification title

void setTitle(const QString &title)

Set the notification title to title and update the message text label.

Parameters:

titleNotification title

QString getDescription() const

Get the notification description.

Returns:

Notification description

void setDescription(const QString &description)

Set the notification description to description and update the message text label.

Parameters:

descriptionNotification description

QSize minimumSizeHint() const override

Returns the preferred minimum size (overriden to allow for less tall notification widget)

Returns:

Minimum size hint

QSize sizeHint() const override

Returns the preferred minimum size (overriden to allow for less tall notification widget)

Returns:

Minimum size hint

void finished()

Signal emitted when the toaster finishes displaying.

Protected Functions

void showEvent(QShowEvent *event) override

Invoked when the widget is shown (used to update the position at the correct time)

Parameters:

event – Pointer to show event

void updatePosition()

Update the position of the notification and other notifications after it.

class NotificationWidget : public QWidget

For custom drawing of the notification widget background.

Public Functions

void paintEvent(QPaintEvent *event) override

Override the default paint behavior.

Parameters:

event – Pointer to paint event that occurred