2019-11-19 15:20:38 +03:00
|
|
|
#ifndef NOTIFICATIONSERVICE_H
|
|
|
|
#define NOTIFICATIONSERVICE_H
|
|
|
|
|
|
|
|
#include "notificationdata.h"
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
namespace QmlNotificationService {
|
|
|
|
|
|
|
|
/**
|
2021-03-29 10:04:20 +03:00
|
|
|
* @brief The NotificationService class. This class used for working with notify.
|
2019-11-19 15:20:38 +03:00
|
|
|
*/
|
|
|
|
class NOTIFYSERVICESHARED_EXPORT NotificationService: public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
Q_PROPERTY(NotificationData notify READ notify NOTIFY notifyChanged)
|
2021-01-18 23:20:03 +03:00
|
|
|
Q_PROPERTY(NotificationData question READ question NOTIFY questionChanged)
|
2019-11-19 15:20:38 +03:00
|
|
|
|
2021-01-18 23:20:03 +03:00
|
|
|
Q_PROPERTY(QList<NotificationData> history READ history NOTIFY notifyChanged)
|
2019-11-19 15:20:38 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
2021-03-29 10:04:20 +03:00
|
|
|
* @brief Notify.
|
2021-03-29 09:57:08 +03:00
|
|
|
* @return notyfyData for qml.
|
2019-11-19 15:20:38 +03:00
|
|
|
*/
|
|
|
|
NotificationData notify() const;
|
2021-01-18 23:20:03 +03:00
|
|
|
NotificationData question() const;
|
2019-11-19 15:20:38 +03:00
|
|
|
|
|
|
|
/**
|
2021-03-29 09:57:08 +03:00
|
|
|
* @brief setNotify - Add new message for application.
|
|
|
|
* @param notify - Message data.
|
2019-11-19 15:20:38 +03:00
|
|
|
*/
|
|
|
|
void setNotify(const NotificationData ¬ify);
|
|
|
|
|
2021-01-18 23:20:03 +03:00
|
|
|
void setQuestion(const NotificationData& question);
|
|
|
|
Q_INVOKABLE void questionComplete(bool accepted, int code = 0);
|
|
|
|
|
2019-11-19 15:20:38 +03:00
|
|
|
Q_INVOKABLE void setNotify(const QString& title = "",
|
|
|
|
const QString& text = "",
|
|
|
|
const QString& img = "",
|
|
|
|
int type = NotificationData::Normal);
|
|
|
|
|
2021-01-18 23:20:03 +03:00
|
|
|
Q_INVOKABLE void setQuestion(const QString& title = "",
|
|
|
|
const QString& text = "",
|
|
|
|
const QString& img = "",
|
|
|
|
int code = 0);
|
|
|
|
|
|
|
|
|
2019-11-19 15:20:38 +03:00
|
|
|
/**
|
2021-03-29 10:04:20 +03:00
|
|
|
* @brief getService - This method return instance to notify service.
|
|
|
|
* @return pointer to service.
|
2019-11-19 15:20:38 +03:00
|
|
|
*/
|
|
|
|
static NotificationService* getService();
|
|
|
|
|
|
|
|
/**
|
2021-03-29 10:04:20 +03:00
|
|
|
* @brief history - This method used for return notify list.
|
2021-03-29 09:57:08 +03:00
|
|
|
* @return list of all notify.
|
2019-11-19 15:20:38 +03:00
|
|
|
*/
|
|
|
|
const QList<NotificationData> & history() const;
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void notifyChanged();
|
2021-01-18 23:20:03 +03:00
|
|
|
void questionChanged();
|
|
|
|
void questionCompleted(bool accepted, int questionCode);
|
|
|
|
|
|
|
|
private:
|
|
|
|
explicit NotificationService(QObject *ptr = nullptr);
|
|
|
|
|
|
|
|
NotificationData _question;
|
|
|
|
NotificationData _notify;
|
|
|
|
QList<NotificationData> _history;
|
2019-11-19 15:20:38 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // NOTIFICATIONSERVICE_H
|