Skip to content
Snippets Groups Projects

Add PIN confirmation (issue #21)

Merged Martin Straka requested to merge pin-update into develop
Compare and
1 file
+ 123
78
Preferences
Compare changes
+ 123
78
@@ -46,82 +46,105 @@ Component {
color: datovkaPalette.text
text: qsTr("PIN settings")
}
Column {
spacing: formItemVerticalSpacing
Text {
id: pinLabel
color: datovkaPalette.mid
width: myWidht
text: ""
wrapMode: Text.Wrap
}
Button {
id: setPinCodeButton
text: qsTr("Set PIN")
onClicked: {
actionName = "new"
actionButton.visible = true
setPinCodeButton.visible = false
pinLabel.text = qsTr("Enter a new PIN code:")
setPinCodeString.visible = true
setPinCodeString.focus = true
getPinCodeString.visible = false
}
}
Button {
id: changePinCodeButton
text: qsTr("Change PIN")
onClicked: {
actionName = "change"
actionButton.visible = true
changePinCodeButton.visible = false
disablePinCodeButton.visible = false
pinLabel.text = qsTr("In order to change the PIN code you must enter the current and a new PIN code:")
getPinCodeString.visible = true
getPinCodeString.focus = true
setPinCodeString.visible = true
}
}
Button {
id: disablePinCodeButton
text: qsTr("Disable PIN")
onClicked: {
actionName = "disable"
actionButton.visible = true
disablePinCodeButton.visible = false
changePinCodeButton.visible = false
pinLabel.text = qsTr("In order to deactivate the PIN code you must enter the current PIN code:")
getPinCodeString.visible = true
getPinCodeString.focus = true
}
Text {
id: pinLabel
anchors.horizontalCenter: parent.horizontalCenter
color: datovkaPalette.mid
width: myWidht
text: ""
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.Wrap
}
Button {
id: setPinCodeButton
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Set PIN")
onClicked: {
actionName = "new"
actionButton.visible = true
setPinCodeButton.visible = false
pinLabel.text = qsTr("Enter a new PIN code into both text fields:")
setPinCodeString.visible = true
setPinCodeString2.visible = true
setPinCodeString.focus = true
getPinCodeString.visible = false
}
TextField {
id: getPinCodeString
visible: false
width: myWidht
echoMode: TextInput.Password
passwordMaskDelay: 500 // milliseconds
inputMethodHints: Qt.ImhDigitsOnly
placeholderText: qsTr("Current PIN code")
text: ""
}
Button {
id: changePinCodeButton
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Change PIN")
onClicked: {
actionName = "change"
actionButton.visible = true
changePinCodeButton.visible = false
disablePinCodeButton.visible = false
pinLabel.text = qsTr("In order to change the PIN code you must enter the current and a new PIN code:")
getPinCodeString.visible = true
getPinCodeString.focus = true
setPinCodeString.visible = true
setPinCodeString2.visible = true
}
TextField {
id: setPinCodeString
visible: false
width: myWidht
echoMode: TextInput.Password
passwordMaskDelay: 500 // milliseconds
inputMethodHints: Qt.ImhDigitsOnly
placeholderText: qsTr("New PIN code")
text: ""
}
Button {
id: disablePinCodeButton
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Disable PIN")
onClicked: {
actionName = "disable"
actionButton.visible = true
disablePinCodeButton.visible = false
changePinCodeButton.visible = false
pinLabel.text = qsTr("In order to deactivate the PIN code you must enter the current PIN code:")
setPinCodeString.visible = false
setPinCodeString2.visible = false
getPinCodeString.visible = true
getPinCodeString.focus = true
}
Text {
id: errorLabel
visible: false
anchors.horizontalCenter: parent.horizontalCenter
font.bold: true
color: datovkaPalette.text
text: "" }
}
TextField {
id: getPinCodeString
anchors.horizontalCenter: parent.horizontalCenter
visible: false
width: myWidht * 0.5
echoMode: TextInput.Password
passwordMaskDelay: 500 // milliseconds
inputMethodHints: Qt.ImhDigitsOnly
placeholderText: qsTr("Current PIN code")
text: ""
}
TextField {
id: setPinCodeString
anchors.horizontalCenter: parent.horizontalCenter
visible: false
width: myWidht * 0.5
echoMode: TextInput.Password
passwordMaskDelay: 500 // milliseconds
inputMethodHints: Qt.ImhDigitsOnly
placeholderText: qsTr("New PIN code")
text: ""
}
TextField {
id: setPinCodeString2
anchors.horizontalCenter: parent.horizontalCenter
visible: false
width: myWidht * 0.5
echoMode: TextInput.Password
passwordMaskDelay: 500 // milliseconds
inputMethodHints: Qt.ImhDigitsOnly
placeholderText: qsTr("Confirm new PIN code")
text: ""
}
Text {
id: errorLabel
visible: false
anchors.horizontalCenter: parent.horizontalCenter
font.bold: true
color: datovkaPalette.text
width: myWidht
text: ""
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.Wrap
}
Connections {
target: settings
@@ -157,9 +180,18 @@ Component {
onClicked: {
/* set new pin code */
if (actionName == "new") {
if (setPinCodeString.text == "") {
errorLabel.text = qsTr("Error: New PIN code is missing!")
if (setPinCodeString.text == "" || setPinCodeString2.text == "") {
errorLabel.text = qsTr("Error: Both new PIN code fields must be filled in!")
errorLabel.visible = true
if (setPinCodeString.text == "") {
setPinCodeString.focus = true
} else if (setPinCodeString2.text == "") {
setPinCodeString2.focus = true
}
} else if (setPinCodeString2.text != setPinCodeString.text) {
errorLabel.text = qsTr("Error: Newly entered PIN codes are different!")
errorLabel.visible = true
setPinCodeString2.focus = true
} else {
errorLabel.visible = false
settings.updatePinSettings(true, setPinCodeString.text.toString())
@@ -169,9 +201,18 @@ Component {
} else if (actionName == "change") {
if (getPinCodeString.text == currentPIN) {
errorLabel.visible = false
if (setPinCodeString.text == "") {
errorLabel.text = qsTr("Error: New PIN code is missing!")
if (setPinCodeString.text == "" || setPinCodeString2.text == "") {
errorLabel.text = qsTr("Error: Both new PIN code fields must be filled in!")
errorLabel.visible = true
if (setPinCodeString.text == "") {
setPinCodeString.focus = true
} else if (setPinCodeString2.text == "") {
setPinCodeString2.focus = true
}
} else if (setPinCodeString2.text != setPinCodeString.text) {
errorLabel.text = qsTr("Error: Newly entered PIN codes are different!")
errorLabel.visible = true
setPinCodeString2.focus = true
} else {
errorLabel.visible = false
settings.updatePinSettings(true, setPinCodeString.text.toString())
@@ -179,6 +220,8 @@ Component {
}
} else {
errorLabel.text = qsTr("Error: Current PIN code is wrong!")
getPinCodeString.text = ""
getPinCodeString.focus = true
errorLabel.visible = true
}
/* remove/disable current pin code */
@@ -189,13 +232,15 @@ Component {
pageView.pop(StackView.Immediate)
} else {
errorLabel.text = qsTr("Error: Current PIN code is wrong!")
getPinCodeString.text = ""
getPinCodeString.focus = true
errorLabel.visible = true
}
}
}
}
Button {
text: qsTr("Cancel")
text: qsTr("Close")
onClicked: {
pageView.pop(StackView.Immediate)
}