2022-09-13 10:03:25 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Layouts 1.14
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
|
|
|
|
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
|
|
|
|
anchors.topMargin: Style.current.xlPadding
|
|
|
|
anchors.bottomMargin: Style.current.halfPadding
|
|
|
|
anchors.leftMargin: Style.current.xlPadding
|
|
|
|
anchors.rightMargin: Style.current.xlPadding
|
|
|
|
spacing: Style.current.padding
|
|
|
|
|
|
|
|
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
|
|
|
|
font.weight: Font.Bold
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
id: message
|
|
|
|
Layout.alignment: Qt.AlignCenter
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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
|
|
|
|
source: Style.png("keycard/authenticate")
|
|
|
|
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
|
|
|
|
source: Style.png("keycard/authenticate")
|
|
|
|
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
|
|
|
|
source: Style.png("keycard/biometrics-success")
|
|
|
|
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
|
|
|
|
source: Style.png("keycard/biometrics-success")
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|