38 lines
1.0 KiB
C++
Raw Normal View History

2019-08-17 20:07:11 +03:00
#include "notificationservice.h"
2019-08-17 20:33:18 +03:00
NotificationService::NotificationService(QObject * ptr): QObject (ptr) {
2019-08-20 17:04:03 +03:00
qRegisterMetaType<NotificationData>("NotificationData");
qRegisterMetaType<QList<NotificationData>> ("QList<NotificationData>");
2019-08-17 20:07:11 +03:00
}
2019-08-17 20:33:18 +03:00
2019-08-19 18:02:40 +03:00
NotificationData NotificationService::notify() const {
2019-08-17 20:33:18 +03:00
return _notify;
}
2019-08-19 18:02:40 +03:00
void NotificationService::setNotify(const NotificationData& notify) {
2019-08-17 20:33:18 +03:00
if (_notify == notify)
return;
_notify = notify;
_history.push_back(_notify);
2019-08-19 18:02:40 +03:00
emit notifyChanged();
2019-08-17 20:33:18 +03:00
}
void NotificationService::setNotify(const QString &title,
const QString &text,
const QString &img,
NotificationData::Type type) {
setNotify(NotificationData(title, text, img, type));
}
2019-08-17 20:33:18 +03:00
NotificationService *NotificationService::getService() {
static auto service = new NotificationService;
return service;
}
2019-08-19 18:02:40 +03:00
const QList<NotificationData> &NotificationService::history() const {
2019-08-17 20:33:18 +03:00
return _history;
}