From 6d0d0fb2aac721f540ac3ff15a6738493b2ff173 Mon Sep 17 00:00:00 2001 From: Pascal Precht Date: Mon, 10 Aug 2020 14:15:57 +0200 Subject: [PATCH] feat: introduce dialog to confirm removal of contacts Closes #632 --- ui/app/AppLayouts/Chat/ChatColumn.qml | 14 ++++++ .../Chat/components/ProfilePopup.qml | 3 +- .../Profile/Sections/Contacts/Contact.qml | 5 ++- .../Profile/Sections/Contacts/ContactList.qml | 18 ++++++++ ui/shared/RemoveContactConfirmationDialog.qml | 44 +++++++++++++++++++ ui/shared/qmldir | 1 + 6 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 ui/shared/RemoveContactConfirmationDialog.qml diff --git a/ui/app/AppLayouts/Chat/ChatColumn.qml b/ui/app/AppLayouts/Chat/ChatColumn.qml index 5a3e70a2b3..ccd8696cea 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn.qml @@ -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 } diff --git a/ui/app/AppLayouts/Chat/components/ProfilePopup.qml b/ui/app/AppLayouts/Chat/components/ProfilePopup.qml index c1e2629983..6d2bc5b74a 100644 --- a/ui/app/AppLayouts/Chat/components/ProfilePopup.qml +++ b/ui/app/AppLayouts/Chat/components/ProfilePopup.qml @@ -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) } diff --git a/ui/app/AppLayouts/Profile/Sections/Contacts/Contact.qml b/ui/app/AppLayouts/Profile/Sections/Contacts/Contact.qml index b834fe1174..31d366801c 100644 --- a/ui/app/AppLayouts/Profile/Sections/Contacts/Contact.qml +++ b/ui/app/AppLayouts/Profile/Sections/Contacts/Contact.qml @@ -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" diff --git a/ui/app/AppLayouts/Profile/Sections/Contacts/ContactList.qml b/ui/app/AppLayouts/Profile/Sections/Contacts/ContactList.qml index aeb0d9834e..ddf1880e90 100644 --- a/ui/app/AppLayouts/Profile/Sections/Contacts/ContactList.qml +++ b/ui/app/AppLayouts/Profile/Sections/Contacts/ContactList.qml @@ -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 { diff --git a/ui/shared/RemoveContactConfirmationDialog.qml b/ui/shared/RemoveContactConfirmationDialog.qml new file mode 100644 index 0000000000..f19dd1c410 --- /dev/null +++ b/ui/shared/RemoveContactConfirmationDialog.qml @@ -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() + } + } +} + + diff --git a/ui/shared/qmldir b/ui/shared/qmldir index 2a55a81aea..04c5a124b8 100644 --- a/ui/shared/qmldir +++ b/ui/shared/qmldir @@ -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