From adc8f5bc3a5e78599e4c51ba8fa19b968c675458 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Cie=C5=9Blak?= Date: Fri, 25 Oct 2024 17:30:48 +0200 Subject: [PATCH] ContactPanel api simplified --- .../Profile/panels/ContactPanel.qml | 44 +++++----------- .../Profile/panels/ContactsListPanel.qml | 50 +++++++------------ 2 files changed, 29 insertions(+), 65 deletions(-) diff --git a/ui/app/AppLayouts/Profile/panels/ContactPanel.qml b/ui/app/AppLayouts/Profile/panels/ContactPanel.qml index 5cc5246098..428f0d07d9 100644 --- a/ui/app/AppLayouts/Profile/panels/ContactPanel.qml +++ b/ui/app/AppLayouts/Profile/panels/ContactPanel.qml @@ -15,32 +15,23 @@ StatusListItem { title: root.name property string name - property string publicKey property string iconSource property color pubKeyColor property var colorHash - property bool isContact: false - property bool isBlocked: false - property bool isVerified: false - property bool isUntrustworthy: false - property int verificationRequestStatus: 0 - property bool showSendMessageButton: false property bool showRejectContactRequestButton: false property bool showAcceptContactRequestButton: false property bool showRemoveRejectionButton: false property string contactText: "" - property bool contactTextClickable: false - signal openContactContextMenu(string publicKey, string name, string icon) - signal sendMessageActionTriggered(string publicKey) - signal showVerificationRequest(string publicKey) - signal contactRequestAccepted(string publicKey) - signal contactRequestRejected(string publicKey) - signal rejectionRemoved(string publicKey) - signal textClicked(string publicKey) + signal contextMenuRequested + signal sendMessageRequested + signal showVerificationRequestRequested + signal acceptContactRequested + signal rejectRequestRequested + signal removeRejectionRequested asset.width: 40 asset.height: 40 @@ -62,7 +53,7 @@ StatusListItem { height: visible ? 32 : 0 icon.name: "chat" icon.color: Theme.palette.directColor1 - onClicked: root.sendMessageActionTriggered(root.publicKey) + onClicked: root.sendMessageRequested() }, StatusFlatRoundButton { objectName: "declineBtn" @@ -71,7 +62,7 @@ StatusListItem { height: visible ? 32 : 0 icon.name: "close-circle" icon.color: Theme.palette.dangerColor1 - onClicked: root.contactRequestRejected(root.publicKey) + onClicked: root.rejectRequestRequested() }, StatusFlatRoundButton { objectName: "acceptBtn" @@ -80,7 +71,7 @@ StatusListItem { height: visible ? 32 : 0 icon.name: "checkmark-circle" icon.color: Theme.palette.successColor1 - onClicked: root.contactRequestAccepted(root.publicKey) + onClicked: root.acceptContactRequested() }, StatusFlatRoundButton { objectName: "removeRejectBtn" @@ -89,22 +80,13 @@ StatusListItem { height: visible ? 32 : 0 icon.name: "cancel" icon.color: Theme.palette.dangerColor1 - onClicked: root.rejectionRemoved(root.publicKey) + onClicked: root.removeRejectionRequested() }, StatusBaseText { text: root.contactText anchors.verticalCenter: parent.verticalCenter - color: root.contactTextClickable? Theme.palette.directColor1 : Theme.palette.baseColor1 - MouseArea { - anchors.fill: parent - enabled: root.contactTextClickable - cursorShape: sensor.enabled && containsMouse ? Qt.PointingHandCursor : Qt.ArrowCursor - hoverEnabled: true - onClicked: { - root.textClicked(root.publicKey) - } - } + color: Theme.palette.baseColor1 }, StatusFlatRoundButton { objectName: "moreBtn" @@ -113,9 +95,7 @@ StatusListItem { height: 32 icon.name: "more" icon.color: Theme.palette.directColor1 - onClicked: { - root.openContactContextMenu(root.publicKey, root.name, root.iconSource) - } + onClicked: root.contextMenuRequested() } ] } diff --git a/ui/app/AppLayouts/Profile/panels/ContactsListPanel.qml b/ui/app/AppLayouts/Profile/panels/ContactsListPanel.qml index 8a5d21e2ca..3c9c864986 100644 --- a/ui/app/AppLayouts/Profile/panels/ContactsListPanel.qml +++ b/ui/app/AppLayouts/Profile/panels/ContactsListPanel.qml @@ -11,8 +11,6 @@ import shared 1.0 import shared.popups 1.0 import shared.panels 1.0 -import "../../Chat/popups" - import SortFilterProxyModel 0.2 Item { @@ -28,13 +26,11 @@ Item { readonly property int count: contactsList.count signal openContactContextMenu(string publicKey, string name, string icon) - signal contactClicked(string publicKey) signal sendMessageActionTriggered(string publicKey) signal showVerificationRequest(string publicKey) signal contactRequestAccepted(string publicKey) signal contactRequestRejected(string publicKey) signal rejectionRemoved(string publicKey) - signal textClicked(string publicKey) StyledText { id: title @@ -102,63 +98,51 @@ Item { width: ListView.view.width name: model.preferredDisplayName - publicKey: model.pubKey iconSource: model.icon - isContact: model.isContact - isBlocked: model.isBlocked - isVerified: model.isVerified - isUntrustworthy: model.isUntrustworthy subTitle: model.ensVerified ? "" : Utils.getElidedCompressedPk(model.pubKey) pubKeyColor: Utils.colorForPubkey(model.pubKey) colorHash: Utils.getColorHashAsJson(model.pubKey, model.ensVerified) - showSendMessageButton: isContact && !isBlocked - onOpenContactContextMenu: function (publicKey, name, icon) { - root.openContactContextMenu(publicKey, name, icon) - } + showSendMessageButton: model.isContact && !model.isBlocked showRejectContactRequestButton: { - if (root.panelUsage === Constants.contactsPanelUsage.receivedContactRequest && !model.verificationRequestStatus) { + if (root.panelUsage === Constants.contactsPanelUsage.receivedContactRequest + && !model.verificationRequestStatus) return true - } return false } showAcceptContactRequestButton: { - if (root.panelUsage === Constants.contactsPanelUsage.receivedContactRequest && !model.verificationRequestStatus) { + if (root.panelUsage === Constants.contactsPanelUsage.receivedContactRequest + && !model.verificationRequestStatus) return true - } return false } showRemoveRejectionButton: { - if (root.panelUsage === Constants.contactsPanelUsage.rejectedReceivedContactRequest) { + if (root.panelUsage === Constants.contactsPanelUsage.rejectedReceivedContactRequest) return true - } return false } contactText: { - if (root.panelUsage === Constants.contactsPanelUsage.sentContactRequest) { + if (root.panelUsage === Constants.contactsPanelUsage.sentContactRequest) return qsTr("Contact Request Sent") - } - else if (root.panelUsage === Constants.contactsPanelUsage.rejectedSentContactRequest) { + + if (root.panelUsage === Constants.contactsPanelUsage.rejectedSentContactRequest) return qsTr("Contact Request Rejected") - } return "" } - contactTextClickable: { - return false - } - onClicked: root.contactClicked(model.pubKey) - onSendMessageActionTriggered: root.sendMessageActionTriggered(publicKey) - onContactRequestAccepted: root.contactRequestAccepted(publicKey) - onContactRequestRejected: root.contactRequestRejected(publicKey) - onRejectionRemoved: root.rejectionRemoved(publicKey) - onTextClicked: root.textClicked(publicKey) - onShowVerificationRequest: root.showVerificationRequest(publicKey) + + onContextMenuRequested: root.openContactContextMenu( + model.pubKey, model.preferredDisplayName, model.icon) + onSendMessageRequested: root.sendMessageActionTriggered(model.pubKey) + onAcceptContactRequested: root.contactRequestAccepted(model.pubKey) + onRejectRequestRequested: root.contactRequestRejected(model.pubKey) + onRemoveRejectionRequested: root.rejectionRemoved(model.pubKey) + onShowVerificationRequestRequested: root.showVerificationRequest(model.pubKey) } } }