card connection prompt

This commit is contained in:
Michele Balistreri 2021-09-27 12:07:20 +03:00 committed by Iuri Matias
parent 2a027d44d0
commit 303e40bdcf
3 changed files with 25 additions and 4 deletions

View File

@ -1,6 +1,9 @@
import NimQml
import NimQml, chronicles
import status/status
logScope:
topics = "keycard-model"
QtObject:
type KeycardView* = ref object of QObject
status*: Status
@ -19,3 +22,6 @@ QtObject:
proc cardConnected*(self: KeycardView) {.signal.}
proc cardDisconnected*(self: KeycardView) {.signal.}
proc simulateDisconnected*(self: KeycardView) {.slot.} =
self.cardDisconnected()

View File

@ -38,4 +38,18 @@ Item {
keycardView.onClosed()
}
}
Connections {
id: connection
target: keycardModel
ignoreUnknownSignals: true
onCardConnected: {
insertCard.close()
}
onCardDisconnected: {
insertCard.open()
}
}
}

View File

@ -4,6 +4,7 @@ import QtQuick.Dialogs 1.3
import StatusQ.Controls 0.1
import "../../imports"
import "../../shared"
import "../../shared/keycard"
ModalPopup {
property bool firstPINFieldValid: false
@ -27,7 +28,7 @@ ModalPopup {
anchors.top: parent.top
anchors.topMargin: 88
placeholderText: qsTr("New PIN")
textField.echoMode: TextInput.PIN
textField.echoMode: TextInput.Password
onTextChanged: {
[firstPINFieldValid, pinValidationError] =
Utils.validatePINs("first", firstPINField, repeatPINField);
@ -44,7 +45,7 @@ ModalPopup {
anchors.top: firstPINField.bottom
anchors.topMargin: Style.current.xlPadding
placeholderText: qsTr("Confirm PIN")
textField.echoMode: TextInput.PIN
textField.echoMode: TextInput.Password
Keys.onReturnPressed: function(event) {
if (submitBtn.enabled) {
submitBtn.clicked(event)
@ -101,7 +102,7 @@ ModalPopup {
enabled: firstPINFieldValid && repeatPINFieldValid
onClicked: {
keycardModel.simulateDisconnected()
}
}
}