refactor(ConfirmationDialog): change dialog to `StatusModal`

This commit is contained in:
Pascal Precht 2021-09-09 11:10:29 +02:00 committed by Iuri Matias
parent a4df3c644b
commit 33d800fcda
16 changed files with 82 additions and 85 deletions

View File

@ -54,7 +54,6 @@ Item {
ConfirmationDialog { ConfirmationDialog {
property string settingsProp: "" property string settingsProp: ""
property var onConfirmed: (function(){}) property var onConfirmed: (function(){})
height: 310
showCancelButton: true showCancelButton: true
//% "This feature is experimental and is meant for testing purposes by core contributors and the community. It's not meant for real use and makes no claims of security or integrity of funds or data. Use at your own risk." //% "This feature is experimental and is meant for testing purposes by core contributors and the community. It's not meant for real use and makes no claims of security or integrity of funds or data. Use at your own risk."
confirmationText: qsTrId("this-feature-is-experimental-and-is-meant-for-testing-purposes-by-core-contributors-and-the-community--it-s-not-meant-for-real-use-and-makes-no-claims-of-security-or-integrity-of-funds-or-data--use-at-your-own-risk-") confirmationText: qsTrId("this-feature-is-experimental-and-is-meant-for-testing-purposes-by-core-contributors-and-the-community--it-s-not-meant-for-real-use-and-makes-no-claims-of-security-or-integrity-of-funds-or-data--use-at-your-own-risk-")

View File

@ -207,7 +207,7 @@ StatusAppThreePanelLayout {
ConfirmationDialog { ConfirmationDialog {
id: removeContactConfirmationDialog id: removeContactConfirmationDialog
// % "Remove contact" // % "Remove contact"
title: qsTrId("remove-contact") header.title: qsTrId("remove-contact")
//% "Are you sure you want to remove this contact?" //% "Are you sure you want to remove this contact?"
confirmationText: qsTrId("are-you-sure-you-want-to-remove-this-contact-") confirmationText: qsTrId("are-you-sure-you-want-to-remove-this-contact-")
onConfirmButtonClicked: { onConfirmButtonClicked: {

View File

@ -298,7 +298,6 @@ Item {
ConfirmationDialog { ConfirmationDialog {
property string categoryId property string categoryId
btnType: "warn" btnType: "warn"
height: 216
showCancelButton: true showCancelButton: true
onClosed: { onClosed: {
destroy() destroy()

View File

@ -178,7 +178,6 @@ StatusModal {
id: deleteCategoryConfirmationDialogComponent id: deleteCategoryConfirmationDialogComponent
ConfirmationDialog { ConfirmationDialog {
btnType: "warn" btnType: "warn"
height: 216
showCancelButton: true showCancelButton: true
onClosed: { onClosed: {
destroy() destroy()

View File

@ -61,7 +61,7 @@ ModalPopup {
ConfirmationDialog { ConfirmationDialog {
id: declineAllDialog id: declineAllDialog
//% "Decline all contacts" //% "Decline all contacts"
title: qsTrId("decline-all-contacts") header.title: qsTrId("decline-all-contacts")
//% "Are you sure you want to decline all these contact requests" //% "Are you sure you want to decline all these contact requests"
confirmationText: qsTrId("are-you-sure-you-want-to-decline-all-these-contact-requests") confirmationText: qsTrId("are-you-sure-you-want-to-decline-all-these-contact-requests")
onConfirmButtonClicked: { onConfirmButtonClicked: {
@ -78,7 +78,7 @@ ModalPopup {
ConfirmationDialog { ConfirmationDialog {
id: acceptAllDialog id: acceptAllDialog
//% "Accept all contacts" //% "Accept all contacts"
title: qsTrId("accept-all-contacts") header.title: qsTrId("accept-all-contacts")
//% "Are you sure you want to accept all these contact requests" //% "Are you sure you want to accept all these contact requests"
confirmationText: qsTrId("are-you-sure-you-want-to-accept-all-these-contact-requests") confirmationText: qsTrId("are-you-sure-you-want-to-accept-all-these-contact-requests")
onConfirmButtonClicked: { onConfirmButtonClicked: {

View File

@ -219,7 +219,7 @@ StatusModal {
ConfirmationDialog { ConfirmationDialog {
id: removeContactConfirmationDialog id: removeContactConfirmationDialog
title: qsTr("Remove contact") header.title: qsTr("Remove contact")
confirmationText: qsTr("Are you sure you want to remove this contact?") confirmationText: qsTr("Are you sure you want to remove this contact?")
onConfirmButtonClicked: { onConfirmButtonClicked: {
if (profileModel.contacts.isAdded(fromAuthor)) { if (profileModel.contacts.isAdded(fromAuthor)) {

View File

@ -197,7 +197,7 @@ ScrollView {
id: confirmDialog id: confirmDialog
//% "Warning!" //% "Warning!"
title: qsTrId("close-app-title") header.title: qsTrId("close-app-title")
//% "The account will be logged out. When you login again, the selected mode will be enabled" //% "The account will be logged out. When you login again, the selected mode will be enabled"
confirmationText: qsTrId("the-account-will-be-logged-out--when-you-login-again--the-selected-mode-will-be-enabled") confirmationText: qsTrId("the-account-will-be-logged-out--when-you-login-again--the-selected-mode-will-be-enabled")
onConfirmButtonClicked: { onConfirmButtonClicked: {
@ -286,7 +286,6 @@ ScrollView {
ConfirmationDialog { ConfirmationDialog {
id: confirmationPopup id: confirmationPopup
property string settingsProp: "" property string settingsProp: ""
height: 310
showCancelButton: true showCancelButton: true
//% "This feature is experimental and is meant for testing purposes by core contributors and the community. It's not meant for real use and makes no claims of security or integrity of funds or data. Use at your own risk." //% "This feature is experimental and is meant for testing purposes by core contributors and the community. It's not meant for real use and makes no claims of security or integrity of funds or data. Use at your own risk."
confirmationText: (settingsProp === "isWalletV2Enabled" ? qsTr("<b>--DO NOT USE - UNDER ACTIVE DEVELOPMENT--</b>\n") : "") + confirmationText: (settingsProp === "isWalletV2Enabled" ? qsTr("<b>--DO NOT USE - UNDER ACTIVE DEVELOPMENT--</b>\n") : "") +

View File

@ -199,7 +199,7 @@ ModalPopup {
ConfirmationDialog { ConfirmationDialog {
id: confirmPopup id: confirmPopup
//% "Are you sure?" //% "Are you sure?"
title: qsTrId("are-you-sure?") header.title: qsTrId("are-you-sure?")
//% "You will not be able to see the whole seed phrase again" //% "You will not be able to see the whole seed phrase again"
confirmationText: qsTrId("are-you-sure-description") confirmationText: qsTrId("are-you-sure-description")
onConfirmButtonClicked: { onConfirmButtonClicked: {

View File

@ -69,7 +69,7 @@ ListView {
ConfirmationDialog { ConfirmationDialog {
id: removeContactConfirmationDialog id: removeContactConfirmationDialog
//% "Remove contact" //% "Remove contact"
title: qsTrId("remove-contact") header.title: qsTrId("remove-contact")
//% "Are you sure you want to remove this contact?" //% "Are you sure you want to remove this contact?"
confirmationText: qsTrId("are-you-sure-you-want-to-remove-this-contact-") confirmationText: qsTrId("are-you-sure-you-want-to-remove-this-contact-")
onConfirmButtonClicked: { onConfirmButtonClicked: {

View File

@ -354,7 +354,6 @@ Item {
ConfirmationDialog { ConfirmationDialog {
id: confirmationPopup id: confirmationPopup
height: 310
showCancelButton: true showCancelButton: true
confirmationText: qsTr("This feature is experimental and is meant for testing purposes by core contributors and the community. It's not meant for real use and makes no claims of security or integrity of funds or data. Use at your own risk.") confirmationText: qsTr("This feature is experimental and is meant for testing purposes by core contributors and the community. It's not meant for real use and makes no claims of security or integrity of funds or data. Use at your own risk.")
confirmButtonLabel: qsTr("I understand") confirmButtonLabel: qsTr("I understand")

View File

@ -23,7 +23,7 @@ StatusRadioButtonRow {
id: confirmDialogComponent id: confirmDialogComponent
ConfirmationDialog { ConfirmationDialog {
//% "Warning!" //% "Warning!"
title: qsTrId("close-app-title") header.title: qsTrId("close-app-title")
//% "Change fleet to %1" //% "Change fleet to %1"
confirmationText: qsTrId("change-fleet-to--1").arg(newFleet) confirmationText: qsTrId("change-fleet-to--1").arg(newFleet)
onConfirmButtonClicked: profileModel.fleets.setFleet(newFleet) onConfirmButtonClicked: profileModel.fleets.setFleet(newFleet)

View File

@ -27,7 +27,7 @@ ModalPopup {
active: Qt.platform.os === Constants.linux active: Qt.platform.os === Constants.linux
sourceComponent: ConfirmationDialog { sourceComponent: ConfirmationDialog {
property string newLocale property string newLocale
title: qsTr("Change language") header.title: qsTr("Change language")
confirmationText: qsTr("Display language has been changed. You must restart the application for changes to take effect.") confirmationText: qsTr("Display language has been changed. You must restart the application for changes to take effect.")
showCancelButton: true showCancelButton: true
confirmButtonLabel: qsTr("Close the app now") confirmButtonLabel: qsTr("Close the app now")

View File

@ -26,7 +26,7 @@ StatusRadioButtonRow {
ConfirmationDialog { ConfirmationDialog {
id: confirmDialog id: confirmDialog
//% "Warning!" //% "Warning!"
title: qsTrId("close-app-title") header.title: qsTrId("close-app-title")
//% "The account will be logged out. When you unlock it again, the selected network will be used" //% "The account will be logged out. When you unlock it again, the selected network will be used"
confirmationText: qsTrId("logout-app-content") confirmationText: qsTrId("logout-app-content")
onConfirmButtonClicked: { onConfirmButtonClicked: {

View File

@ -1,77 +1,100 @@
import QtQuick 2.13 import QtQuick 2.13
import QtQuick.Controls 2.13 import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13 import QtQuick.Layouts 1.13
import "../imports"
import "../shared/status"
import "./"
ModalPopup { import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Controls 0.1
import StatusQ.Popups 0.1
StatusModal {
id: confirmationDialog id: confirmationDialog
anchors.centerIn: parent
property Popup parentPopup property Popup parentPopup
property var value
property var executeConfirm
property var executeCancel
property string btnType: "warn" property string btnType: "warn"
property string confirmButtonLabel: qsTr("Confirm")
property string cancelButtonLabel: qsTr("Cancel")
property string confirmationText: qsTr("Are you sure you want to do this?")
property bool showCancelButton: false property bool showCancelButton: false
property alias checkbox: checkbox property alias checkbox: checkbox
height: 186 header.title: qsTr("Confirm you action")
width: 400
//% "Confirm your action"
title: qsTrId("confirm-your-action")
focus: visible focus: visible
//% "Confirm"
property string confirmButtonLabel: qsTrId("close-app-button")
//% "Cancel"
//% "Cancel"
property string cancelButtonLabel: qsTrId("browsing-cancel")
//% "Are you sure you want to this?"
property string confirmationText: qsTrId("are-you-sure-you-want-to-this-")
property var value
signal confirmButtonClicked() signal confirmButtonClicked()
signal cancelButtonClicked() signal cancelButtonClicked()
property var executeConfirm
property var executeCancel
Item { contentItem: Item {
anchors.fill: parent width: confirmationDialog.width
implicitHeight: childrenRect.height
Column {
width: parent.width - 32
anchors.horizontalCenter: parent.horizontalCenter
StyledText { Item {
id: innerText width: parent.width
text: confirmationDialog.confirmationText height: 16
font.pixelSize: 15 }
anchors.left: parent.left
anchors.right: parent.right
wrapMode: Text.WordWrap
}
StatusCheckBox { StatusBaseText {
id: checkbox text: confirmationDialog.confirmationText
visible: false font.pixelSize: 15
anchors.top: innerText.bottom anchors.left: parent.left
anchors.topMargin: Style.current.halfPadding anchors.right: parent.right
Layout.preferredWidth: parent.width wrapMode: Text.WordWrap
//% "Do not show this again" color: Theme.palette.directColor1
text: qsTrId("do-not-show-this-again") }
Item {
width: parent.width
height: 16
}
StatusCheckBox {
id: checkbox
visible: false
Layout.preferredWidth: parent.width
text: qsTr("Do not show this again")
}
Item {
width: parent.width
height: visible ? 16 : 0
visible: checkbox.visible
}
} }
} }
rightButtons: [
footer: Item { StatusFlatButton {
id: footerContainer id: cancelButton
width: parent.width visible: showCancelButton
height: confirmButton.height//children[0].height text: confirmationDialog.cancelButtonLabel
onClicked: {
if (executeCancel && typeof executeCancel === "function") {
executeCancel()
}
confirmationDialog.cancelButtonClicked()
}
},
StatusButton { StatusButton {
id: confirmButton id: confirmButton
type: confirmationDialog.btnType type: {
anchors.right: cancelButton.visible ? cancelButton.left : parent.right switch (confirmationDialog.btnType) {
anchors.rightMargin: cancelButton.visible ? Style.current.smallPadding : 0 case "warn":
return StatusBaseButton.Type.Danger
break
default:
return StatusBaseButton.Type.Primary
}
}
text: confirmationDialog.confirmButtonLabel text: confirmationDialog.confirmButtonLabel
anchors.bottom: parent.bottom
focus: true focus: true
Keys.onReturnPressed: function(event) { Keys.onReturnPressed: function(event) {
confirmButton.clicked() confirmButton.clicked()
@ -80,27 +103,8 @@ ModalPopup {
if (executeConfirm && typeof executeConfirm === "function") { if (executeConfirm && typeof executeConfirm === "function") {
executeConfirm() executeConfirm()
} }
confirmationDialog.confirmButtonClicked() confirmationDialog.confirmButtonClicked()
} }
} }
]
StatusButton {
id: cancelButton
anchors.right: parent.right
visible: showCancelButton
anchors.rightMargin: Style.current.smallPadding
text: confirmationDialog.cancelButtonLabel
anchors.bottom: parent.bottom
onClicked: {
if (executeCancel && typeof executeCancel === "function") {
executeCancel()
}
confirmationDialog.cancelButtonClicked()
}
}
}
} }

View File

@ -62,7 +62,6 @@ Popup {
ConfirmationDialog { ConfirmationDialog {
id: confirmationPopup id: confirmationPopup
height: 310
showCancelButton: true showCancelButton: true
confirmationText: qsTr("This feature is experimental and is meant for testing purposes by core contributors and the community. It's not meant for real use and makes no claims of security or integrity of funds or data. Use at your own risk.") confirmationText: qsTr("This feature is experimental and is meant for testing purposes by core contributors and the community. It's not meant for real use and makes no claims of security or integrity of funds or data. Use at your own risk.")
confirmButtonLabel: qsTr("I understand") confirmButtonLabel: qsTr("I understand")

View File

@ -160,7 +160,6 @@ Item {
ConfirmationDialog { ConfirmationDialog {
id: confirmationPopup id: confirmationPopup
height: 310
showCancelButton: true showCancelButton: true
confirmationText: qsTr("This feature is experimental and is meant for testing purposes by core contributors and the community. It's not meant for real use and makes no claims of security or integrity of funds or data. Use at your own risk.") confirmationText: qsTr("This feature is experimental and is meant for testing purposes by core contributors and the community. It's not meant for real use and makes no claims of security or integrity of funds or data. Use at your own risk.")
confirmButtonLabel: qsTr("I understand") confirmButtonLabel: qsTr("I understand")