feat: introduce dialog to confirm removal of contacts

Closes #632
This commit is contained in:
Pascal Precht 2020-08-10 14:15:57 +02:00 committed by Iuri Matias
parent 04ff3393fa
commit 6d0d0fb2aa
6 changed files with 83 additions and 2 deletions

View File

@ -126,6 +126,10 @@ StackLayout {
blockContactConfirmationDialog.contactAddress = address
blockContactConfirmationDialog.open()
}
onRemoveButtonClicked: {
removeContactConfirmationDialog.contactAddress = address
removeContactConfirmationDialog.open()
}
}
BlockContactConfirmationDialog {
@ -137,6 +141,16 @@ StackLayout {
}
}
RemoveContactConfirmationDialog {
id: removeContactConfirmationDialog
onRemoveButtonClicked: {
if (profileModel.isAdded(removeContactConfirmationDialog.contactAddress)) {
profileModel.removeContact(removeContactConfirmationDialog.contactAddress)
}
removeContactConfirmationDialog.close()
}
}
EmojiReactions {
id: reactionModel
}

View File

@ -18,6 +18,7 @@ ModalPopup {
property bool noFooter: false
signal blockButtonClicked(name: string, address: string)
signal removeButtonClicked(address: string)
function setPopupData(userNameParam, fromAuthorParam, identiconParam, textParam){
this.showQR = false
@ -290,7 +291,7 @@ ModalPopup {
anchors.bottom: parent.bottom
onClicked: {
if (profileModel.isAdded(fromAuthor)) {
chatsModel.removeContact(fromAuthor)
popup.removeButtonClicked(fromAuthor)
} else {
chatsModel.addContact(fromAuthor)
}

View File

@ -14,6 +14,7 @@ Rectangle {
property bool isBlocked: false
property string searchStr: ""
signal blockContactActionTriggered(name: string, address: string)
signal removeContactActionTriggered(address: string)
id: container
visible: isContact && (searchStr == "" || name.includes(searchStr))
@ -121,7 +122,9 @@ Rectangle {
icon.color: Style.current.red
text: qsTrId("remove-contact")
enabled: container.isContact
onTriggered: profileModel.removeContact(address)
onTriggered: {
container.removeContactActionTriggered(address)
}
}
Action {
icon.source: "../../../../img/block-icon.svg"

View File

@ -35,6 +35,10 @@ ListView {
blockContactConfirmationDialog.contactAddress = address
blockContactConfirmationDialog.open()
}
onRemoveContactActionTriggered: {
removeContactConfirmationDialog.contactAddress = address
removeContactConfirmationDialog.open()
}
}
ProfilePopup {
@ -44,6 +48,10 @@ ListView {
blockContactConfirmationDialog.contactAddress = address
blockContactConfirmationDialog.open()
}
onRemoveButtonClicked: {
removeContactConfirmationDialog.contactAddress = address
removeContactConfirmationDialog.open()
}
}
ButtonGroup {
@ -57,6 +65,16 @@ ListView {
blockContactConfirmationDialog.close()
}
}
RemoveContactConfirmationDialog {
id: removeContactConfirmationDialog
onRemoveButtonClicked: {
if (profileModel.isAdded(removeContactConfirmationDialog.contactAddress)) {
profileModel.removeContact(removeContactConfirmationDialog.contactAddress)
}
removeContactConfirmationDialog.close()
}
}
}
/*##^##
Designer {

View File

@ -0,0 +1,44 @@
import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13
import "../imports"
import "./"
ModalPopup {
id: removeContactConfirmationDialog
height: 186
width: 400
property string contactAddress: ""
signal removeButtonClicked()
title: qsTrId("remove-contact")
Text {
text: qsTr("Are you sure you want to remove this contact?")
font.pixelSize: 15
anchors.left: parent.left
anchors.right: parent.right
wrapMode: Text.WordWrap
}
footer: Item {
id: footerContainer
width: parent.width
height: children[0].height
StyledButton {
anchors.right: parent.right
anchors.rightMargin: Style.current.smallPadding
btnColor: Style.current.lightRed
btnBorderWidth: 1
btnBorderColor: Style.current.grey
textColor: Style.current.red
//% "Block User"
label: qsTrId("remove-contact")
anchors.bottom: parent.bottom
onClicked: removeContactConfirmationDialog.removeButtonClicked()
}
}
}

View File

@ -18,3 +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