2020-09-16 16:00:21 +00:00
|
|
|
|
import QtQuick 2.13
|
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
|
import QtQuick.Layouts 1.13
|
|
|
|
|
import QtGraphicalEffects 1.13
|
|
|
|
|
import "../../../../imports"
|
|
|
|
|
import "../../../../shared"
|
2021-01-28 11:04:10 +00:00
|
|
|
|
import "../../../../shared/status"
|
2020-09-16 16:00:21 +00:00
|
|
|
|
import "./"
|
|
|
|
|
|
|
|
|
|
ModalPopup {
|
|
|
|
|
property int nicknameLength: nicknameInput.textField.text.length
|
|
|
|
|
readonly property int maxNicknameLength: 32
|
|
|
|
|
property bool nicknameTooLong: nicknameLength > maxNicknameLength
|
2020-09-28 14:31:00 +00:00
|
|
|
|
property var changeUsername: function () {}
|
|
|
|
|
property var changeNickname: function () {}
|
2020-09-16 16:00:21 +00:00
|
|
|
|
|
|
|
|
|
id: popup
|
2020-09-24 18:12:50 +00:00
|
|
|
|
width: 400
|
|
|
|
|
height: 390
|
|
|
|
|
|
2021-01-12 20:51:00 +00:00
|
|
|
|
noTopMargin: true
|
|
|
|
|
|
2020-09-24 18:12:50 +00:00
|
|
|
|
onOpened: {
|
|
|
|
|
nicknameInput.forceActiveFocus(Qt.MouseFocusReason)
|
|
|
|
|
}
|
2020-09-16 16:00:21 +00:00
|
|
|
|
|
|
|
|
|
header: Item {
|
2021-01-12 20:51:00 +00:00
|
|
|
|
height: 78
|
2020-09-16 16:00:21 +00:00
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
|
id: nicknameTitle
|
2020-09-22 07:53:03 +00:00
|
|
|
|
//% "Nickname"
|
|
|
|
|
text: qsTrId("nickname")
|
2020-09-16 16:00:21 +00:00
|
|
|
|
anchors.top: parent.top
|
2021-01-12 20:51:00 +00:00
|
|
|
|
anchors.topMargin: Style.current.padding
|
2020-09-16 16:00:21 +00:00
|
|
|
|
anchors.left: parent.left
|
2021-01-12 20:51:00 +00:00
|
|
|
|
anchors.leftMargin: Style.current.padding
|
2020-09-16 16:00:21 +00:00
|
|
|
|
font.bold: true
|
2021-01-12 20:51:00 +00:00
|
|
|
|
font.pixelSize: 17
|
2020-09-16 16:00:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
|
text: isEnsVerified ? alias : fromAuthor
|
|
|
|
|
width: 160
|
|
|
|
|
elide: !isEnsVerified ? Text.ElideMiddle : Text.ElideNone
|
|
|
|
|
anchors.left: nicknameTitle.left
|
2021-01-12 20:51:00 +00:00
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
anchors.bottomMargin: Style.current.padding
|
|
|
|
|
font.pixelSize: 15
|
2020-09-16 16:00:21 +00:00
|
|
|
|
color: Style.current.secondaryText
|
|
|
|
|
}
|
2021-01-12 20:51:00 +00:00
|
|
|
|
|
|
|
|
|
Separator {
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.leftMargin: -Style.current.padding
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.rightMargin: -Style.current.padding
|
|
|
|
|
}
|
2020-09-16 16:00:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
|
id: descriptionText
|
2020-09-22 07:53:03 +00:00
|
|
|
|
//% "Nicknames help you identify others in Status. Only you can see the nicknames you’ve added"
|
|
|
|
|
text: qsTrId("nicknames-help-you-identify-others-in-status--only-you-can-see-the-nicknames-you-ve-added")
|
2020-09-16 16:00:21 +00:00
|
|
|
|
font.pixelSize: 15
|
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
|
color: Style.current.secondaryText
|
|
|
|
|
width: parent.width
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Input {
|
|
|
|
|
id: nicknameInput
|
2020-09-22 07:53:03 +00:00
|
|
|
|
//% "Nickname"
|
|
|
|
|
placeholderText: qsTrId("nickname")
|
2020-09-16 18:50:40 +00:00
|
|
|
|
text: nickname
|
2020-09-16 16:00:21 +00:00
|
|
|
|
anchors.top: descriptionText.bottom
|
|
|
|
|
anchors.topMargin: Style.current.padding
|
2020-09-22 07:53:03 +00:00
|
|
|
|
//% "Your nickname is too long"
|
|
|
|
|
validationError: popup.nicknameTooLong ? qsTrId("your-nickname-is-too-long") : ""
|
2021-01-13 00:31:26 +00:00
|
|
|
|
Keys.onReleased: {
|
|
|
|
|
if (event.key === Qt.Key_Return) {
|
|
|
|
|
doneBtn.onClicked();
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-09-16 16:00:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
|
id: lengthLimitText
|
|
|
|
|
text: popup.nicknameLength + "/" + popup.maxNicknameLength
|
|
|
|
|
font.pixelSize: 15
|
|
|
|
|
anchors.top: nicknameInput.bottom
|
|
|
|
|
anchors.topMargin: 12
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
color: popup.nicknameTooLong ? Style.current.danger : Style.current.secondaryText
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-28 11:04:10 +00:00
|
|
|
|
footer: StatusButton {
|
2020-09-16 16:00:21 +00:00
|
|
|
|
id: doneBtn
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.rightMargin: Style.current.smallPadding
|
2020-09-22 07:53:03 +00:00
|
|
|
|
//% "Done"
|
2021-01-28 11:04:10 +00:00
|
|
|
|
text: qsTrId("done")
|
2020-09-16 16:00:21 +00:00
|
|
|
|
anchors.bottom: parent.bottom
|
2021-01-28 11:04:10 +00:00
|
|
|
|
enabled: !popup.nicknameTooLong
|
2020-09-16 16:00:21 +00:00
|
|
|
|
onClicked: {
|
2020-09-24 18:12:50 +00:00
|
|
|
|
if (!isEnsVerified) {
|
|
|
|
|
// Change username title only if it was not an ENS name
|
|
|
|
|
if (nicknameInput.textField.text === "") {
|
|
|
|
|
// If we removed the nickname, go back to showing the alias
|
2020-09-28 14:31:00 +00:00
|
|
|
|
popup.changeUsername(alias)
|
2020-09-24 18:12:50 +00:00
|
|
|
|
} else {
|
2020-09-28 14:31:00 +00:00
|
|
|
|
popup.changeUsername(nicknameInput.textField.text)
|
2020-09-24 18:12:50 +00:00
|
|
|
|
}
|
2020-09-17 19:39:02 +00:00
|
|
|
|
}
|
2020-09-28 14:31:00 +00:00
|
|
|
|
popup.changeNickname(nicknameInput.textField.text)
|
2020-12-06 22:15:51 +00:00
|
|
|
|
profileModel.contacts.changeContactNickname(fromAuthor, nicknameInput.textField.text)
|
2020-09-16 18:50:40 +00:00
|
|
|
|
popup.close()
|
2021-08-30 16:09:33 +00:00
|
|
|
|
if (!!chatsModel.communities.activeCommunity) {
|
|
|
|
|
chatsModel.communities.activeCommunity.triggerMembersUpdate()
|
|
|
|
|
}
|
2020-09-16 16:00:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|