fix(MessageContextMenuView): popup menu's fixes

- add the (Un)Mark as Untrustworthy action to the menu
- fix the placement and visuals of the (Un)Block menu item
- add a missing separator above these
- store the blocked and trust details in `d.contactDetails` and properly
  refresh it upon opening the menu
- some other smaller UI fixes to align the menu to the design

Closes #6538: Stranger's (untrustworthy) menu doesn't match the Design

Closes #6535: The stranger's card doesn't match the Design
This commit is contained in:
Lukáš Tinkl 2022-07-21 13:02:31 +02:00 committed by Iuri Matias
parent 9ddd75c8f5
commit 89f42c9fc3
2 changed files with 85 additions and 41 deletions

View File

@ -33,6 +33,7 @@ Item {
property bool pubkeyVisibleWithCopy: false
property bool emojiHashVisible: true
property bool editImageButtonVisible: false
property bool editButtonVisible: displayNamePlusIconsVisible
readonly property bool compact: root.imageSize === ProfileHeader.ImageSize.Compact
signal clicked()
@ -115,11 +116,14 @@ Item {
}
RowLayout {
spacing: Style.current.halfPadding
spacing: compact ? 4 : Style.current.halfPadding
Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter
visible: root.displayNamePlusIconsVisible
StyledText {
Layout.maximumWidth: root.width - Style.current.xlPadding
text: root.displayName
elide: Text.ElideRight
font {
weight: Font.Medium
pixelSize: Style.current.primaryTextFontSize
@ -128,8 +132,8 @@ Item {
Loader {
sourceComponent: SVGImage {
height: 16
width: 16
height: compact ? 10 : 16
width: compact ? 10 : 16
source: Style.svg("contact")
}
active: isContact && !root.isCurrentUser
@ -138,27 +142,30 @@ Item {
Loader {
sourceComponent: VerificationLabel {
id: trustStatus
trustStatus: root.trustStatus
height: 16
width: 16
height: compact ? 10 : 16
width: compact ? 10 : 16
}
active: root.trustStatus !== Constants.trustStatus.unknown && !root.isCurrentUser
visible: active
}
SVGImage {
height: 16
width: 16
source: Style.svg("edit-message")
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
acceptedButtons: Qt.LeftButton
onClicked: {
root.editClicked()
Loader {
sourceComponent: SVGImage {
height: compact ? 10 : 16
width: compact ? 10 : 16
source: Style.svg("edit-message")
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
acceptedButtons: Qt.LeftButton
onClicked: {
root.editClicked()
}
}
}
active: root.editButtonVisible
visible: active
}
}

View File

@ -54,13 +54,14 @@ StatusPopupMenu {
readonly property bool isMyMutualContact: {
return root.selectedUserPublicKey !== "" && root.store.contactsStore.isMyMutualContact(root.selectedUserPublicKey);
}
readonly property bool isBlockedContact: {
return root.selectedUserPublicKey !== "" && root.store.contactsStore.isBlockedContact(root.selectedUserPublicKey);
}
readonly property bool isBlockedContact: d.contactDetails && d.contactDetails.isBlocked
readonly property bool hasPendingContactRequest: {
return root.selectedUserPublicKey !== "" && root.store.contactsStore.hasPendingContactRequest(root.selectedUserPublicKey);
}
readonly property bool userTrustIsUnknown: d.contactDetails && d.contactDetails.trustStatus === Constants.trustStatus.unknown
readonly property bool userIsUntrustworthy: d.contactDetails && d.contactDetails.trustStatus === Constants.trustStatus.untrustworthy
property var setXPosition: function() {return 0}
property var setYPosition: function() {return 0}
@ -98,6 +99,7 @@ StatusPopupMenu {
onClosed: {
// Reset selectedUserPublicKey so that associated properties get recalculated on re-open
selectedUserPublicKey = ""
d.contactDetails = {}
}
onHeightChanged: { root.y = setYPosition(); }
@ -108,7 +110,20 @@ StatusPopupMenu {
y = setYPosition()
}
width: Math.max(emojiContainer.visible ? emojiContainer.width : 0, 200)
width: Math.max(emojiContainer.visible ? emojiContainer.width : 0, 230)
onAboutToShow: {
if (root.isProfile && root.selectedUserPublicKey !== "") {
d.contactDetails = Utils.getContactDetailsAsJson(root.selectedUserPublicKey)
} else {
d.contactDetails = {}
}
}
QtObject {
id: d
property var contactDetails: ({})
}
Item {
id: emojiContainer
@ -141,9 +156,15 @@ StatusPopupMenu {
width: parent.width
visible: root.isProfile
displayNameVisible: false
displayNamePlusIconsVisible: true
editButtonVisible: false
displayName: root.selectedUserDisplayName
pubkey: root.selectedUserPublicKey
icon: root.selectedUserIcon
trustStatus: d.contactDetails.trustStatus
isContact: root.isMyMutualContact
isCurrentUser: root.isMe
}
Item {
@ -207,27 +228,6 @@ StatusPopupMenu {
}
}
StatusMenuItem {
text: qsTr("Block User")
icon.name: "cancel"
icon.color: Style.current.danger
enabled: root.isProfile && !root.isMe && !root.isBlockedContact
onTriggered: {
root.openProfileClicked(root.selectedUserPublicKey, "blockUser")
root.close()
}
}
StatusMenuItem {
text: qsTr("Unblock User")
icon.name: "remove"
enabled: root.isProfile && !root.isMe && root.isBlockedContact
onTriggered: {
root.openProfileClicked(root.selectedUserPublicKey, "unblockUser")
root.close()
}
}
StatusMenuItem {
text: qsTr("Rename")
icon.name: "edit_pencil"
@ -238,6 +238,43 @@ StatusPopupMenu {
}
}
StatusMenuItem {
text: qsTr("Unblock User")
icon.name: "remove-circle"
enabled: root.isProfile && !root.isMe && root.isBlockedContact
onTriggered: root.store.contactsStore.unblockContact(root.selectedUserPublicKey)
}
StatusMenuSeparator {
visible: blockMenuItem.enabled || markUntrustworthyMenuItem.enabled || removeUntrustworthyMarkMenuItem.enabled
}
StatusMenuItem {
id: markUntrustworthyMenuItem
text: qsTr("Mark as Untrustworthy")
icon.name: "warning"
type: StatusMenuItem.Type.Danger
enabled: root.isProfile && !root.isMe && root.userTrustIsUnknown
onTriggered: root.store.contactsStore.markUntrustworthy(root.selectedUserPublicKey)
}
StatusMenuItem {
id: removeUntrustworthyMarkMenuItem
text: qsTr("Remove Untrustworthy Mark")
icon.name: "warning"
enabled: root.isProfile && !root.isMe && root.userIsUntrustworthy
onTriggered: root.store.contactsStore.removeTrustStatus(root.selectedUserPublicKey)
}
StatusMenuItem {
id: blockMenuItem
text: qsTr("Block User")
icon.name: "cancel"
type: StatusMenuItem.Type.Danger
enabled: root.isProfile && !root.isMe && !root.isBlockedContact
onTriggered: root.store.contactsStore.blockContact(root.selectedUserPublicKey)
}
StatusMenuItem {
id: replyToMenuItem
text: qsTr("Reply to")