service/notifications: make notifications Retainable

This commit is contained in:
outfoxxed 2024-07-12 21:25:46 -07:00
parent 609834d8f2
commit e23923d9a2
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
3 changed files with 19 additions and 2 deletions

View file

@ -39,6 +39,11 @@ QString NotificationAction::identifier() const { return this->mIdentifier; }
QString NotificationAction::text() const { return this->mText; }
void NotificationAction::invoke() {
if (this->notification->isRetained()) {
qCritical() << "Cannot invoke destroyed notification" << this;
return;
}
NotificationServer::instance()->ActionInvoked(this->notification->id(), this->mIdentifier);
if (!this->notification->isResident()) {
@ -57,6 +62,11 @@ void Notification::expire() { this->close(NotificationCloseReason::Expired); }
void Notification::dismiss() { this->close(NotificationCloseReason::Dismissed); }
void Notification::close(NotificationCloseReason::Enum reason) {
if (this->isRetained()) {
qCritical() << "Cannot close destroyed notification" << this;
return;
}
this->mCloseReason = reason;
if (reason != 0) {