2024-10-15 19:26:12 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
import QtQuick.Controls 2.15
|
2022-09-13 10:03:25 +00:00
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Controls.Validators 0.1
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
import "../helpers"
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
property var sharedKeycardModule
|
|
|
|
|
|
|
|
property string kcData: root.sharedKeycardModule.keycardData
|
|
|
|
|
|
|
|
signal passwordValid(bool valid)
|
|
|
|
|
|
|
|
onKcDataChanged: {
|
|
|
|
d.updatePasswordValidation()
|
|
|
|
}
|
|
|
|
|
|
|
|
onStateChanged: {
|
|
|
|
password.focus = true
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: timer.start()
|
|
|
|
|
|
|
|
Timer {
|
|
|
|
id: timer
|
|
|
|
interval: 1000
|
|
|
|
onTriggered: {
|
|
|
|
password.forceActiveFocus(Qt.MouseFocusReason)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
2022-09-20 14:01:57 +00:00
|
|
|
readonly property bool wrongPassword: root.kcData & Constants.predefinedKeycardData.wrongPassword
|
|
|
|
|
2022-09-13 10:03:25 +00:00
|
|
|
function updatePasswordValidation() {
|
2022-09-20 14:01:57 +00:00
|
|
|
root.passwordValid(password.text !== "" && !d.wrongPassword)
|
2022-09-13 10:03:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
anchors.fill: parent
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.topMargin: Theme.xlPadding
|
|
|
|
anchors.bottomMargin: Theme.halfPadding
|
|
|
|
anchors.leftMargin: Theme.xlPadding
|
|
|
|
anchors.rightMargin: Theme.xlPadding
|
|
|
|
spacing: Theme.padding
|
2022-09-13 10:03:25 +00:00
|
|
|
|
|
|
|
KeycardImage {
|
|
|
|
id: image
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
Layout.preferredHeight: Constants.keycard.shared.imageHeight
|
|
|
|
Layout.preferredWidth: Constants.keycard.shared.imageWidth
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
id: title
|
|
|
|
Layout.alignment: Qt.AlignCenter
|
2023-06-05 12:02:11 +00:00
|
|
|
Layout.maximumWidth: parent.width
|
2022-09-13 10:03:25 +00:00
|
|
|
font.weight: Font.Bold
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
id: message
|
|
|
|
Layout.alignment: Qt.AlignCenter
|
2023-06-05 12:02:11 +00:00
|
|
|
Layout.maximumWidth: parent.width
|
2022-09-13 10:03:25 +00:00
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
visible: text != ""
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusPasswordInput {
|
|
|
|
id: password
|
2023-02-24 12:59:14 +00:00
|
|
|
objectName: "keycardPasswordInput"
|
2022-09-13 10:03:25 +00:00
|
|
|
Layout.alignment: Qt.AlignHCenter
|
2023-06-05 12:02:11 +00:00
|
|
|
Layout.maximumWidth: parent.width
|
2022-09-13 10:03:25 +00:00
|
|
|
signingPhrase: root.sharedKeycardModule.getSigningPhrase()
|
|
|
|
placeholderText: qsTr("Password")
|
|
|
|
selectByMouse: true
|
|
|
|
focus: true
|
|
|
|
|
|
|
|
onTextChanged: {
|
|
|
|
root.sharedKeycardModule.keycardData = ""
|
|
|
|
root.sharedKeycardModule.setPassword(text)
|
|
|
|
d.updatePasswordValidation()
|
|
|
|
}
|
|
|
|
|
|
|
|
onAccepted: {
|
|
|
|
if (password.text !== "") {
|
|
|
|
root.sharedKeycardModule.currentState.doPrimaryAction()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
id: info
|
|
|
|
Layout.alignment: Qt.AlignCenter
|
2023-06-05 12:02:11 +00:00
|
|
|
Layout.maximumWidth: parent.width
|
2022-09-13 10:03:25 +00:00
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
name: Constants.keycardSharedState.enterPassword
|
|
|
|
when: root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.enterPassword
|
|
|
|
PropertyChanges {
|
|
|
|
target: image
|
2024-10-15 19:26:12 +00:00
|
|
|
source: Theme.png("keycard/authenticate")
|
2022-09-13 10:03:25 +00:00
|
|
|
pattern: ""
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: title
|
|
|
|
text: qsTr("Enter your password")
|
|
|
|
font.pixelSize: Constants.keycard.general.fontSize1
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: message
|
|
|
|
text: ""
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: info
|
|
|
|
text: ""
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: Constants.keycardSharedState.wrongPassword
|
|
|
|
when: root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongPassword
|
|
|
|
PropertyChanges {
|
|
|
|
target: image
|
2024-10-15 19:26:12 +00:00
|
|
|
source: Theme.png("keycard/authenticate")
|
2022-09-13 10:03:25 +00:00
|
|
|
pattern: ""
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: title
|
|
|
|
text: qsTr("Enter your password")
|
|
|
|
font.pixelSize: Constants.keycard.general.fontSize1
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: message
|
|
|
|
text: ""
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: info
|
2022-09-20 14:01:57 +00:00
|
|
|
text: d.wrongPassword? qsTr("Password incorrect") : ""
|
2022-09-13 10:03:25 +00:00
|
|
|
color: Theme.palette.dangerColor1
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: Constants.keycardSharedState.enterBiometricsPassword
|
|
|
|
when: root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.enterBiometricsPassword
|
|
|
|
PropertyChanges {
|
|
|
|
target: image
|
2024-10-15 19:26:12 +00:00
|
|
|
source: Theme.png("keycard/biometrics-success")
|
2022-09-13 10:03:25 +00:00
|
|
|
pattern: ""
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: title
|
2023-04-03 13:29:14 +00:00
|
|
|
text: qsTr("Stored password doesn't match")
|
2022-09-13 10:03:25 +00:00
|
|
|
font.pixelSize: Constants.keycard.general.fontSize1
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: message
|
|
|
|
text: qsTr("Enter your new password to proceed")
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: info
|
2022-09-20 14:01:57 +00:00
|
|
|
text: d.wrongPassword? qsTr("Password incorrect") : ""
|
2022-09-13 10:03:25 +00:00
|
|
|
color: Theme.palette.dangerColor1
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: Constants.keycardSharedState.wrongBiometricsPassword
|
|
|
|
when: root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongBiometricsPassword
|
|
|
|
PropertyChanges {
|
|
|
|
target: image
|
2024-10-15 19:26:12 +00:00
|
|
|
source: Theme.png("keycard/biometrics-success")
|
2022-09-13 10:03:25 +00:00
|
|
|
pattern: ""
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: title
|
2023-04-03 13:29:14 +00:00
|
|
|
text: qsTr("Stored password doesn't match")
|
2022-09-13 10:03:25 +00:00
|
|
|
font.pixelSize: Constants.keycard.general.fontSize1
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: message
|
|
|
|
text: qsTr("Enter your new password to proceed")
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: info
|
2022-09-20 14:01:57 +00:00
|
|
|
text: d.wrongPassword? qsTr("Password incorrect") : ""
|
2022-09-13 10:03:25 +00:00
|
|
|
color: Theme.palette.dangerColor1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|