2022-07-21 11:29:18 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Layouts 1.12
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Controls.Validators 0.1
|
|
|
|
|
2022-09-28 16:09:12 +00:00
|
|
|
import shared.popups.keycard.helpers 1.0
|
|
|
|
|
2022-07-21 11:29:18 +00:00
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
import "../stores"
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
property StartupStore startupStore
|
|
|
|
|
|
|
|
property int remainingAttempts: parseInt(root.startupStore.startupModuleInst.keycardData, 10)
|
|
|
|
|
|
|
|
onRemainingAttemptsChanged: {
|
|
|
|
if (root.startupStore.currentStartupState.stateType === Constants.startupState.keycardWrongPin) {
|
|
|
|
pinInputField.statesInitialization()
|
|
|
|
pinInputField.forceFocus()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onStateChanged: {
|
|
|
|
if(state === Constants.startupState.keycardPinSet) {
|
|
|
|
pinInputField.setPin("123456") // we are free to set fake pin in this case
|
|
|
|
} else {
|
|
|
|
pinInputField.statesInitialization()
|
|
|
|
pinInputField.forceFocus()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Timer {
|
|
|
|
id: timer
|
|
|
|
interval: 1000
|
|
|
|
running: root.startupStore.currentStartupState.stateType === Constants.startupState.keycardPinSet
|
|
|
|
onTriggered: {
|
|
|
|
root.startupStore.doPrimaryAction()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
anchors.centerIn: parent
|
2022-09-28 16:09:12 +00:00
|
|
|
height: Constants.keycard.general.onboardingHeight
|
2022-09-29 13:30:17 +00:00
|
|
|
spacing: Style.current.bigPadding
|
2022-07-21 11:29:18 +00:00
|
|
|
|
2022-09-28 16:09:12 +00:00
|
|
|
KeycardImage {
|
|
|
|
id: image
|
2022-07-21 11:29:18 +00:00
|
|
|
Layout.alignment: Qt.AlignHCenter
|
2022-09-28 16:09:12 +00:00
|
|
|
Layout.preferredHeight: Constants.keycard.general.imageHeight
|
|
|
|
Layout.preferredWidth: Constants.keycard.general.imageWidth
|
2022-07-21 11:29:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
id: title
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
font.weight: Font.Bold
|
|
|
|
font.pixelSize: Constants.keycard.general.fontSize1
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusPinInput {
|
|
|
|
id: pinInputField
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
validator: StatusIntValidator{bottom: 0; top: 999999;}
|
|
|
|
pinLen: Constants.keycard.general.keycardPinLength
|
|
|
|
enabled: root.startupStore.currentStartupState.stateType !== Constants.startupState.keycardPinSet
|
|
|
|
|
|
|
|
onPinInputChanged: {
|
2022-09-28 16:09:12 +00:00
|
|
|
if (root.state !== Constants.startupState.keycardWrongPin) {
|
|
|
|
image.source = Style.png("keycard/enter-pin-%1".arg(pinInput.length))
|
|
|
|
}
|
2022-07-21 11:29:18 +00:00
|
|
|
if(pinInput.length == 0)
|
|
|
|
return
|
|
|
|
if(root.state === Constants.startupState.keycardCreatePin ||
|
|
|
|
root.state === Constants.startupState.keycardEnterPin ||
|
|
|
|
root.state === Constants.startupState.keycardWrongPin) {
|
|
|
|
root.startupStore.setPin(pinInput)
|
|
|
|
root.startupStore.doPrimaryAction()
|
|
|
|
}
|
|
|
|
else if(root.state === Constants.startupState.keycardRepeatPin) {
|
|
|
|
let pinsMatch = root.startupStore.checkRepeatedKeycardPinWhileTyping(pinInput)
|
|
|
|
if (pinsMatch) {
|
2022-09-02 11:04:59 +00:00
|
|
|
info.text = qsTr("It is very important that you do not lose this PIN")
|
2022-07-21 11:29:18 +00:00
|
|
|
root.startupStore.doPrimaryAction()
|
|
|
|
} else {
|
|
|
|
info.text = qsTr("PINs don't match")
|
2022-09-28 16:09:12 +00:00
|
|
|
image.source = Style.png("keycard/plain-error")
|
2022-07-21 11:29:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
id: info
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
font.pixelSize: Constants.keycard.general.fontSize3
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
id: message
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
font.pixelSize: Constants.keycard.general.fontSize3
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
}
|
2022-09-28 16:09:12 +00:00
|
|
|
|
|
|
|
Item {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
}
|
2022-07-21 11:29:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
name: Constants.startupState.keycardCreatePin
|
|
|
|
when: root.startupStore.currentStartupState.stateType === Constants.startupState.keycardCreatePin
|
2022-09-28 16:09:12 +00:00
|
|
|
PropertyChanges {
|
|
|
|
target: image
|
|
|
|
source: Style.png("keycard/enter-pin-0")
|
|
|
|
pattern: ""
|
|
|
|
}
|
2022-07-21 11:29:18 +00:00
|
|
|
PropertyChanges {
|
|
|
|
target: title
|
|
|
|
text: qsTr("Create new Keycard PIN")
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: info
|
2022-09-02 11:04:59 +00:00
|
|
|
text: qsTr("It is very important that you do not lose this PIN")
|
2022-09-29 07:41:20 +00:00
|
|
|
color: Theme.palette.dangerColor1
|
2022-07-21 11:29:18 +00:00
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: message
|
|
|
|
text: ""
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: Constants.startupState.keycardRepeatPin
|
|
|
|
when: root.startupStore.currentStartupState.stateType === Constants.startupState.keycardRepeatPin
|
2022-09-28 16:09:12 +00:00
|
|
|
PropertyChanges {
|
|
|
|
target: image
|
|
|
|
source: Style.png("keycard/enter-pin-0")
|
|
|
|
pattern: ""
|
|
|
|
}
|
2022-07-21 11:29:18 +00:00
|
|
|
PropertyChanges {
|
|
|
|
target: title
|
|
|
|
text: qsTr("Repeat Keycard PIN")
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: info
|
2022-09-02 11:04:59 +00:00
|
|
|
text: qsTr("It is very important that you do not lose this PIN")
|
2022-07-21 11:29:18 +00:00
|
|
|
color: Theme.palette.dangerColor1
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: message
|
|
|
|
text: ""
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: Constants.startupState.keycardPinSet
|
|
|
|
when: root.startupStore.currentStartupState.stateType === Constants.startupState.keycardPinSet
|
2022-09-28 16:09:12 +00:00
|
|
|
PropertyChanges {
|
|
|
|
target: image
|
|
|
|
pattern: "keycard/strong_success/img-%1"
|
|
|
|
source: ""
|
|
|
|
startImgIndexForTheFirstLoop: 0
|
|
|
|
startImgIndexForOtherLoops: 0
|
|
|
|
endImgIndex: 20
|
|
|
|
duration: 1300
|
|
|
|
loops: 1
|
|
|
|
}
|
2022-07-21 11:29:18 +00:00
|
|
|
PropertyChanges {
|
|
|
|
target: title
|
|
|
|
text: qsTr("Keycard PIN set")
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: info
|
|
|
|
text: ""
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: message
|
|
|
|
text: ""
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: Constants.startupState.keycardEnterPin
|
|
|
|
when: root.startupStore.currentStartupState.stateType === Constants.startupState.keycardEnterPin
|
2022-09-28 16:09:12 +00:00
|
|
|
PropertyChanges {
|
|
|
|
target: image
|
|
|
|
source: Style.png("keycard/card-empty")
|
|
|
|
pattern: ""
|
|
|
|
}
|
2022-07-21 11:29:18 +00:00
|
|
|
PropertyChanges {
|
|
|
|
target: title
|
|
|
|
text: qsTr("Enter Keycard PIN")
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: info
|
|
|
|
text: ""
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: message
|
|
|
|
text: ""
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: Constants.startupState.keycardWrongPin
|
|
|
|
when: root.startupStore.currentStartupState.stateType === Constants.startupState.keycardWrongPin
|
2022-09-28 16:09:12 +00:00
|
|
|
PropertyChanges {
|
|
|
|
target: image
|
|
|
|
source: Style.png("keycard/plain-error")
|
|
|
|
pattern: ""
|
|
|
|
}
|
2022-07-21 11:29:18 +00:00
|
|
|
PropertyChanges {
|
|
|
|
target: title
|
|
|
|
text: qsTr("Enter Keycard PIN")
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: info
|
|
|
|
text: qsTr("PIN incorrect")
|
|
|
|
color: Theme.palette.dangerColor1
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: message
|
2022-08-05 13:50:54 +00:00
|
|
|
text: qsTr("%n attempt(s) remaining", "", root.remainingAttempts)
|
2022-07-21 11:29:18 +00:00
|
|
|
color: root.remainingAttempts === 1?
|
|
|
|
Theme.palette.dangerColor1 :
|
|
|
|
Theme.palette.baseColor1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|