mirror of
https://github.com/QuasarApp/SimpleQmlNotify.git
synced 2025-04-29 23:24:33 +00:00
commit
835d8c95df
@ -9,18 +9,59 @@ class QQmlApplicationEngine;
|
|||||||
/**
|
/**
|
||||||
* Simple notify service for qml.
|
* Simple notify service for qml.
|
||||||
* Use :
|
* Use :
|
||||||
|
* @code{cpp}
|
||||||
* #include <qmlnotifyservice.h>
|
* #include <qmlnotifyservice.h>
|
||||||
*
|
|
||||||
* QmlNotificationService::init();
|
* QmlNotificationService::init();
|
||||||
* auto service = QmlNotificationService::NotificationService::getService()
|
* auto service = QmlNotificationService::NotificationService::getService()
|
||||||
* service->setNotify("title", "text", "UrlOfImage", NotificationData::Normal)
|
* service->setNotify("title", "text", "UrlOfImage", NotificationData::Normal)
|
||||||
*
|
* @endcode
|
||||||
*
|
*
|
||||||
* in qml :
|
* in qml :
|
||||||
*
|
* @code{qml}
|
||||||
* NotificationServiceView {
|
* NotificationServiceView {
|
||||||
anchors.fill: parent;
|
anchors.fill: parent;
|
||||||
}
|
}
|
||||||
|
* @endcode
|
||||||
|
* Questions
|
||||||
|
* CPP
|
||||||
|
* @code{cpp}
|
||||||
|
#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
|
||||||
|
* @code{qml}
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
* @endcode
|
||||||
*/
|
*/
|
||||||
namespace QmlNotificationService {
|
namespace QmlNotificationService {
|
||||||
bool NOTIFYSERVICESHARED_EXPORT init(QQmlApplicationEngine *engine);
|
bool NOTIFYSERVICESHARED_EXPORT init(QQmlApplicationEngine *engine);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user