2023-03-29 13:00:08 +02:00
|
|
|
/*
|
2023-12-31 10:03:40 +01:00
|
|
|
* Copyright (C) 2018-2024 QuasarApp.
|
2023-03-29 13:00:08 +02:00
|
|
|
* Distributed under the GPLv3 software license, see the accompanying
|
|
|
|
* Everyone is permitted to copy and distribute verbatim copies
|
|
|
|
* of this license document, but changing it is not allowed.
|
|
|
|
*/
|
|
|
|
|
2019-11-19 15:20:38 +03:00
|
|
|
#ifndef QMLNOTIFYSERVICE_H
|
|
|
|
#define QMLNOTIFYSERVICE_H
|
|
|
|
#include "notifyservice_global.h"
|
|
|
|
|
|
|
|
#include "notificationservice.h"
|
|
|
|
|
|
|
|
class QQmlApplicationEngine;
|
2021-05-27 16:43:56 +03:00
|
|
|
inline void initSNotufyResources() { Q_INIT_RESOURCE(NotifyModule); }
|
2019-11-19 15:20:38 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Simple notify service for qml.
|
|
|
|
* Use :
|
2021-04-16 10:23:33 +03:00
|
|
|
* @code{cpp}
|
2019-11-19 15:20:38 +03:00
|
|
|
* #include <qmlnotifyservice.h>
|
|
|
|
* QmlNotificationService::init();
|
|
|
|
* auto service = QmlNotificationService::NotificationService::getService()
|
|
|
|
* service->setNotify("title", "text", "UrlOfImage", NotificationData::Normal)
|
2021-04-16 09:49:55 +03:00
|
|
|
* @endcode
|
2019-11-19 15:20:38 +03:00
|
|
|
*
|
|
|
|
* in qml :
|
2021-04-16 10:23:45 +03:00
|
|
|
* @code{qml}
|
2019-11-19 15:20:38 +03:00
|
|
|
* NotificationServiceView {
|
|
|
|
anchors.fill: parent;
|
|
|
|
}
|
2021-04-16 10:14:13 +03:00
|
|
|
* @endcode
|
|
|
|
* Questions
|
|
|
|
* CPP
|
2021-04-16 10:23:12 +03:00
|
|
|
* @code{cpp}
|
2021-04-16 10:14:13 +03:00
|
|
|
#include <qmlnotifyservice.h>
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
QmlNotificationService::init();
|
|
|
|
auto service = QmlNotificationService::NotificationService::getService();
|
|
|
|
int questionCode = service->setQuestion("title", "some text");
|
|
|
|
|
|
|
|
QObject::connect(service, QmlNotificationService::NotificationService::questionCompleted,
|
|
|
|
[questionCode](bool accepted, int questionCode) {
|
|
|
|
if (accepted && code === questionCode) {
|
|
|
|
// your action here.
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
* @endcode
|
|
|
|
* QML
|
2021-04-16 10:23:12 +03:00
|
|
|
* @code{qml}
|
2021-04-16 10:14:13 +03:00
|
|
|
NotificationServiceView {
|
|
|
|
anchors.fill: parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
readonly property int questionCode: 0;
|
|
|
|
|
|
|
|
questionCode = notificationService.setQuestion(qsTr("Remove %0 user").arg(userModel.userId),
|
|
|
|
qsTr("All saved data and records will be delete, Do you want continuee?"))
|
|
|
|
Connections {
|
|
|
|
target: notificationService
|
|
|
|
function onQuestionCompleted(accepted, code) {
|
|
|
|
if (accepted && code === privateRoot.questionCode) {
|
|
|
|
if (userModel)
|
|
|
|
backEnd.removeUser(userModel.userId)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-04-16 09:49:55 +03:00
|
|
|
* @endcode
|
2019-11-19 15:20:38 +03:00
|
|
|
*/
|
|
|
|
namespace QmlNotificationService {
|
|
|
|
bool NOTIFYSERVICESHARED_EXPORT init(QQmlApplicationEngine *engine);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif // QMLNOTIFYSERVICE_H
|