SimpleQmlNotify/NotifyModule/NotificationServiceView.qml

77 lines
1.7 KiB
QML
Raw Normal View History

2020-05-23 02:30:51 +03:00
/*
2021-01-31 19:57:49 +03:00
* Copyright (C) 2018-2021 QuasarApp.
2020-05-23 02:30:51 +03:00
* Distributed under the lgplv3 software license, see the accompanying
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/
2021-01-18 23:20:03 +03:00
import QtQuick 2.15
import QtQuick.Controls.Material 2.15
import QtQuick.Controls 2.15
2019-11-19 15:20:38 +03:00
import QtQuick.Layouts 1.3
Item {
2021-10-21 18:46:18 +03:00
id : root;
2019-11-19 15:20:38 +03:00
readonly property var model: notificationService;
readonly property var msg: model.notify
2021-01-18 23:20:03 +03:00
readonly property var qst: model.question
2019-11-19 15:20:38 +03:00
readonly property var history: model.history
2019-11-19 18:09:01 +03:00
Metrix {
id: metrix
}
2019-11-19 15:20:38 +03:00
NotificationForm {
id: notyfyView
2021-05-31 16:28:00 +03:00
titleText : msg.title();
text: (msg)? msg.text(): "";
img: (msg && msg.img().length)? msg.img(): getDefaultImage((msg)? msg.type(): 0);
type: (msg)? msg.type(): 0;
2019-11-19 15:20:38 +03:00
x: parent.width - width - margin;
y: margin;
2021-01-18 23:20:03 +03:00
width: 4 * metrix.pt;
2019-11-19 15:20:38 +03:00
height: width * 0.5
}
2021-01-18 23:20:03 +03:00
YesNoQuestion {
id: questionMsgBox
2021-05-31 16:28:00 +03:00
titleText : qst.title();
text: (qst)? qst.text(): "";
img: (qst && qst.img().length)? qst.img(): defImg;
2021-01-18 23:20:03 +03:00
type: 0;
x: parent.width / 2 - width / 2;
y: parent.height / 2 - height / 2;
2021-10-21 18:46:18 +03:00
width: Math.min(6 * metrix.pt, root.width);
2021-01-18 23:20:03 +03:00
onAccepted: {
if (model) {
2021-05-31 16:28:00 +03:00
model.questionComplete(true, qst.type())
2021-01-18 23:20:03 +03:00
}
}
onRejected: {
if (model) {
2021-05-31 16:28:00 +03:00
model.questionComplete(false, qst.type())
2021-01-18 23:20:03 +03:00
}
}
}
2019-11-19 15:20:38 +03:00
onMsgChanged: {
2019-11-20 17:54:52 +03:00
if (msg.isValid()) {
notyfyView._show();
}
2019-11-19 15:20:38 +03:00
}
2021-01-18 23:20:03 +03:00
onQstChanged: {
if (qst.isValid()) {
questionMsgBox._show();
}
}
2019-11-19 15:20:38 +03:00
}