2022-03-01 15:59:38 +00:00
import QtQuick 2.0
import QtQuick . Controls 2.13
import QtQuick . Layouts 1.12
import shared . controls 1.0
import shared 1.0
import shared . panels 1.0
2022-07-20 12:34:44 +00:00
import shared . stores 1.0
2022-03-01 15:59:38 +00:00
import utils 1.0
import StatusQ . Controls 0.1
import StatusQ . Core 0.1
import StatusQ . Core . Theme 0.1
import "../stores"
2022-03-07 22:59:38 +00:00
import "../controls"
2022-03-01 15:59:38 +00:00
2022-07-20 12:34:44 +00:00
Item {
2022-03-01 15:59:38 +00:00
id: root
2022-07-20 12:34:44 +00:00
property StartupStore startupStore
2022-03-01 15:59:38 +00:00
property string password
2022-07-20 12:34:44 +00:00
Component.onCompleted: {
root . password = root . startupStore . getPassword ( )
2022-07-28 14:04:37 +00:00
d . forcePasswordInputFocus ( )
2022-07-20 12:34:44 +00:00
}
2022-05-06 12:47:46 +00:00
QtObject {
id: d
function checkPasswordMatches ( ) {
if ( confPswInput . text !== root . password ) {
errorTxt . text = qsTr ( "Passwords don't match" )
return false
}
return true
}
function submit ( ) {
if ( ! checkPasswordMatches ( ) ) {
return
}
2022-07-20 12:34:44 +00:00
root . startupStore . doPrimaryAction ( )
2022-05-06 12:47:46 +00:00
}
2022-07-28 14:04:37 +00:00
function forcePasswordInputFocus ( ) { confPswInput . forceActiveFocus ( Qt . MouseFocusReason ) }
2022-05-06 12:47:46 +00:00
}
2022-10-11 13:58:34 +00:00
ColumnLayout {
2022-03-01 15:59:38 +00:00
id: view
2022-10-11 13:58:34 +00:00
spacing: Style . current . bigPadding
height: 460
2022-03-01 15:59:38 +00:00
anchors.centerIn: parent
StatusBaseText {
2022-10-11 13:58:34 +00:00
Layout.alignment: Qt . AlignHCenter
2022-03-01 15:59:38 +00:00
text: qsTr ( "Have you written down your password?" )
font.pixelSize: 22
font.bold: true
color: Theme . palette . directColor1
}
2022-10-11 13:58:34 +00:00
ColumnLayout {
Layout.alignment: Qt . AlignHCenter
spacing: 4
2022-03-01 15:59:38 +00:00
StatusBaseText {
2022-10-11 13:58:34 +00:00
Layout.alignment: Qt . AlignHCenter
2022-03-01 15:59:38 +00:00
text: qsTr ( "You will never be able to recover your password if you lose it." )
2022-05-05 09:57:39 +00:00
font.pixelSize: 15
2022-03-01 15:59:38 +00:00
color: Theme . palette . dangerColor1
}
StatusBaseText {
2022-10-11 13:58:34 +00:00
Layout.alignment: Qt . AlignHCenter
2022-03-01 15:59:38 +00:00
text: qsTr ( "If you need to, write it using pen and paper and keep in a safe place." )
2022-05-05 09:57:39 +00:00
font.pixelSize: 15
2022-03-01 15:59:38 +00:00
color: Theme . palette . baseColor1
}
StatusBaseText {
2022-10-11 13:58:34 +00:00
Layout.alignment: Qt . AlignHCenter
2022-06-20 14:22:34 +00:00
text: qsTr ( "If you lose your password you will lose access to your Status profile." )
2022-05-05 09:57:39 +00:00
font.pixelSize: 15
2022-03-01 15:59:38 +00:00
color: Theme . palette . baseColor1
}
}
2022-10-11 13:58:34 +00:00
StatusPasswordInput {
id: confPswInput
property bool showPassword: false
objectName: "confirmAgainPasswordInput"
Layout.preferredWidth: 416
Layout.alignment: Qt . AlignHCenter
enabled: ! submitBtn . loading
placeholderText: qsTr ( "Confirm your password (again)" )
echoMode: showPassword ? TextInput.Normal : TextInput . Password
validator: RegExpValidator { regExp: /^[!-~]{0,64}$/ } // That incudes NOT extended ASCII printable characters less space and a maximum of 64 characters allowed
rightPadding: showHideCurrentIcon . width + showHideCurrentIcon . anchors . rightMargin + Style . current . padding / 2
onTextChanged: { errorTxt . text = "" }
Keys.onReturnPressed: { if ( submitBtn . enabled ) d . submit ( ) }
StatusFlatRoundButton {
id: showHideCurrentIcon
visible: confPswInput . text !== ""
anchors.verticalCenter: parent . verticalCenter
anchors.right: parent . right
anchors.rightMargin: 16
width: 24
height: 24
icon.name: confPswInput . showPassword ? "hide" : "show"
icon.color: Theme . palette . baseColor1
onClicked: confPswInput . showPassword = ! confPswInput . showPassword
2022-03-01 15:59:38 +00:00
}
2022-05-09 14:14:30 +00:00
}
2022-03-01 15:59:38 +00:00
2022-10-11 13:58:34 +00:00
StatusBaseText {
id: errorTxt
Layout.alignment: Qt . AlignHCenter
Layout.fillHeight: true
Layout.topMargin: - Style . current . halfPadding
font.pixelSize: 12
color: Theme . palette . dangerColor1
2022-03-01 15:59:38 +00:00
}
StatusButton {
id: submitBtn
2022-07-20 12:14:50 +00:00
objectName: "confirmPswSubmitBtn"
2022-10-11 13:58:34 +00:00
Layout.alignment: Qt . AlignHCenter
2022-05-05 09:57:39 +00:00
text: qsTr ( "Finalise Status Password Creation" )
2022-05-09 14:14:30 +00:00
enabled: ! submitBtn . loading && ( confPswInput . text === root . password )
2022-03-01 15:59:38 +00:00
2022-05-06 12:47:46 +00:00
onClicked: { d . submit ( ) }
2022-03-07 22:59:38 +00:00
}
}
Connections {
2022-07-20 12:34:44 +00:00
target: RootStore . privacyModule
2023-01-18 09:25:36 +00:00
function onPasswordChanged ( success: bool , errorMsg: string ) {
2022-03-07 22:59:38 +00:00
if ( success ) {
submitBtn . loading = false
}
}
}
2022-03-01 15:59:38 +00:00
}