2020-08-10 12:15:57 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
|
|
|
import "../imports"
|
2020-10-03 19:00:07 +00:00
|
|
|
import "../shared/status"
|
2020-08-10 12:15:57 +00:00
|
|
|
import "./"
|
|
|
|
|
|
|
|
ModalPopup {
|
2020-08-10 13:06:46 +00:00
|
|
|
id: confirmationDialog
|
2020-10-02 13:02:56 +00:00
|
|
|
|
|
|
|
property Popup parentPopup
|
2021-02-10 06:12:43 +00:00
|
|
|
property string btnType: "warn"
|
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
|
|
|
|
|
|
|
|
2020-08-10 12:15:57 +00:00
|
|
|
height: 186
|
|
|
|
width: 400
|
2020-08-26 15:52:26 +00:00
|
|
|
//% "Confirm your action"
|
|
|
|
title: qsTrId("confirm-your-action")
|
2021-08-18 16:11:17 +00:00
|
|
|
focus: visible
|
2020-08-10 13:06:46 +00:00
|
|
|
|
2020-08-26 15:52:26 +00:00
|
|
|
//% "Confirm"
|
|
|
|
property string confirmButtonLabel: qsTrId("close-app-button")
|
2021-04-23 10:22:07 +00:00
|
|
|
//% "Cancel"
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Cancel"
|
|
|
|
property string cancelButtonLabel: qsTrId("browsing-cancel")
|
2020-08-26 15:52:26 +00:00
|
|
|
//% "Are you sure you want to this?"
|
|
|
|
property string confirmationText: qsTrId("are-you-sure-you-want-to-this-")
|
2020-10-02 13:02:56 +00:00
|
|
|
|
2020-10-02 14:37:51 +00:00
|
|
|
property var value
|
|
|
|
|
2020-08-10 13:06:46 +00:00
|
|
|
signal confirmButtonClicked()
|
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
|
|
|
property var executeConfirm
|
|
|
|
property var executeCancel
|
|
|
|
|
|
|
|
Item {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: innerText
|
|
|
|
text: confirmationDialog.confirmationText
|
|
|
|
font.pixelSize: 15
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusCheckBox {
|
|
|
|
id: checkbox
|
|
|
|
visible: false
|
|
|
|
anchors.top: innerText.bottom
|
|
|
|
anchors.topMargin: Style.current.halfPadding
|
|
|
|
Layout.preferredWidth: parent.width
|
2021-07-30 16:02:22 +00:00
|
|
|
//% "Do not show this again"
|
|
|
|
text: qsTrId("do-not-show-this-again")
|
2021-07-26 18:44:25 +00:00
|
|
|
}
|
2020-08-10 12:15:57 +00:00
|
|
|
}
|
|
|
|
|
2021-07-26 18:44:25 +00:00
|
|
|
|
2020-08-10 12:15:57 +00:00
|
|
|
footer: Item {
|
|
|
|
id: footerContainer
|
|
|
|
width: parent.width
|
2021-04-23 10:22:07 +00:00
|
|
|
height: confirmButton.height//children[0].height
|
2020-08-10 12:15:57 +00:00
|
|
|
|
2020-10-03 19:00:07 +00:00
|
|
|
StatusButton {
|
2021-04-23 10:22:07 +00:00
|
|
|
id: confirmButton
|
2021-01-13 20:26:30 +00:00
|
|
|
type: confirmationDialog.btnType
|
2021-07-26 18:44:25 +00:00
|
|
|
anchors.right: cancelButton.visible ? cancelButton.left : parent.right
|
|
|
|
anchors.rightMargin: cancelButton.visible ? Style.current.smallPadding : 0
|
2020-10-03 19:00:07 +00:00
|
|
|
text: confirmationDialog.confirmButtonLabel
|
2020-08-10 12:15:57 +00:00
|
|
|
anchors.bottom: parent.bottom
|
2021-08-18 16:11:17 +00:00
|
|
|
focus: true
|
|
|
|
Keys.onReturnPressed: function(event) {
|
|
|
|
confirmButton.clicked()
|
|
|
|
}
|
2021-07-26 18:44:25 +00:00
|
|
|
onClicked: {
|
|
|
|
if (executeConfirm && typeof executeConfirm === "function") {
|
|
|
|
executeConfirm()
|
|
|
|
}
|
|
|
|
|
|
|
|
confirmationDialog.confirmButtonClicked()
|
|
|
|
}
|
2020-08-10 12:15:57 +00:00
|
|
|
}
|
2021-04-23 10:22:07 +00:00
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
id: cancelButton
|
|
|
|
anchors.right: parent.right
|
|
|
|
visible: showCancelButton
|
|
|
|
anchors.rightMargin: Style.current.smallPadding
|
|
|
|
text: confirmationDialog.cancelButtonLabel
|
|
|
|
anchors.bottom: parent.bottom
|
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-04-23 10:22:07 +00:00
|
|
|
}
|
2020-08-10 12:15:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-10 13:06:46 +00:00
|
|
|
|