refactor: Introduce more generic confirmation dialog for simpel cases
This commit is contained in:
parent
6d0d0fb2aa
commit
4f7486afbe
|
@ -18,6 +18,8 @@ StackLayout {
|
|||
|
||||
property var appSettings
|
||||
property bool isConnected: false
|
||||
property string contactToRemove: ""
|
||||
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
Layout.minimumWidth: 300
|
||||
|
@ -118,16 +120,15 @@ StackLayout {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
ProfilePopup {
|
||||
id: profilePopup
|
||||
onBlockButtonClicked: {
|
||||
blockContactConfirmationDialog.contactName = name
|
||||
blockContactConfirmationDialog.contactAddress = address
|
||||
chatColumnLayout.contact = address
|
||||
blockContactConfirmationDialog.open()
|
||||
}
|
||||
onRemoveButtonClicked: {
|
||||
removeContactConfirmationDialog.contactAddress = address
|
||||
chatColumnLayout.contactToRemove = address
|
||||
removeContactConfirmationDialog.open()
|
||||
}
|
||||
}
|
||||
|
@ -141,14 +142,17 @@ StackLayout {
|
|||
}
|
||||
}
|
||||
|
||||
RemoveContactConfirmationDialog {
|
||||
id: removeContactConfirmationDialog
|
||||
onRemoveButtonClicked: {
|
||||
if (profileModel.isAdded(removeContactConfirmationDialog.contactAddress)) {
|
||||
profileModel.removeContact(removeContactConfirmationDialog.contactAddress)
|
||||
}
|
||||
removeContactConfirmationDialog.close()
|
||||
}
|
||||
ConfirmationDialog {
|
||||
id: removeContactConfirmationDialog
|
||||
// % "Remove contact"
|
||||
title: qsTrId("remove-contact")
|
||||
confirmationText: qsTr("Are you sure you want to remove this contact?")
|
||||
onConfirmButtonClicked: {
|
||||
if (profileModel.isAdded(chatColumnLayout.contactToRemove)) {
|
||||
profileModel.removeContact(chatColumnLayout.contactToRemove)
|
||||
}
|
||||
removeContactConfirmationDialog.close()
|
||||
}
|
||||
}
|
||||
|
||||
EmojiReactions {
|
||||
|
|
|
@ -148,7 +148,14 @@ Rectangle {
|
|||
icon.color: Style.current.red
|
||||
//% "Delete Chat"
|
||||
text: qsTrId("delete-chat")
|
||||
onTriggered: chatsModel.leaveActiveChat()
|
||||
onTriggered: {
|
||||
//% "Delete Chat"
|
||||
deleteChatConfirmationDialog.title = qsTrId("delete-chat")
|
||||
//% "Delete Chat"
|
||||
deleteChatConfirmationDialog.confirmButtonLabel = qsTrId("delete-chat")
|
||||
deleteChatConfirmationDialog.confirmationText = qsTr("Are you sure you want to delete this chat?")
|
||||
deleteChatConfirmationDialog.open()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -179,7 +186,14 @@ Rectangle {
|
|||
icon.height: chatTopBarContent.iconSize
|
||||
//% "Leave Group"
|
||||
text: qsTrId("leave-group")
|
||||
onTriggered: chatsModel.leaveActiveChat()
|
||||
onTriggered: {
|
||||
//% "Leave group"
|
||||
deleteChatConfirmationDialog.title = qsTrId("leave-group")
|
||||
//% "Leave group"
|
||||
deleteChatConfirmationDialog.confirmButtonLabel = qsTrId("leave-group")
|
||||
deleteChatConfirmationDialog.confirmationText = qsTr("Are you sure you want to leave this chat?")
|
||||
deleteChatConfirmationDialog.open()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -203,4 +217,12 @@ Rectangle {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
ConfirmationDialog {
|
||||
id: deleteChatConfirmationDialog
|
||||
onConfirmButtonClicked: {
|
||||
chatsModel.leaveActiveChat()
|
||||
deleteChatConfirmationDialog.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ ListView {
|
|||
property alias selectedContact: contactGroup.checkedButton
|
||||
property string searchString: ""
|
||||
property string lowerCaseSearchString: searchString.toLowerCase()
|
||||
property string contactToRemove: ""
|
||||
|
||||
width: parent.width
|
||||
|
||||
|
@ -36,7 +37,7 @@ ListView {
|
|||
blockContactConfirmationDialog.open()
|
||||
}
|
||||
onRemoveContactActionTriggered: {
|
||||
removeContactConfirmationDialog.contactAddress = address
|
||||
contactList.contactToRemove = address
|
||||
removeContactConfirmationDialog.open()
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +50,7 @@ ListView {
|
|||
blockContactConfirmationDialog.open()
|
||||
}
|
||||
onRemoveButtonClicked: {
|
||||
removeContactConfirmationDialog.contactAddress = address
|
||||
contactList.contactToRemove = address
|
||||
removeContactConfirmationDialog.open()
|
||||
}
|
||||
}
|
||||
|
@ -66,11 +67,13 @@ ListView {
|
|||
}
|
||||
}
|
||||
|
||||
RemoveContactConfirmationDialog {
|
||||
ConfirmationDialog {
|
||||
id: removeContactConfirmationDialog
|
||||
onRemoveButtonClicked: {
|
||||
if (profileModel.isAdded(removeContactConfirmationDialog.contactAddress)) {
|
||||
profileModel.removeContact(removeContactConfirmationDialog.contactAddress)
|
||||
title: qsTrId("remove-contact")
|
||||
confirmationText: qsTr("Are you sure you want to remove this contact?")
|
||||
onConfirmButtonClicked: {
|
||||
if (profileModel.isAdded(contactList.contactToRemove)) {
|
||||
profileModel.removeContact(contactList.contactToRemove)
|
||||
}
|
||||
removeContactConfirmationDialog.close()
|
||||
}
|
||||
|
|
|
@ -5,21 +5,22 @@ import "../imports"
|
|||
import "./"
|
||||
|
||||
ModalPopup {
|
||||
id: removeContactConfirmationDialog
|
||||
id: confirmationDialog
|
||||
height: 186
|
||||
width: 400
|
||||
property string contactAddress: ""
|
||||
signal removeButtonClicked()
|
||||
title: qsTrId("remove-contact")
|
||||
title: qsTr("Confirm your action")
|
||||
|
||||
property string confirmButtonLabel: qsTr("Confirm")
|
||||
property string confirmationText: qsTr("Are you sure you want to this?")
|
||||
signal confirmButtonClicked()
|
||||
|
||||
Text {
|
||||
text: qsTr("Are you sure you want to remove this contact?")
|
||||
text: confirmationDialog.confirmationText
|
||||
font.pixelSize: 15
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
wrapMode: Text.WordWrap
|
||||
}
|
||||
|
||||
|
||||
footer: Item {
|
||||
id: footerContainer
|
||||
|
@ -33,12 +34,12 @@ ModalPopup {
|
|||
btnBorderWidth: 1
|
||||
btnBorderColor: Style.current.grey
|
||||
textColor: Style.current.red
|
||||
//% "Block User"
|
||||
label: qsTrId("remove-contact")
|
||||
label: confirmationDialog.confirmButtonLabel
|
||||
anchors.bottom: parent.bottom
|
||||
onClicked: removeContactConfirmationDialog.removeButtonClicked()
|
||||
onClicked: confirmationDialog.confirmButtonClicked()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -18,4 +18,4 @@ SplitViewHandle 1.0 SplitViewHandle.qml
|
|||
CopyToClipBoardButton 1.0 CopyToClipBoardButton.qml
|
||||
NotificationWindow 1.0 NotificationWindow.qml
|
||||
BlockContactConfirmationDialog 1.0 BlockContactConfirmationDialog.qml
|
||||
RemoveContactConfirmationDialog 1.0 RemoveContactConfirmationDialog.qml
|
||||
ConfirmationDialog 1.0 ConfirmationDialog.qml
|
||||
|
|
Loading…
Reference in New Issue