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.onReturnPressed: generateOrCopy()
Keys.onEnterPressed: generateOrCopy() Keys.onEnterPressed: generateOrCopy()
Keys.onEscapePressed: deselectCredential()
} }

View File

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