2020-06-17 15:18:31 -04:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
2020-06-12 16:47:44 -04:00
|
|
|
import QtQuick.Dialogs 1.3
|
2021-07-23 12:22:14 +03:00
|
|
|
import StatusQ.Controls 0.1
|
2020-06-12 16:47:44 -04:00
|
|
|
import "../imports"
|
|
|
|
import "../shared"
|
|
|
|
|
|
|
|
ModalPopup {
|
|
|
|
property bool loading: false
|
2020-12-04 00:26:05 +02:00
|
|
|
property bool firstPasswordFieldValid: false
|
|
|
|
property bool repeatPasswordFieldValid: false
|
2020-06-23 15:31:35 -04:00
|
|
|
property string passwordValidationError: ""
|
|
|
|
property string repeatPasswordValidationError: ""
|
|
|
|
|
2020-06-12 16:47:44 -04:00
|
|
|
id: popup
|
2020-07-06 16:39:55 -04:00
|
|
|
//% "Create a password"
|
|
|
|
title: qsTrId("intro-wizard-title-alt4")
|
2020-06-12 16:47:44 -04:00
|
|
|
height: 500
|
|
|
|
|
|
|
|
onOpened: {
|
|
|
|
firstPasswordField.text = "";
|
|
|
|
firstPasswordField.forceActiveFocus(Qt.MouseFocusReason)
|
|
|
|
}
|
2020-06-30 16:01:37 -04:00
|
|
|
|
2020-06-12 16:47:44 -04:00
|
|
|
Input {
|
|
|
|
id: firstPasswordField
|
|
|
|
anchors.rightMargin: 56
|
|
|
|
anchors.leftMargin: 56
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: 88
|
2020-07-06 16:39:55 -04:00
|
|
|
//% "New password..."
|
|
|
|
placeholderText: qsTrId("new-password...")
|
2020-06-12 16:47:44 -04:00
|
|
|
textField.echoMode: TextInput.Password
|
2020-12-04 00:26:05 +02:00
|
|
|
onTextChanged: {
|
|
|
|
[firstPasswordFieldValid, passwordValidationError] =
|
2020-12-04 16:53:00 +02:00
|
|
|
Utils.validatePasswords("first", firstPasswordField, repeatPasswordField);
|
2020-12-04 00:26:05 +02:00
|
|
|
}
|
2020-06-12 16:47:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Input {
|
|
|
|
id: repeatPasswordField
|
2020-12-04 00:26:05 +02:00
|
|
|
enabled: firstPasswordFieldValid
|
2020-06-12 16:47:44 -04:00
|
|
|
anchors.rightMargin: 0
|
|
|
|
anchors.leftMargin: 0
|
|
|
|
anchors.right: firstPasswordField.right
|
|
|
|
anchors.left: firstPasswordField.left
|
|
|
|
anchors.top: firstPasswordField.bottom
|
2020-07-02 11:14:31 -04:00
|
|
|
anchors.topMargin: Style.current.xlPadding
|
2020-07-06 16:39:55 -04:00
|
|
|
//% "Confirm password…"
|
|
|
|
placeholderText: qsTrId("confirm-password…")
|
2020-06-12 16:47:44 -04:00
|
|
|
textField.echoMode: TextInput.Password
|
2021-07-26 10:11:01 +02:00
|
|
|
Keys.onReturnPressed: function(event) {
|
|
|
|
submitBtn.clicked(event)
|
2020-06-12 16:47:44 -04:00
|
|
|
}
|
2020-12-04 00:26:05 +02:00
|
|
|
onTextChanged: {
|
|
|
|
[repeatPasswordFieldValid, repeatPasswordValidationError] =
|
2020-12-04 16:53:00 +02:00
|
|
|
Utils.validatePasswords("repeat", firstPasswordField, repeatPasswordField);
|
2020-12-04 00:26:05 +02:00
|
|
|
}
|
2020-06-12 16:47:44 -04:00
|
|
|
}
|
|
|
|
|
2020-12-05 23:00:28 +02:00
|
|
|
StyledText {
|
|
|
|
id: validationError
|
|
|
|
text: {
|
|
|
|
if (passwordValidationError !== "") return passwordValidationError;
|
|
|
|
if (repeatPasswordValidationError !== "") return repeatPasswordValidationError;
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
anchors.top: repeatPasswordField.bottom
|
|
|
|
anchors.topMargin: 20
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: Style.current.xlPadding
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: Style.current.xlPadding
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
color: Style.current.danger
|
|
|
|
font.pixelSize: 11
|
|
|
|
}
|
|
|
|
|
2020-06-19 14:06:58 -04:00
|
|
|
StyledText {
|
2020-07-06 16:39:55 -04:00
|
|
|
//% "At least 6 characters. You will use this password to unlock status on this device & sign transactions."
|
2020-07-07 15:25:20 -04:00
|
|
|
text: qsTrId("at-least-6-characters-you-will-use-this-password-to-unlock-status-on-this-device-sign-transactions.")
|
2020-06-12 16:47:44 -04:00
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
anchors.right: parent.right
|
2020-07-02 11:14:31 -04:00
|
|
|
anchors.rightMargin: Style.current.xlPadding
|
2020-06-12 16:47:44 -04:00
|
|
|
anchors.left: parent.left
|
2020-07-02 11:14:31 -04:00
|
|
|
anchors.leftMargin: Style.current.xlPadding
|
2020-06-12 16:47:44 -04:00
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.bottomMargin: 0
|
2020-09-29 16:39:29 +10:00
|
|
|
color: Style.current.secondaryText
|
2020-06-12 16:47:44 -04:00
|
|
|
font.pixelSize: 12
|
|
|
|
}
|
|
|
|
|
2020-06-22 15:32:00 -04:00
|
|
|
footer: Item {
|
2021-01-13 14:15:52 -05:00
|
|
|
width: parent.width
|
|
|
|
height: submitBtn.height
|
2020-06-12 16:47:44 -04:00
|
|
|
|
2020-09-29 16:39:29 +10:00
|
|
|
StatusButton {
|
2020-06-22 15:32:00 -04:00
|
|
|
id: submitBtn
|
|
|
|
anchors.bottom: parent.bottom
|
2020-07-02 11:14:31 -04:00
|
|
|
anchors.topMargin: Style.current.padding
|
2020-06-22 15:32:00 -04:00
|
|
|
anchors.right: parent.right
|
2020-10-26 10:23:36 -04:00
|
|
|
state: loading ? "pending" : "default"
|
2020-07-06 16:39:55 -04:00
|
|
|
//% "Create password"
|
2020-10-26 10:23:36 -04:00
|
|
|
text: qsTrId("create-password")
|
2020-06-12 16:47:44 -04:00
|
|
|
|
2020-12-04 00:26:05 +02:00
|
|
|
enabled: firstPasswordFieldValid && repeatPasswordFieldValid && !loading
|
2020-06-22 15:32:00 -04:00
|
|
|
|
|
|
|
MessageDialog {
|
|
|
|
id: importError
|
2020-07-06 16:39:55 -04:00
|
|
|
//% "Error importing account"
|
|
|
|
title: qsTrId("error-importing-account")
|
|
|
|
//% "An error occurred while importing your account: "
|
|
|
|
text: qsTrId("an-error-occurred-while-importing-your-account:-")
|
2020-06-22 15:32:00 -04:00
|
|
|
icon: StandardIcon.Critical
|
|
|
|
standardButtons: StandardButton.Ok
|
|
|
|
onVisibilityChanged: {
|
|
|
|
loading = false
|
|
|
|
}
|
2020-06-12 16:47:44 -04:00
|
|
|
}
|
|
|
|
|
2020-06-22 15:32:00 -04:00
|
|
|
MessageDialog {
|
|
|
|
id: importLoginError
|
2020-07-06 16:39:55 -04:00
|
|
|
//% "Login failed"
|
|
|
|
title: qsTrId("login-failed")
|
|
|
|
//% "Login failed. Please re-enter your password and try again."
|
|
|
|
text: qsTrId("login-failed.-please-re-enter-your-password-and-try-again.")
|
2020-06-22 15:32:00 -04:00
|
|
|
icon: StandardIcon.Critical
|
|
|
|
standardButtons: StandardButton.Ok
|
|
|
|
onVisibilityChanged: {
|
2020-06-12 16:47:44 -04:00
|
|
|
loading = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-22 15:32:00 -04:00
|
|
|
Connections {
|
|
|
|
target: onboardingModel
|
|
|
|
ignoreUnknownSignals: true
|
|
|
|
onLoginResponseChanged: {
|
|
|
|
if (error) {
|
|
|
|
loading = false
|
|
|
|
importLoginError.open()
|
|
|
|
}
|
|
|
|
}
|
2020-06-12 16:47:44 -04:00
|
|
|
}
|
2020-06-22 15:32:00 -04:00
|
|
|
|
2020-06-23 15:31:35 -04:00
|
|
|
onClicked: {
|
2020-06-22 15:32:00 -04:00
|
|
|
loading = true
|
2020-06-29 15:49:34 -04:00
|
|
|
loginModel.isCurrentFlow = false;
|
|
|
|
onboardingModel.isCurrentFlow = true;
|
2020-06-22 15:32:00 -04:00
|
|
|
const result = onboardingModel.storeDerivedAndLogin(repeatPasswordField.text);
|
|
|
|
const error = JSON.parse(result).error
|
|
|
|
if (error) {
|
|
|
|
importError.text += error
|
|
|
|
return importError.open()
|
|
|
|
}
|
2021-04-20 14:52:09 -04:00
|
|
|
onboardingModel.firstTimeLogin = true
|
2020-06-12 16:47:44 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*##^##
|
|
|
|
Designer {
|
|
|
|
D{i:0;formeditorColor:"#ffffff";height:500;width:400}
|
|
|
|
}
|
|
|
|
##^##*/
|