2020-08-19 15:29:42 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-10-14 13:47:12 +00:00
|
|
|
import "../status"
|
|
|
|
import "../panels"
|
|
|
|
import "../controls"
|
2020-08-19 15:29:42 +00:00
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
height: signingPhraseItem.height + signingPhrase.height + txtPassword.height + Style.current.smallPadding + Style.current.bigPadding
|
|
|
|
|
2020-08-20 04:45:29 +00:00
|
|
|
property alias signingPhrase: signingPhrase.text
|
|
|
|
property string enteredPassword
|
|
|
|
property alias validationError: txtPassword.validationError
|
|
|
|
//% "You need to enter a password"
|
|
|
|
property string noInputErrorMessage: qsTrId("you-need-to-enter-a-password")
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Password needs to be 6 characters or more"
|
|
|
|
property string invalidInputErrorMessage: qsTrId("password-needs-to-be-6-characters-or-more")
|
2020-08-20 04:45:29 +00:00
|
|
|
property bool isValid: false
|
|
|
|
|
|
|
|
function forceActiveFocus(reason) {
|
|
|
|
txtPassword.forceActiveFocus(reason)
|
|
|
|
}
|
|
|
|
|
|
|
|
function validate() {
|
|
|
|
txtPassword.validationError = ""
|
|
|
|
const noInput = txtPassword.text === ""
|
|
|
|
if (noInput) {
|
|
|
|
txtPassword.validationError = noInputErrorMessage
|
2020-12-03 22:26:05 +00:00
|
|
|
} else if (txtPassword.text.length < 6) {
|
2020-08-20 04:45:29 +00:00
|
|
|
txtPassword.validationError = invalidInputErrorMessage
|
|
|
|
}
|
|
|
|
isValid = txtPassword.validationError === ""
|
|
|
|
return isValid
|
|
|
|
}
|
2020-08-19 15:29:42 +00:00
|
|
|
|
|
|
|
Item {
|
|
|
|
id: signingPhraseItem
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
height: labelSigningPhrase.height
|
|
|
|
width: labelSigningPhrase.width + infoButton.width + infoButton.anchors.leftMargin
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: labelSigningPhrase
|
|
|
|
color: Style.current.secondaryText
|
|
|
|
font.pixelSize: 15
|
2020-08-26 15:52:26 +00:00
|
|
|
//% "Signing phrase"
|
|
|
|
text: qsTrId("signing-phrase")
|
2020-08-19 15:29:42 +00:00
|
|
|
}
|
|
|
|
|
2020-11-16 14:04:40 +00:00
|
|
|
StatusRoundButton {
|
2020-08-19 15:29:42 +00:00
|
|
|
id: infoButton
|
|
|
|
anchors.left: labelSigningPhrase.right
|
|
|
|
anchors.leftMargin: 7
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
width: 13
|
|
|
|
height: 13
|
2020-11-16 14:04:40 +00:00
|
|
|
icon.width: width
|
|
|
|
icon.height: height
|
|
|
|
icon.name: "info"
|
2020-08-21 11:23:47 +00:00
|
|
|
StatusToolTip {
|
|
|
|
visible: infoButton.hovered
|
2020-08-26 15:52:26 +00:00
|
|
|
//% "Signing phrase is a 3 word combination that displayed when you entered the wallet on this device for the first time."
|
|
|
|
text: qsTrId("signing-phrase-is-a-3-word-combination-that-displayed-when-you-entered-the-wallet-on-this-device-for-the-first-time-")
|
2020-08-21 11:23:47 +00:00
|
|
|
}
|
2020-08-19 15:29:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: signingPhrase
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.top: signingPhraseItem.bottom
|
|
|
|
anchors.topMargin: Style.current.smallPadding
|
|
|
|
font.pixelSize: 15
|
|
|
|
text: root.signingPhrase
|
|
|
|
}
|
|
|
|
|
2020-11-16 14:04:40 +00:00
|
|
|
StatusRoundButton {
|
2020-08-19 15:29:42 +00:00
|
|
|
id: passwordInfoButton
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 67
|
|
|
|
anchors.top: txtPassword.top
|
|
|
|
anchors.topMargin: 2
|
|
|
|
width: 13
|
|
|
|
height: 13
|
2020-11-16 14:04:40 +00:00
|
|
|
icon.width: width
|
|
|
|
icon.height: height
|
|
|
|
icon.name: "info"
|
2020-08-21 11:23:47 +00:00
|
|
|
StatusToolTip {
|
|
|
|
visible: passwordInfoButton.hovered
|
2020-08-26 15:52:26 +00:00
|
|
|
//% "Enter the password you use to unlock this device"
|
|
|
|
text: qsTrId("enter-the-password-you-use-to-unlock-this-device")
|
2020-08-21 11:23:47 +00:00
|
|
|
}
|
2020-08-19 15:29:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Input {
|
2020-08-20 04:45:29 +00:00
|
|
|
id: txtPassword
|
2020-08-19 15:29:42 +00:00
|
|
|
anchors.top: signingPhrase.bottom
|
|
|
|
anchors.topMargin: Style.current.bigPadding
|
2020-08-20 04:45:29 +00:00
|
|
|
focus: true
|
|
|
|
customHeight: 56
|
2020-08-19 15:29:42 +00:00
|
|
|
//% "Password"
|
|
|
|
label: qsTrId("password")
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Enter password"
|
2020-08-19 15:29:42 +00:00
|
|
|
placeholderText: qsTrId("enter-password")
|
|
|
|
textField.echoMode: TextInput.Password
|
2020-08-20 04:45:29 +00:00
|
|
|
validationErrorAlignment: TextEdit.AlignRight
|
|
|
|
validationErrorTopMargin: 8
|
|
|
|
onTextChanged: {
|
|
|
|
if(root.validate()) {
|
|
|
|
root.enteredPassword = this.text
|
|
|
|
}
|
|
|
|
}
|
2020-08-19 15:29:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|