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
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
|
|
import utils 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
|
import shared.controls 1.0
|
2021-10-19 09:17:20 +00:00
|
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
|
import StatusQ.Controls 0.1
|
2022-03-10 19:41:59 +00:00
|
|
|
|
import StatusQ.Controls.Validators 0.1
|
2021-10-19 09:17:20 +00:00
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
|
|
|
|
|
|
StatusModal {
|
|
|
|
|
anchors.centerIn: parent
|
2020-09-16 16:00:21 +00:00
|
|
|
|
|
|
|
|
|
id: popup
|
2020-09-24 18:12:50 +00:00
|
|
|
|
width: 400
|
2022-03-10 19:41:59 +00:00
|
|
|
|
height: 340
|
2021-10-19 09:17:20 +00:00
|
|
|
|
header.title: qsTr("Nickname")
|
2020-09-16 16:00:21 +00:00
|
|
|
|
|
2022-01-05 15:50:03 +00:00
|
|
|
|
property string nickname: ""
|
2022-03-10 19:41:59 +00:00
|
|
|
|
property int nicknameLength: nicknameInput.text.length
|
2021-10-22 20:49:47 +00:00
|
|
|
|
readonly property int maxNicknameLength: 32
|
|
|
|
|
property bool nicknameTooLong: nicknameLength > maxNicknameLength
|
2022-03-08 11:01:57 +00:00
|
|
|
|
signal editDone(string newNickname)
|
2021-10-22 20:49:47 +00:00
|
|
|
|
|
|
|
|
|
onOpened: {
|
|
|
|
|
nicknameInput.forceActiveFocus(Qt.MouseFocusReason);
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-19 09:17:20 +00:00
|
|
|
|
contentItem: Item {
|
|
|
|
|
width: popup.width
|
|
|
|
|
height: childrenRect.height
|
2020-09-16 16:00:21 +00:00
|
|
|
|
|
2021-10-19 09:17:20 +00:00
|
|
|
|
Column {
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.topMargin: 16
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
width: parent.width - 32
|
|
|
|
|
spacing: 16
|
2021-01-12 20:51:00 +00:00
|
|
|
|
|
2021-10-19 09:17:20 +00:00
|
|
|
|
StatusBaseText {
|
|
|
|
|
id: descriptionText
|
|
|
|
|
//% "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")
|
|
|
|
|
font.pixelSize: 15
|
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
|
width: parent.width
|
|
|
|
|
}
|
2020-09-16 16:00:21 +00:00
|
|
|
|
|
2022-03-10 19:41:59 +00:00
|
|
|
|
StatusInput {
|
2021-10-19 09:17:20 +00:00
|
|
|
|
id: nicknameInput
|
|
|
|
|
//% "Nickname"
|
2022-03-10 19:41:59 +00:00
|
|
|
|
input.placeholderText: qsTrId("nickname")
|
2021-10-19 09:17:20 +00:00
|
|
|
|
text: nickname
|
2022-03-10 19:41:59 +00:00
|
|
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
|
|
charLimit: maxNicknameLength
|
|
|
|
|
validationMode: StatusInput.ValidationMode.IgnoreInvalidInput
|
|
|
|
|
validators: [
|
|
|
|
|
StatusRegularExpressionValidator {
|
|
|
|
|
regularExpression: /^[0-9A-Za-z_-]*$/
|
|
|
|
|
}
|
|
|
|
|
]
|
2021-10-19 09:17:20 +00:00
|
|
|
|
Keys.onReleased: {
|
|
|
|
|
if (event.key === Qt.Key_Return) {
|
2022-03-10 19:41:59 +00:00
|
|
|
|
editDone(nicknameInput.text)
|
2021-10-19 09:17:20 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-01-13 00:31:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-09-16 16:00:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-19 09:17:20 +00:00
|
|
|
|
rightButtons: [
|
|
|
|
|
StatusButton {
|
|
|
|
|
id: doneBtn
|
|
|
|
|
//% "Done"
|
|
|
|
|
text: qsTrId("done")
|
|
|
|
|
enabled: !popup.nicknameTooLong
|
2022-03-10 19:41:59 +00:00
|
|
|
|
onClicked: editDone(nicknameInput.text)
|
2020-09-16 16:00:21 +00:00
|
|
|
|
}
|
2021-10-19 09:17:20 +00:00
|
|
|
|
]
|
2020-09-16 16:00:21 +00:00
|
|
|
|
}
|