2023-02-07 15:21:32 +01:00
|
|
|
|
import QtQuick 2.14
|
2021-09-28 18:04:06 +03:00
|
|
|
|
|
|
|
|
|
import utils 1.0
|
2021-10-28 00:27:49 +03:00
|
|
|
|
import shared.controls 1.0
|
2021-10-19 11:17:20 +02:00
|
|
|
|
|
2023-02-06 14:37:25 +01:00
|
|
|
|
import StatusQ 0.1
|
2021-10-19 11:17:20 +02:00
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
|
import StatusQ.Controls 0.1
|
2022-03-10 20:41:59 +01:00
|
|
|
|
import StatusQ.Controls.Validators 0.1
|
2021-10-19 11:17:20 +02:00
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
|
|
|
|
|
|
StatusModal {
|
2020-09-16 12:00:21 -04:00
|
|
|
|
id: popup
|
2022-07-20 12:48:44 +02:00
|
|
|
|
|
2020-09-24 14:12:50 -04:00
|
|
|
|
width: 400
|
2022-03-10 20:41:59 +01:00
|
|
|
|
height: 340
|
2022-07-20 12:48:44 +02:00
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
|
2021-10-19 11:17:20 +02:00
|
|
|
|
header.title: qsTr("Nickname")
|
2022-09-27 23:26:26 +02:00
|
|
|
|
header.subTitleElide: Text.ElideMiddle
|
|
|
|
|
|
|
|
|
|
/*required*/ property string publicKey
|
|
|
|
|
property string nickname
|
2020-09-16 12:00:21 -04:00
|
|
|
|
|
2022-07-20 12:48:44 +02:00
|
|
|
|
readonly property int nicknameLength: nicknameInput.text.length
|
2021-10-22 23:49:47 +03:00
|
|
|
|
readonly property int maxNicknameLength: 32
|
2022-07-20 12:48:44 +02:00
|
|
|
|
|
2022-03-08 12:01:57 +01:00
|
|
|
|
signal editDone(string newNickname)
|
2021-10-22 23:49:47 +03:00
|
|
|
|
|
|
|
|
|
onOpened: {
|
2022-09-27 23:26:26 +02:00
|
|
|
|
nicknameInput.input.edit.forceActiveFocus()
|
2021-10-22 23:49:47 +03:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-19 11:17:20 +02:00
|
|
|
|
contentItem: Item {
|
|
|
|
|
width: popup.width
|
|
|
|
|
height: childrenRect.height
|
2020-09-16 12:00:21 -04:00
|
|
|
|
|
2021-10-19 11:17:20 +02:00
|
|
|
|
Column {
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.topMargin: 16
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
width: parent.width - 32
|
|
|
|
|
spacing: 16
|
2021-01-12 15:51:00 -05:00
|
|
|
|
|
2021-10-19 11:17:20 +02:00
|
|
|
|
StatusBaseText {
|
|
|
|
|
id: descriptionText
|
2022-04-04 13:26:30 +02:00
|
|
|
|
text: qsTr("Nicknames help you identify others in Status. Only you can see the nicknames you’ve added")
|
2021-10-19 11:17:20 +02:00
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
|
width: parent.width
|
|
|
|
|
}
|
2020-09-16 12:00:21 -04:00
|
|
|
|
|
2022-03-10 20:41:59 +01:00
|
|
|
|
StatusInput {
|
2021-10-19 11:17:20 +02:00
|
|
|
|
id: nicknameInput
|
2022-07-22 13:28:04 +03:00
|
|
|
|
placeholderText: qsTr("Nickname")
|
2022-09-27 23:26:26 +02:00
|
|
|
|
input.clearable: true
|
2022-03-10 20:41:59 +01:00
|
|
|
|
width: parent.width
|
2022-09-27 23:26:26 +02:00
|
|
|
|
text: popup.nickname
|
2022-03-10 20:41:59 +01:00
|
|
|
|
charLimit: maxNicknameLength
|
|
|
|
|
validationMode: StatusInput.ValidationMode.IgnoreInvalidInput
|
|
|
|
|
validators: [
|
2023-02-07 15:21:32 +01:00
|
|
|
|
StatusValidator {
|
2022-12-05 13:26:06 +01:00
|
|
|
|
validatorObj: RXValidator { regularExpression: /^[\w\d_ -]*$/u }
|
2023-02-07 15:21:32 +01:00
|
|
|
|
validate: (value) => validatorObj.test(value)
|
2022-03-10 20:41:59 +01:00
|
|
|
|
}
|
|
|
|
|
]
|
2021-10-19 11:17:20 +02:00
|
|
|
|
Keys.onReleased: {
|
|
|
|
|
if (event.key === Qt.Key_Return) {
|
2022-03-10 20:41:59 +01:00
|
|
|
|
editDone(nicknameInput.text)
|
2021-10-19 11:17:20 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-01-13 04:31:26 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-09-16 12:00:21 -04:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-19 11:17:20 +02:00
|
|
|
|
rightButtons: [
|
|
|
|
|
StatusButton {
|
|
|
|
|
id: doneBtn
|
2022-04-04 13:26:30 +02:00
|
|
|
|
text: qsTr("Done")
|
2022-07-20 12:48:44 +02:00
|
|
|
|
enabled: nicknameInput.valid
|
2022-03-10 20:41:59 +01:00
|
|
|
|
onClicked: editDone(nicknameInput.text)
|
2020-09-16 12:00:21 -04:00
|
|
|
|
}
|
2021-10-19 11:17:20 +02:00
|
|
|
|
]
|
2020-09-16 12:00:21 -04:00
|
|
|
|
}
|