Always deselect credential with ESC

This commit is contained in:
Dag Heyman 2017-08-15 09:25:10 +02:00
parent 01cb66ddbd
commit 17b3b208d5
No known key found for this signature in database
GPG Key ID: 06FC004369E7D338
2 changed files with 13 additions and 6 deletions

View File

@ -37,4 +37,5 @@ Item {
Keys.onReturnPressed: generateOrCopy()
Keys.onEnterPressed: generateOrCopy()
Keys.onEscapePressed: deselectCredential()
}

View File

@ -220,7 +220,10 @@ ApplicationWindow {
// A mouse area to allow a click
// outside search bar to remove focus from it.
anchors.fill: parent
onClicked: arrowKeys.focus = true
onClicked: {
arrowKeys.focus = true;
deselectCredential()
}
}
Flickable {
@ -317,8 +320,7 @@ ApplicationWindow {
Keys.onEscapePressed: {
search.text = ""
arrowKeys.focus = true
selected = null
selectedIndex = null
deselectCredential()
}
Keys.onReturnPressed: generateOrCopy()
Keys.onEnterPressed: generateOrCopy()
@ -355,6 +357,11 @@ ApplicationWindow {
onTriggered: touchYourYubikey.open()
}
function deselectCredential() {
selected = null;
selectedIndex = null;
}
function getSpacedCredential(code) {
// Add a space in the code for easier reading.
@ -469,7 +476,7 @@ ApplicationWindow {
} else if (search.text.length > 0) {
// If search was started but no result,
// reset selected to avoid hidden selected creds.
selected = null
deselectCredential()
}
return result
}
@ -614,8 +621,7 @@ ApplicationWindow {
// Left click, select or deselect credential.
if (mouse.button & Qt.LeftButton) {
if (selected != null && selected.name === modelData.name) {
selected = null
selectedIndex = null
deselectCredential()
} else {
selected = modelData
selectedIndex = index