2023-08-01 12:32:03 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
import QtQml.Models 2.15
|
2022-06-20 11:54:17 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Controls.Validators 0.1
|
2023-08-01 12:32:03 +00:00
|
|
|
import StatusQ.Popups.Dialog 0.1
|
2022-06-20 11:54:17 +00:00
|
|
|
|
2024-05-22 08:13:39 +00:00
|
|
|
import AppLayouts.stores 1.0 as AppLayoutStores
|
|
|
|
|
2024-02-16 11:56:29 +00:00
|
|
|
CommonContactDialog {
|
2022-06-20 11:54:17 +00:00
|
|
|
id: root
|
|
|
|
|
2024-05-22 08:13:39 +00:00
|
|
|
property AppLayoutStores.RootStore rootStore
|
2023-04-06 07:56:50 +00:00
|
|
|
|
2024-02-16 11:56:29 +00:00
|
|
|
property string labelText: qsTr("Why should they accept your contact request?")
|
|
|
|
property string challengeText: qsTr("Write a short message telling them who you are...")
|
|
|
|
property string buttonText: qsTr("Send contact request")
|
2022-09-27 21:26:26 +00:00
|
|
|
|
2022-06-20 11:54:17 +00:00
|
|
|
signal accepted(string message)
|
|
|
|
|
2024-02-26 18:54:05 +00:00
|
|
|
title: qsTr("Send contact request")
|
2023-04-06 07:56:50 +00:00
|
|
|
|
|
|
|
onAboutToShow: {
|
|
|
|
messageInput.input.edit.forceActiveFocus()
|
|
|
|
|
2023-08-01 12:32:03 +00:00
|
|
|
// (request) update from mailserver
|
2024-11-19 10:44:28 +00:00
|
|
|
if (root.contactDetails.displayName === "") {
|
2024-02-16 11:56:29 +00:00
|
|
|
root.rootStore.contactStore.requestContactInfo(root.publicKey)
|
2024-02-26 18:54:05 +00:00
|
|
|
root.loadingContactDetails = true
|
2023-07-27 11:21:25 +00:00
|
|
|
}
|
2023-04-06 07:56:50 +00:00
|
|
|
}
|
2022-06-20 11:54:17 +00:00
|
|
|
|
2024-02-16 11:56:29 +00:00
|
|
|
readonly property var d: QtObject {
|
2022-06-20 11:54:17 +00:00
|
|
|
id: d
|
|
|
|
|
|
|
|
readonly property int maxMsgLength: 280
|
|
|
|
readonly property int minMsgLength: 1
|
|
|
|
readonly property int msgHeight: 152
|
|
|
|
}
|
|
|
|
|
2024-02-16 11:56:29 +00:00
|
|
|
readonly property var _conn: Connections {
|
2023-04-06 07:56:50 +00:00
|
|
|
target: root.rootStore.contactStore.contactsModule
|
|
|
|
|
|
|
|
function onContactInfoRequestFinished(publicKey, ok) {
|
2024-02-16 11:56:29 +00:00
|
|
|
if (publicKey !== root.publicKey)
|
2023-10-26 13:58:05 +00:00
|
|
|
return
|
|
|
|
if (ok)
|
2024-02-26 18:54:05 +00:00
|
|
|
root.contactDetails = Utils.getContactDetailsAsJson(root.publicKey, false)
|
|
|
|
root.loadingContactDetails = false
|
2023-04-06 07:56:50 +00:00
|
|
|
}
|
2022-09-27 21:26:26 +00:00
|
|
|
}
|
|
|
|
|
2024-02-16 11:56:29 +00:00
|
|
|
StatusInput {
|
|
|
|
id: messageInput
|
|
|
|
input.edit.objectName: "ProfileSendContactRequestModal_sayWhoYouAreInput"
|
|
|
|
Layout.fillWidth: true
|
|
|
|
label: root.labelText
|
|
|
|
charLimit: d.maxMsgLength
|
|
|
|
placeholderText: root.challengeText
|
|
|
|
input.multiline: true
|
|
|
|
minimumHeight: d.msgHeight
|
|
|
|
maximumHeight: d.msgHeight
|
|
|
|
input.verticalAlignment: TextEdit.AlignTop
|
|
|
|
validators: StatusMinLengthValidator {
|
|
|
|
minLength: d.minMsgLength
|
|
|
|
errorMessage: Utils.getErrorMessage(messageInput.errors, qsTr("who are you"))
|
2022-06-20 11:54:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-16 11:56:29 +00:00
|
|
|
rightButtons: ObjectModel {
|
|
|
|
StatusFlatButton {
|
|
|
|
text: qsTr("Cancel")
|
|
|
|
onClicked: root.close()
|
|
|
|
}
|
|
|
|
StatusButton {
|
|
|
|
objectName: "ProfileSendContactRequestModal_sendContactRequestButton"
|
|
|
|
enabled: messageInput.valid
|
|
|
|
text: root.buttonText
|
|
|
|
onClicked: {
|
|
|
|
root.accepted(messageInput.text);
|
|
|
|
root.close();
|
2023-08-01 12:32:03 +00:00
|
|
|
}
|
2022-06-20 11:54:17 +00:00
|
|
|
}
|
|
|
|
}
|
2022-06-22 12:16:21 +00:00
|
|
|
}
|