2020-08-10 12:15:57 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
|
|
|
|
2021-09-09 09:10:29 +00:00
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
|
|
|
|
StatusModal {
|
2020-08-10 13:06:46 +00:00
|
|
|
id: confirmationDialog
|
2020-10-02 13:02:56 +00:00
|
|
|
|
2022-09-23 10:57:48 +00:00
|
|
|
property var parentPopup
|
2021-09-09 09:10:29 +00:00
|
|
|
property var value
|
|
|
|
property var executeConfirm
|
2021-09-13 11:51:47 +00:00
|
|
|
property var executeReject
|
2021-09-09 09:10:29 +00:00
|
|
|
property var executeCancel
|
2022-07-20 08:18:27 +00:00
|
|
|
property string confirmButtonObjectName: ""
|
2021-02-10 06:12:43 +00:00
|
|
|
property string btnType: "warn"
|
2022-09-15 07:31:38 +00:00
|
|
|
property string cancelBtnType: "warn"
|
2021-09-09 09:10:29 +00:00
|
|
|
property string confirmButtonLabel: qsTr("Confirm")
|
2021-09-13 11:51:47 +00:00
|
|
|
property string rejectButtonLabel: qsTr("Reject")
|
2021-09-09 09:10:29 +00:00
|
|
|
property string cancelButtonLabel: qsTr("Cancel")
|
|
|
|
property string confirmationText: qsTr("Are you sure you want to do this?")
|
2021-09-13 11:51:47 +00:00
|
|
|
property bool showRejectButton: false
|
2021-04-23 10:22:07 +00:00
|
|
|
property bool showCancelButton: false
|
2021-07-26 18:44:25 +00:00
|
|
|
property alias checkbox: checkbox
|
2020-10-02 13:02:56 +00:00
|
|
|
|
|
|
|
|
2023-05-23 12:46:16 +00:00
|
|
|
headerSettings.title: qsTr("Confirm your action")
|
2021-08-18 16:11:17 +00:00
|
|
|
focus: visible
|
2020-08-10 13:06:46 +00:00
|
|
|
|
|
|
|
signal confirmButtonClicked()
|
2021-09-13 11:51:47 +00:00
|
|
|
signal rejectButtonClicked()
|
2021-04-23 10:22:07 +00:00
|
|
|
signal cancelButtonClicked()
|
2020-08-10 12:15:57 +00:00
|
|
|
|
2021-07-26 18:44:25 +00:00
|
|
|
|
2021-09-09 09:10:29 +00:00
|
|
|
contentItem: Item {
|
|
|
|
width: confirmationDialog.width
|
|
|
|
implicitHeight: childrenRect.height
|
|
|
|
Column {
|
|
|
|
width: parent.width - 32
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2021-07-26 18:44:25 +00:00
|
|
|
|
2021-09-09 09:10:29 +00:00
|
|
|
Item {
|
|
|
|
width: parent.width
|
|
|
|
height: 16
|
|
|
|
}
|
2020-08-10 12:15:57 +00:00
|
|
|
|
2021-09-09 09:10:29 +00:00
|
|
|
StatusBaseText {
|
|
|
|
text: confirmationDialog.confirmationText
|
|
|
|
font.pixelSize: 15
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
}
|
2021-07-26 18:44:25 +00:00
|
|
|
|
2021-09-09 09:10:29 +00:00
|
|
|
Item {
|
|
|
|
width: parent.width
|
|
|
|
height: 16
|
|
|
|
}
|
2020-08-10 12:15:57 +00:00
|
|
|
|
2021-09-09 09:10:29 +00:00
|
|
|
StatusCheckBox {
|
|
|
|
id: checkbox
|
|
|
|
visible: false
|
|
|
|
Layout.preferredWidth: parent.width
|
|
|
|
text: qsTr("Do not show this again")
|
2021-08-18 16:11:17 +00:00
|
|
|
}
|
2021-07-26 18:44:25 +00:00
|
|
|
|
2021-09-09 09:10:29 +00:00
|
|
|
Item {
|
|
|
|
width: parent.width
|
|
|
|
height: visible ? 16 : 0
|
|
|
|
visible: checkbox.visible
|
2021-07-26 18:44:25 +00:00
|
|
|
}
|
2020-08-10 12:15:57 +00:00
|
|
|
}
|
2021-09-09 09:10:29 +00:00
|
|
|
}
|
2021-04-23 10:22:07 +00:00
|
|
|
|
2021-09-09 09:10:29 +00:00
|
|
|
rightButtons: [
|
|
|
|
StatusFlatButton {
|
2021-04-23 10:22:07 +00:00
|
|
|
id: cancelButton
|
|
|
|
visible: showCancelButton
|
|
|
|
text: confirmationDialog.cancelButtonLabel
|
2022-09-15 07:31:38 +00:00
|
|
|
type: {
|
|
|
|
switch (confirmationDialog.cancelBtnType) {
|
|
|
|
case "warn":
|
|
|
|
return StatusBaseButton.Type.Danger
|
|
|
|
default:
|
|
|
|
return StatusBaseButton.Type.Normal
|
|
|
|
}
|
|
|
|
}
|
2021-07-26 18:44:25 +00:00
|
|
|
onClicked: {
|
2021-07-19 15:44:39 +00:00
|
|
|
if (executeCancel && typeof executeCancel === "function") {
|
|
|
|
executeCancel()
|
2021-07-26 18:44:25 +00:00
|
|
|
}
|
|
|
|
confirmationDialog.cancelButtonClicked()
|
|
|
|
}
|
2021-09-09 09:10:29 +00:00
|
|
|
},
|
2021-09-13 11:51:47 +00:00
|
|
|
StatusFlatButton {
|
|
|
|
visible: showRejectButton
|
|
|
|
text: confirmationDialog.rejectButtonLabel
|
|
|
|
onClicked: {
|
|
|
|
if (executeReject && typeof executeReject === "function") {
|
|
|
|
executeReject()
|
|
|
|
}
|
|
|
|
confirmationDialog.rejectButtonClicked()
|
|
|
|
}
|
|
|
|
},
|
2021-09-09 09:10:29 +00:00
|
|
|
StatusButton {
|
2023-11-29 15:48:33 +00:00
|
|
|
Layout.maximumWidth: confirmationDialog.availableWidth/2
|
2021-09-09 09:10:29 +00:00
|
|
|
id: confirmButton
|
2022-07-20 08:18:27 +00:00
|
|
|
objectName: confirmationDialog.confirmButtonObjectName
|
2021-09-09 09:10:29 +00:00
|
|
|
type: {
|
|
|
|
switch (confirmationDialog.btnType) {
|
|
|
|
case "warn":
|
|
|
|
return StatusBaseButton.Type.Danger
|
|
|
|
default:
|
2022-09-15 07:31:38 +00:00
|
|
|
return StatusBaseButton.Type.Normal
|
2021-09-09 09:10:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
text: confirmationDialog.confirmButtonLabel
|
|
|
|
focus: true
|
|
|
|
Keys.onReturnPressed: function(event) {
|
|
|
|
confirmButton.clicked()
|
|
|
|
}
|
|
|
|
onClicked: {
|
|
|
|
if (executeConfirm && typeof executeConfirm === "function") {
|
|
|
|
executeConfirm()
|
|
|
|
}
|
|
|
|
confirmationDialog.confirmButtonClicked()
|
|
|
|
}
|
2021-04-23 10:22:07 +00:00
|
|
|
}
|
2021-09-09 09:10:29 +00:00
|
|
|
]
|
2020-08-10 12:15:57 +00:00
|
|
|
}
|