File indexing completed on 2024-05-05 05:28:18

0001 /*
0002  * SPDX-FileCopyrightText: 2019 Dimitris Kardarakos <dimkard@posteo.net>
0003  *
0004  * SPDX-License-Identifier: GPL-3.0-or-later
0005  */
0006 
0007 #ifndef ALARMNOTIFICATION_H
0008 #define ALARMNOTIFICATION_H
0009 
0010 #include <KNotification>
0011 #include <QDateTime>
0012 
0013 class NotificationHandler;
0014 
0015 /**
0016  * @brief The alarm notification that should be displayed. It is a wrapper of a KNotification enhanced with alarm properties, like uid and remind time
0017  *
0018  */
0019 class AlarmNotification : public QObject
0020 {
0021     Q_OBJECT
0022 public:
0023     explicit AlarmNotification(NotificationHandler *handler, const QString &uid);
0024     ~AlarmNotification() override;
0025 
0026     /**
0027      * @brief Sends the notification so as to be displayed
0028      */
0029     void send() const;
0030 
0031     /**
0032      * @return The uid of the Incidence of the alarm of the notification
0033      */
0034     QString uid() const;
0035 
0036     /**
0037      * @brief The text of the notification that should be displayed
0038      */
0039     QString text() const;
0040 
0041     /**
0042      * @brief Sets the to-be-displayed text of the notification
0043      */
0044     void setText(const QString &alarmText);
0045 
0046     /**
0047      * @return In case of a suspended notification, the time that the notification should be displayed. Otherwise, it is empty.
0048      */
0049     QDateTime remindAt() const;
0050 
0051     /**
0052      * @brief Sets the time that should be displayed a suspended notification
0053      */
0054     void setRemindAt(const QDateTime &remindAtDt);
0055 
0056 Q_SIGNALS:
0057 
0058     /**
0059      * @brief Signal that should be emitted when the user clicks to the Dismiss action button of the KNotification displayed
0060      */
0061     void dismiss();
0062 
0063     /**
0064      * @brief Signal that should be emitted when the user clicks to the Suspend action button of the KNotification displayed
0065      */
0066     void suspend();
0067 
0068 private:
0069     KNotification *m_notification;
0070     QString m_uid;
0071     QDateTime m_remind_at;
0072     NotificationHandler *m_notification_handler;
0073 };
0074 #endif