From 17b3b208d5c3dbaa2583cae5f7bc348743cc9de4 Mon Sep 17 00:00:00 2001 From: Dag Heyman Date: Tue, 15 Aug 2017 09:25:10 +0200 Subject: [PATCH] Always deselect credential with ESC --- qml/ArrowKeysSelecter.qml | 1 + qml/main.qml | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/qml/ArrowKeysSelecter.qml b/qml/ArrowKeysSelecter.qml index 9cbbfa38..dfea6e0a 100644 --- a/qml/ArrowKeysSelecter.qml +++ b/qml/ArrowKeysSelecter.qml @@ -37,4 +37,5 @@ Item { Keys.onReturnPressed: generateOrCopy() Keys.onEnterPressed: generateOrCopy() + Keys.onEscapePressed: deselectCredential() } diff --git a/qml/main.qml b/qml/main.qml index 944925c7..3d7b2c7e 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -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