ContactPanel api simplified
This commit is contained in:
parent
9b5b5a4a60
commit
adc8f5bc3a
|
@ -15,32 +15,23 @@ StatusListItem {
|
||||||
title: root.name
|
title: root.name
|
||||||
|
|
||||||
property string name
|
property string name
|
||||||
property string publicKey
|
|
||||||
property string iconSource
|
property string iconSource
|
||||||
|
|
||||||
property color pubKeyColor
|
property color pubKeyColor
|
||||||
property var colorHash
|
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 showSendMessageButton: false
|
||||||
property bool showRejectContactRequestButton: false
|
property bool showRejectContactRequestButton: false
|
||||||
property bool showAcceptContactRequestButton: false
|
property bool showAcceptContactRequestButton: false
|
||||||
property bool showRemoveRejectionButton: false
|
property bool showRemoveRejectionButton: false
|
||||||
property string contactText: ""
|
property string contactText: ""
|
||||||
property bool contactTextClickable: false
|
|
||||||
|
|
||||||
signal openContactContextMenu(string publicKey, string name, string icon)
|
signal contextMenuRequested
|
||||||
signal sendMessageActionTriggered(string publicKey)
|
signal sendMessageRequested
|
||||||
signal showVerificationRequest(string publicKey)
|
signal showVerificationRequestRequested
|
||||||
signal contactRequestAccepted(string publicKey)
|
signal acceptContactRequested
|
||||||
signal contactRequestRejected(string publicKey)
|
signal rejectRequestRequested
|
||||||
signal rejectionRemoved(string publicKey)
|
signal removeRejectionRequested
|
||||||
signal textClicked(string publicKey)
|
|
||||||
|
|
||||||
asset.width: 40
|
asset.width: 40
|
||||||
asset.height: 40
|
asset.height: 40
|
||||||
|
@ -62,7 +53,7 @@ StatusListItem {
|
||||||
height: visible ? 32 : 0
|
height: visible ? 32 : 0
|
||||||
icon.name: "chat"
|
icon.name: "chat"
|
||||||
icon.color: Theme.palette.directColor1
|
icon.color: Theme.palette.directColor1
|
||||||
onClicked: root.sendMessageActionTriggered(root.publicKey)
|
onClicked: root.sendMessageRequested()
|
||||||
},
|
},
|
||||||
StatusFlatRoundButton {
|
StatusFlatRoundButton {
|
||||||
objectName: "declineBtn"
|
objectName: "declineBtn"
|
||||||
|
@ -71,7 +62,7 @@ StatusListItem {
|
||||||
height: visible ? 32 : 0
|
height: visible ? 32 : 0
|
||||||
icon.name: "close-circle"
|
icon.name: "close-circle"
|
||||||
icon.color: Theme.palette.dangerColor1
|
icon.color: Theme.palette.dangerColor1
|
||||||
onClicked: root.contactRequestRejected(root.publicKey)
|
onClicked: root.rejectRequestRequested()
|
||||||
},
|
},
|
||||||
StatusFlatRoundButton {
|
StatusFlatRoundButton {
|
||||||
objectName: "acceptBtn"
|
objectName: "acceptBtn"
|
||||||
|
@ -80,7 +71,7 @@ StatusListItem {
|
||||||
height: visible ? 32 : 0
|
height: visible ? 32 : 0
|
||||||
icon.name: "checkmark-circle"
|
icon.name: "checkmark-circle"
|
||||||
icon.color: Theme.palette.successColor1
|
icon.color: Theme.palette.successColor1
|
||||||
onClicked: root.contactRequestAccepted(root.publicKey)
|
onClicked: root.acceptContactRequested()
|
||||||
},
|
},
|
||||||
StatusFlatRoundButton {
|
StatusFlatRoundButton {
|
||||||
objectName: "removeRejectBtn"
|
objectName: "removeRejectBtn"
|
||||||
|
@ -89,22 +80,13 @@ StatusListItem {
|
||||||
height: visible ? 32 : 0
|
height: visible ? 32 : 0
|
||||||
icon.name: "cancel"
|
icon.name: "cancel"
|
||||||
icon.color: Theme.palette.dangerColor1
|
icon.color: Theme.palette.dangerColor1
|
||||||
onClicked: root.rejectionRemoved(root.publicKey)
|
onClicked: root.removeRejectionRequested()
|
||||||
},
|
},
|
||||||
StatusBaseText {
|
StatusBaseText {
|
||||||
text: root.contactText
|
text: root.contactText
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
color: root.contactTextClickable? Theme.palette.directColor1 : Theme.palette.baseColor1
|
|
||||||
|
|
||||||
MouseArea {
|
color: Theme.palette.baseColor1
|
||||||
anchors.fill: parent
|
|
||||||
enabled: root.contactTextClickable
|
|
||||||
cursorShape: sensor.enabled && containsMouse ? Qt.PointingHandCursor : Qt.ArrowCursor
|
|
||||||
hoverEnabled: true
|
|
||||||
onClicked: {
|
|
||||||
root.textClicked(root.publicKey)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
StatusFlatRoundButton {
|
StatusFlatRoundButton {
|
||||||
objectName: "moreBtn"
|
objectName: "moreBtn"
|
||||||
|
@ -113,9 +95,7 @@ StatusListItem {
|
||||||
height: 32
|
height: 32
|
||||||
icon.name: "more"
|
icon.name: "more"
|
||||||
icon.color: Theme.palette.directColor1
|
icon.color: Theme.palette.directColor1
|
||||||
onClicked: {
|
onClicked: root.contextMenuRequested()
|
||||||
root.openContactContextMenu(root.publicKey, root.name, root.iconSource)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,6 @@ import shared 1.0
|
||||||
import shared.popups 1.0
|
import shared.popups 1.0
|
||||||
import shared.panels 1.0
|
import shared.panels 1.0
|
||||||
|
|
||||||
import "../../Chat/popups"
|
|
||||||
|
|
||||||
import SortFilterProxyModel 0.2
|
import SortFilterProxyModel 0.2
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
@ -28,13 +26,11 @@ Item {
|
||||||
readonly property int count: contactsList.count
|
readonly property int count: contactsList.count
|
||||||
|
|
||||||
signal openContactContextMenu(string publicKey, string name, string icon)
|
signal openContactContextMenu(string publicKey, string name, string icon)
|
||||||
signal contactClicked(string publicKey)
|
|
||||||
signal sendMessageActionTriggered(string publicKey)
|
signal sendMessageActionTriggered(string publicKey)
|
||||||
signal showVerificationRequest(string publicKey)
|
signal showVerificationRequest(string publicKey)
|
||||||
signal contactRequestAccepted(string publicKey)
|
signal contactRequestAccepted(string publicKey)
|
||||||
signal contactRequestRejected(string publicKey)
|
signal contactRequestRejected(string publicKey)
|
||||||
signal rejectionRemoved(string publicKey)
|
signal rejectionRemoved(string publicKey)
|
||||||
signal textClicked(string publicKey)
|
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
id: title
|
id: title
|
||||||
|
@ -102,63 +98,51 @@ Item {
|
||||||
|
|
||||||
width: ListView.view.width
|
width: ListView.view.width
|
||||||
name: model.preferredDisplayName
|
name: model.preferredDisplayName
|
||||||
publicKey: model.pubKey
|
|
||||||
iconSource: model.icon
|
iconSource: model.icon
|
||||||
isContact: model.isContact
|
|
||||||
isBlocked: model.isBlocked
|
|
||||||
isVerified: model.isVerified
|
|
||||||
isUntrustworthy: model.isUntrustworthy
|
|
||||||
|
|
||||||
subTitle: model.ensVerified ? "" : Utils.getElidedCompressedPk(model.pubKey)
|
subTitle: model.ensVerified ? "" : Utils.getElidedCompressedPk(model.pubKey)
|
||||||
pubKeyColor: Utils.colorForPubkey(model.pubKey)
|
pubKeyColor: Utils.colorForPubkey(model.pubKey)
|
||||||
colorHash: Utils.getColorHashAsJson(model.pubKey, model.ensVerified)
|
colorHash: Utils.getColorHashAsJson(model.pubKey, model.ensVerified)
|
||||||
|
|
||||||
showSendMessageButton: isContact && !isBlocked
|
showSendMessageButton: model.isContact && !model.isBlocked
|
||||||
onOpenContactContextMenu: function (publicKey, name, icon) {
|
|
||||||
root.openContactContextMenu(publicKey, name, icon)
|
|
||||||
}
|
|
||||||
showRejectContactRequestButton: {
|
showRejectContactRequestButton: {
|
||||||
if (root.panelUsage === Constants.contactsPanelUsage.receivedContactRequest && !model.verificationRequestStatus) {
|
if (root.panelUsage === Constants.contactsPanelUsage.receivedContactRequest
|
||||||
|
&& !model.verificationRequestStatus)
|
||||||
return true
|
return true
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
showAcceptContactRequestButton: {
|
showAcceptContactRequestButton: {
|
||||||
if (root.panelUsage === Constants.contactsPanelUsage.receivedContactRequest && !model.verificationRequestStatus) {
|
if (root.panelUsage === Constants.contactsPanelUsage.receivedContactRequest
|
||||||
|
&& !model.verificationRequestStatus)
|
||||||
return true
|
return true
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
showRemoveRejectionButton: {
|
showRemoveRejectionButton: {
|
||||||
if (root.panelUsage === Constants.contactsPanelUsage.rejectedReceivedContactRequest) {
|
if (root.panelUsage === Constants.contactsPanelUsage.rejectedReceivedContactRequest)
|
||||||
return true
|
return true
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
contactText: {
|
contactText: {
|
||||||
if (root.panelUsage === Constants.contactsPanelUsage.sentContactRequest) {
|
if (root.panelUsage === Constants.contactsPanelUsage.sentContactRequest)
|
||||||
return qsTr("Contact Request Sent")
|
return qsTr("Contact Request Sent")
|
||||||
}
|
|
||||||
else if (root.panelUsage === Constants.contactsPanelUsage.rejectedSentContactRequest) {
|
if (root.panelUsage === Constants.contactsPanelUsage.rejectedSentContactRequest)
|
||||||
return qsTr("Contact Request Rejected")
|
return qsTr("Contact Request Rejected")
|
||||||
}
|
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
contactTextClickable: {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
onClicked: root.contactClicked(model.pubKey)
|
|
||||||
onSendMessageActionTriggered: root.sendMessageActionTriggered(publicKey)
|
onContextMenuRequested: root.openContactContextMenu(
|
||||||
onContactRequestAccepted: root.contactRequestAccepted(publicKey)
|
model.pubKey, model.preferredDisplayName, model.icon)
|
||||||
onContactRequestRejected: root.contactRequestRejected(publicKey)
|
onSendMessageRequested: root.sendMessageActionTriggered(model.pubKey)
|
||||||
onRejectionRemoved: root.rejectionRemoved(publicKey)
|
onAcceptContactRequested: root.contactRequestAccepted(model.pubKey)
|
||||||
onTextClicked: root.textClicked(publicKey)
|
onRejectRequestRequested: root.contactRequestRejected(model.pubKey)
|
||||||
onShowVerificationRequest: root.showVerificationRequest(publicKey)
|
onRemoveRejectionRequested: root.rejectionRemoved(model.pubKey)
|
||||||
|
onShowVerificationRequestRequested: root.showVerificationRequest(model.pubKey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue