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. 49
      electrum/gui/qml/components/Preferences.qml

49
electrum/gui/qml/components/Preferences.qml

@ -180,28 +180,43 @@ 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)
if (checked) {
var dialog = pinSetup.createObject(preferences, {mode: 'enter'}) var dialog = pinSetup.createObject(preferences, {mode: 'enter'})
dialog.accepted.connect(function() { dialog.accepted.connect(function() {
Config.pinCode = dialog.pincode Config.pinCode = dialog.pincode
dialog.close() dialog.close()
}) })
dialog.rejected.connect(function() {
checked = false
})
dialog.open() dialog.open()
} else {
focus = false
Config.pinCode = ''
// re-add binding, pincode still set if auth failed
checked = Qt.binding(function () { return Config.pinCode })
} }
} }
}
}
Label {
Layout.fillWidth: true
text: qsTr('PIN')
wrapMode: Text.Wrap
}
}
Button { Button {
text: qsTr('Modify') text: qsTr('Modify')
visible: Config.pinCode != '' visible: Config.pinCode != ''
@ -214,14 +229,6 @@ Pane {
dialog.open() dialog.open()
} }
} }
Button {
text: qsTr('Remove')
visible: Config.pinCode != ''
onClicked: {
Config.pinCode = ''
}
}
}
RowLayout { RowLayout {
Layout.columnSpan: 2 Layout.columnSpan: 2

Loading…
Cancel
Save