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

View File

@ -54,13 +54,14 @@ StatusPopupMenu {
readonly property bool isMyMutualContact: { readonly property bool isMyMutualContact: {
return root.selectedUserPublicKey !== "" && root.store.contactsStore.isMyMutualContact(root.selectedUserPublicKey); return root.selectedUserPublicKey !== "" && root.store.contactsStore.isMyMutualContact(root.selectedUserPublicKey);
} }
readonly property bool isBlockedContact: { readonly property bool isBlockedContact: d.contactDetails && d.contactDetails.isBlocked
return root.selectedUserPublicKey !== "" && root.store.contactsStore.isBlockedContact(root.selectedUserPublicKey);
}
readonly property bool hasPendingContactRequest: { readonly property bool hasPendingContactRequest: {
return root.selectedUserPublicKey !== "" && root.store.contactsStore.hasPendingContactRequest(root.selectedUserPublicKey); 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 setXPosition: function() {return 0}
property var setYPosition: function() {return 0} property var setYPosition: function() {return 0}
@ -98,6 +99,7 @@ StatusPopupMenu {
onClosed: { onClosed: {
// Reset selectedUserPublicKey so that associated properties get recalculated on re-open // Reset selectedUserPublicKey so that associated properties get recalculated on re-open
selectedUserPublicKey = "" selectedUserPublicKey = ""
d.contactDetails = {}
} }
onHeightChanged: { root.y = setYPosition(); } onHeightChanged: { root.y = setYPosition(); }
@ -108,7 +110,20 @@ StatusPopupMenu {
y = setYPosition() 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 { Item {
id: emojiContainer id: emojiContainer
@ -141,9 +156,15 @@ StatusPopupMenu {
width: parent.width width: parent.width
visible: root.isProfile visible: root.isProfile
displayNameVisible: false
displayNamePlusIconsVisible: true
editButtonVisible: false
displayName: root.selectedUserDisplayName displayName: root.selectedUserDisplayName
pubkey: root.selectedUserPublicKey pubkey: root.selectedUserPublicKey
icon: root.selectedUserIcon icon: root.selectedUserIcon
trustStatus: d.contactDetails.trustStatus
isContact: root.isMyMutualContact
isCurrentUser: root.isMe
} }
Item { 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 { StatusMenuItem {
text: qsTr("Rename") text: qsTr("Rename")
icon.name: "edit_pencil" 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 { StatusMenuItem {
id: replyToMenuItem id: replyToMenuItem
text: qsTr("Reply to") text: qsTr("Reply to")