Browse Source

qml: PIN enable/disable/change more in line with other preferences items

master
Sander van Grieken 3 years ago
parent
commit
41f0f73bed
  1. 79
      electrum/gui/qml/components/Preferences.qml

79
electrum/gui/qml/components/Preferences.qml

@ -180,46 +180,53 @@ Pane {
text: qsTr('Wallet behavior') text: qsTr('Wallet behavior')
} }
Label {
text: qsTr('PIN')
}
RowLayout { RowLayout {
Label { Layout.fillWidth: true
text: Config.pinCode == '' ? qsTr('Off'): qsTr('On') Layout.leftMargin: -constants.paddingSmall
color: Material.accentColor spacing: 0
Layout.rightMargin: constants.paddingMedium Switch {
} id: usePin
Button { checked: Config.pinCode
text: qsTr('Enable') onCheckedChanged: {
visible: Config.pinCode == '' if (activeFocus) {
onClicked: { console.log('PIN active ' + checked)
var dialog = pinSetup.createObject(preferences, {mode: 'enter'}) if (checked) {
dialog.accepted.connect(function() { var dialog = pinSetup.createObject(preferences, {mode: 'enter'})
Config.pinCode = dialog.pincode dialog.accepted.connect(function() {
dialog.close() Config.pinCode = dialog.pincode
}) dialog.close()
dialog.open() })
dialog.rejected.connect(function() {
checked = false
})
dialog.open()
} else {
focus = false
Config.pinCode = ''
// re-add binding, pincode still set if auth failed
checked = Qt.binding(function () { return Config.pinCode })
}
}
} }
} }
Button { Label {
text: qsTr('Modify') Layout.fillWidth: true
visible: Config.pinCode != '' text: qsTr('PIN')
onClicked: { wrapMode: Text.Wrap
var dialog = pinSetup.createObject(preferences, {mode: 'change', pincode: Config.pinCode})
dialog.accepted.connect(function() {
Config.pinCode = dialog.pincode
dialog.close()
})
dialog.open()
}
} }
Button { }
text: qsTr('Remove')
visible: Config.pinCode != '' Button {
onClicked: { text: qsTr('Modify')
Config.pinCode = '' visible: Config.pinCode != ''
} onClicked: {
var dialog = pinSetup.createObject(preferences, {mode: 'change', pincode: Config.pinCode})
dialog.accepted.connect(function() {
Config.pinCode = dialog.pincode
dialog.close()
})
dialog.open()
} }
} }

Loading…
Cancel
Save