2024-10-15 19:26:12 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
import QtQuick.Controls 2.15
|
2022-07-21 11:29:18 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2022-11-16 18:35:40 +00:00
|
|
|
property int remainingAttempts: root.startupStore.startupModuleInst.remainingAttempts
|
2022-07-21 11:29:18 +00:00
|
|
|
|
|
|
|
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
|
2023-05-09 16:23:48 +00:00
|
|
|
height: Constants.onboarding.loginHeight
|
2024-10-15 19:26:12 +00:00
|
|
|
spacing: Theme.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) {
|
2024-10-15 19:26:12 +00:00
|
|
|
image.source = Theme.png("keycard/enter-pin-%1".arg(pinInput.length))
|
2022-09-28 16:09:12 +00:00
|
|
|
}
|
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")
|
2024-10-15 19:26:12 +00:00
|
|
|
image.source = Theme.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
|
2024-10-15 19:26:12 +00:00
|
|
|
source: Theme.png("keycard/enter-pin-0")
|
2022-09-28 16:09:12 +00:00
|
|
|
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
|
2024-10-15 19:26:12 +00:00
|
|
|
source: Theme.png("keycard/enter-pin-0")
|
2022-09-28 16:09:12 +00:00
|
|
|
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
|
2022-10-18 08:31:23 +00:00
|
|
|
pattern: Constants.keycardAnimations.strongSuccess.pattern
|
2022-09-28 16:09:12 +00:00
|
|
|
source: ""
|
2022-10-18 08:31:23 +00:00
|
|
|
startImgIndexForTheFirstLoop: Constants.keycardAnimations.strongSuccess.startImgIndexForTheFirstLoop
|
|
|
|
startImgIndexForOtherLoops: Constants.keycardAnimations.strongSuccess.startImgIndexForOtherLoops
|
|
|
|
endImgIndex: Constants.keycardAnimations.strongSuccess.endImgIndex
|
|
|
|
duration: Constants.keycardAnimations.strongSuccess.duration
|
|
|
|
loops: Constants.keycardAnimations.strongSuccess.loops
|
2022-09-28 16:09:12 +00:00
|
|
|
}
|
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
|
2024-10-15 19:26:12 +00:00
|
|
|
source: Theme.png("keycard/card-empty")
|
2022-09-28 16:09:12 +00:00
|
|
|
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
|
2024-10-15 19:26:12 +00:00
|
|
|
source: Theme.png("keycard/plain-error")
|
2022-09-28 16:09:12 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|