Support binding 3PIDs

Closes network/neochat#565
This commit is contained in:
James Graham
2024-05-31 09:25:42 +00:00
parent ab4af48e52
commit 227ebd610a
11 changed files with 521 additions and 69 deletions

View File

@@ -38,22 +38,72 @@ ColumnLayout {
required property string address
required property string medium
contentItem: RowLayout {
QQC2.Label {
contentItem: ColumnLayout {
RowLayout {
QQC2.Label {
Layout.fillWidth: true
text: threePIdDelegate.address
textFormat: Text.PlainText
elide: Text.ElideRight
wrapMode: Text.Wrap
maximumLineCount: 2
color: Kirigami.Theme.textColor
}
QQC2.ToolButton {
visible: threePIdBindHelper.bindStatus === ThreePIdBindHelper.Ready && root.connection.hasIdentityServer
text: i18nc("@action:button", "Share")
icon.name: "send-to-symbolic"
onClicked: threePIdBindHelper.bindStatus === ThreePIdBindHelper.Verification ? threePIdBindHelper.finalizeNewIdBind() : threePIdBindHelper.initiateNewIdBind()
}
QQC2.ToolButton {
text: i18nc("@action:button", "Remove")
icon.name: "edit-delete-remove"
onClicked: threePIdAddHelper.remove3PId(threePIdDelegate.address, threePIdDelegate.medium)
}
}
Kirigami.InlineMessage {
id: errorHandler
visible: threePIdBindHelper.bindStatusString.length > 0
Layout.topMargin: visible ? Kirigami.Units.smallSpacing : 0
Layout.fillWidth: true
text: threePIdDelegate.address
textFormat: Text.PlainText
elide: Text.ElideRight
wrapMode: Text.Wrap
maximumLineCount: 2
color: Kirigami.Theme.textColor
text: threePIdBindHelper.bindStatusString
type: threePIdBindHelper.statusType
}
QQC2.ToolButton {
text: i18nc("@action:button", "Remove")
icon.name: "edit-delete-remove"
onClicked: threePIdAddHelper.remove3PId(threePIdDelegate.address, threePIdDelegate.medium)
RowLayout {
visible: threePIdBindHelper.bindStatus !== ThreePIdBindHelper.Ready
Item {
Layout.fillWidth: true
}
QQC2.ToolButton {
text: i18nc("@action:button", "Complete")
icon.name: "answer-correct"
onClicked: threePIdBindHelper.finalizeNewIdBind()
}
QQC2.ToolButton {
text: i18nc("@action:button", "Cancel")
icon.name: "edit-delete-remove"
onClicked: threePIdBindHelper.cancel()
}
}
}
ThreePIdBindHelper {
id: threePIdBindHelper
readonly property int statusType: switch(bindStatus) {
case ThreePIdBindHelper.Invalid:
case ThreePIdBindHelper.AuthFailure:
return Kirigami.MessageType.Error;
case ThreePIdBindHelper.VerificationFailure:
return Kirigami.MessageType.Warning;
default:
return Kirigami.MessageType.Information;
}
connection: root.connection
newId: threePIdDelegate.address
medium: threePIdDelegate.medium
}
}