File indexing completed on 2024-06-02 05:15:33

0001 /*
0002    SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "notificationobject.h"
0008 #include <QDebug>
0009 
0010 NotificationObject::NotificationObject(QObject *parent)
0011     : QObject{parent}
0012 {
0013 }
0014 
0015 NotificationObject::~NotificationObject() = default;
0016 
0017 void NotificationObject::sendNotification(const QString &title, const QString &summary)
0018 {
0019     const bool notificationExists = m_notification;
0020     if (!notificationExists) {
0021         m_notification = new KNotification(QStringLiteral("alarm"));
0022     }
0023     m_notification->setTitle(title);
0024 
0025     m_notification->setFlags(KNotification::Persistent);
0026     m_notification->setText(summary);
0027 
0028     if (!notificationExists) {
0029         auto action = m_notification->addDefaultAction(QStringLiteral("View"));
0030         auto remindIn5MAction = m_notification->addAction(QStringLiteral("Remind in 5 mins"));
0031         auto remindIn1hAction = m_notification->addAction(QStringLiteral("Remind in 1 hour"));
0032 
0033         auto dismissAction = m_notification->addAction(QStringLiteral("Dismiss"));
0034         qDebug() << " send event ";
0035         m_notification->sendEvent();
0036     }
0037 }