fix: contact ID verification and community intro sizing issues

- port to StatusDialog
- fix binding loops
- fix `timestamp` to be a double rather than a `string`

Fixes #9563
This commit is contained in:
Lukáš Tinkl 2023-02-17 11:25:48 +01:00 committed by Lukáš Tinkl
parent 27b8180fdd
commit 277de1b544
8 changed files with 57 additions and 82 deletions

View File

@ -70,7 +70,7 @@ Nemo enim 😋 ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit,
Label { Label {
Layout.fillWidth: true Layout.fillWidth: true
text: "Nadialogme" text: "Community name"
font.weight: Font.Bold font.weight: Font.Bold
} }

View File

@ -132,6 +132,7 @@ Button {
text: root.text text: root.text
color: d.textColor color: d.textColor
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
} }
} }

View File

@ -23,26 +23,6 @@ StatusDialog {
signal joined signal joined
signal cancelMembershipRequest signal cancelMembershipRequest
QtObject {
id: d
readonly property int maxWidth: 640
readonly property int minWidth: 300
readonly property int maxHeight: 640
function getHorizontalPaddings() {
return root.leftPadding + root.rightPadding
}
function getVerticalPaddings() {
return root.topPadding + root.bottomPadding
}
function getMaxMinWidth() {
return Math.max(introText.implicitWidth, d.minWidth - d.getHorizontalPaddings())
}
}
title: qsTr("Welcome to %1").arg(name) title: qsTr("Welcome to %1").arg(name)
footer: StatusDialogFooter { footer: StatusDialogFooter {
@ -55,6 +35,7 @@ StatusDialog {
type: root.isInvitationPending ? StatusBaseButton.Type.Danger type: root.isInvitationPending ? StatusBaseButton.Type.Danger
: StatusBaseButton.Type.Normal : StatusBaseButton.Type.Normal
enabled: checkBox.checked || root.isInvitationPending enabled: checkBox.checked || root.isInvitationPending
textFillWidth: true
onClicked: { onClicked: {
if (root.isInvitationPending) { if (root.isInvitationPending) {
root.cancelMembershipRequest() root.cancelMembershipRequest()
@ -68,20 +49,16 @@ StatusDialog {
} }
} }
implicitWidth: Math.min(d.getMaxMinWidth(), d.maxWidth - d.getHorizontalPaddings()) contentItem: StatusScrollView {
implicitHeight: Math.min(columnContent.height + footer.height + header.height + d.getVerticalPaddings(), d.maxHeight)
StatusScrollView {
anchors.fill: parent
contentHeight: columnContent.height
contentWidth: columnContent.width
padding: 0 padding: 0
implicitWidth: 640 // by design
implicitHeight: columnContent.childrenRect.height
ColumnLayout { ColumnLayout {
id: columnContent id: columnContent
spacing: 24 spacing: 24
width: Math.max(root.width - d.getHorizontalPaddings(), d.minWidth - d.getHorizontalPaddings()) width: root.availableWidth
StatusRoundedImage { StatusRoundedImage {
id: roundImage id: roundImage

View File

@ -1,18 +1,19 @@
import QtQuick 2.14 import QtQuick 2.14
import QtQuick.Controls 2.14 import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14 import QtQuick.Layouts 1.14
import QtQml.Models 2.14
import StatusQ.Core 0.1 import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1 import StatusQ.Core.Theme 0.1
import StatusQ.Controls 0.1 import StatusQ.Controls 0.1
import StatusQ.Popups 0.1 import StatusQ.Popups.Dialog 0.1
import shared.controls 1.0 import shared.controls 1.0
import shared.views.chat 1.0 import shared.views.chat 1.0
import utils 1.0 import utils 1.0
StatusModal { StatusDialog {
id: root id: root
property var contactsStore property var contactsStore
@ -58,27 +59,25 @@ StatusModal {
property string senderIcon: "" property string senderIcon: ""
property string challengeText: "" property string challengeText: ""
property string responseText: "" property string responseText: ""
property string messageTimestamp: "" property double messageTimestamp
property string responseTimestamp: "" property double responseTimestamp
} }
anchors.centerIn: parent title: qsTr("%1 is asking you to verify your identity").arg(d.senderDisplayName)
header.title: qsTr("%1 is asking you to verify your identity").arg(d.senderDisplayName)
onOpened: { onAboutToShow: {
root.updateVerificationDetails() root.updateVerificationDetails()
verificationResponse.input.edit.forceActiveFocus(Qt.MouseFocusReason) verificationResponse.input.edit.forceActiveFocus(Qt.MouseFocusReason)
} }
contentItem: StatusScrollView { contentItem: StatusScrollView {
padding: 0 padding: 0
contentWidth: 480 implicitWidth: 560
implicitHeight: contentColumn.childrenRect.height
ColumnLayout { ColumnLayout {
id: contentColumn id: contentColumn
anchors.left: parent.left width: root.availableWidth
anchors.right: parent.right
anchors.margins: Style.current.bigPadding
spacing: Style.current.padding spacing: Style.current.padding
StatusBaseText { StatusBaseText {
@ -89,7 +88,6 @@ StatusModal {
.arg(d.senderDisplayName).arg(d.senderDisplayName) .arg(d.senderDisplayName).arg(d.senderDisplayName)
font.pixelSize: 15 font.pixelSize: 15
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: Style.current.padding
} }
SimplifiedMessageView { SimplifiedMessageView {
@ -144,36 +142,38 @@ StatusModal {
} }
} }
rightButtons: [ footer: StatusDialogFooter {
StatusButton { rightButtons: ObjectModel {
visible: !d.responseText StatusButton {
text: qsTr("Refuse Verification") visible: !d.responseText
onClicked: { text: qsTr("Refuse Verification")
root.verificationRefused(d.senderPublicKey) onClicked: {
root.close(); root.verificationRefused(d.senderPublicKey)
root.close();
}
} }
}, StatusButton {
StatusButton { text: qsTr("Send Answer")
text: qsTr("Send Answer") visible: !d.responseText
visible: !d.responseText enabled: verificationResponse.text !== ""
enabled: verificationResponse.text !== "" onClicked: {
onClicked: { root.responseSent(d.senderPublicKey, Utils.escapeHtml(verificationResponse.text))
root.responseSent(d.senderPublicKey, Utils.escapeHtml(verificationResponse.text)) d.responseText = verificationResponse.text
d.responseText = verificationResponse.text d.responseTimestamp = Date.now()
d.responseTimestamp = Date.now() }
} }
}, StatusFlatButton {
StatusFlatButton { visible: d.responseText
visible: d.responseText text: qsTr("Change answer")
text: qsTr("Change answer") onClicked: {
onClicked: { d.responseText = ""
d.responseText = "" }
}
StatusButton {
visible: d.responseText
text: qsTr("Close")
onClicked: root.close()
} }
},
StatusButton {
visible: d.responseText
text: qsTr("Close")
onClicked: root.close()
} }
] }
} }

View File

@ -67,12 +67,12 @@ StatusDialog {
contentItem: StatusScrollView { contentItem: StatusScrollView {
padding: 0 padding: 0
contentWidth: 480 implicitWidth: 560
implicitHeight: layout.childrenRect.height
ColumnLayout { ColumnLayout {
anchors.left: parent.left id: layout
anchors.right: parent.right width: root.availableWidth
anchors.margins: Style.current.bigPadding
spacing: Style.current.padding spacing: Style.current.padding
SimplifiedMessageView { SimplifiedMessageView {
@ -104,7 +104,7 @@ StatusDialog {
StatusBaseText { StatusBaseText {
id: waitingForText id: waitingForText
visible: !root.verificationResponse visible: !responseMessage.visible
text: qsTr("Waiting for %1's response...").arg(root.verificationResponseDisplayName) text: qsTr("Waiting for %1's response...").arg(root.verificationResponseDisplayName)
font.pixelSize: Style.current.additionalTextSize font.pixelSize: Style.current.additionalTextSize
horizontalAlignment : Text.AlignHCenter horizontalAlignment : Text.AlignHCenter

View File

@ -68,7 +68,8 @@ Pane {
outgoingVerificationStatus !== Constants.verificationStatus.unverified && outgoingVerificationStatus !== Constants.verificationStatus.unverified &&
outgoingVerificationStatus !== Constants.verificationStatus.verified && outgoingVerificationStatus !== Constants.verificationStatus.verified &&
outgoingVerificationStatus !== Constants.verificationStatus.trusted outgoingVerificationStatus !== Constants.verificationStatus.trusted
readonly property bool isVerificationRequestReceived: incomingVerificationStatus === Constants.verificationStatus.verifying readonly property bool isVerificationRequestReceived: incomingVerificationStatus === Constants.verificationStatus.verifying ||
incomingVerificationStatus === Constants.verificationStatus.verified
readonly property bool isTrusted: outgoingVerificationStatus === Constants.verificationStatus.trusted || readonly property bool isTrusted: outgoingVerificationStatus === Constants.verificationStatus.trusted ||
incomingVerificationStatus === Constants.verificationStatus.trusted incomingVerificationStatus === Constants.verificationStatus.trusted

View File

@ -84,7 +84,8 @@ StatusMenu {
if (!root.selectedUserPublicKey || root.isMe || !root.isContact) { if (!root.selectedUserPublicKey || root.isMe || !root.isContact) {
return false return false
} }
return contactDetails.incomingVerificationStatus === Constants.verificationStatus.verifying return contactDetails.incomingVerificationStatus === Constants.verificationStatus.verifying ||
contactDetails.incomingVerificationStatus === Constants.verificationStatus.verified
} }
readonly property bool isVerificationRequestSent: { readonly property bool isVerificationRequestSent: {
if (!root.selectedUserPublicKey || root.isMe || !root.isContact) { if (!root.selectedUserPublicKey || root.isMe || !root.isContact) {

View File

@ -18,12 +18,7 @@ RowLayout {
property Component messageSubheaderComponent: null property Component messageSubheaderComponent: null
property Component messageBadgeComponent: null property Component messageBadgeComponent: null
property StatusMessageDetails messageDetails: StatusMessageDetails { property StatusMessageDetails messageDetails: StatusMessageDetails {}
sender.profileImage {
width: 40
height: 40
}
}
signal openProfilePopup() signal openProfilePopup()