feature: double click to copy/generate

Double-click on a credential now copies
the code to the clipboard. If it is a touch or
HOTP credential a code is generated as well.

The generate code action also copies the code to
the clipboard.

Should resolve #146
This commit is contained in:
Dag Heyman 2017-07-07 10:03:50 +02:00
parent a1e2c449e0
commit 397defaeed
No known key found for this signature in database
GPG Key ID: 06FC004369E7D338
2 changed files with 21 additions and 0 deletions

View File

@ -269,6 +269,10 @@ Python {
// after update, since the code now
// might be available.
selected = cred
// When a single credential is updated,
// it is manually triggered and therefore
// should be copied to the clipboard.
copy()
}
function addCredential(name, key, oathType, digits, algorithm, touch, cb) {

View File

@ -268,6 +268,8 @@ ApplicationWindow {
anchors.fill: parent
onClicked: handleMouseClick(mouse, index,
modelData)
onDoubleClicked: handleCredentialDoubleClick(mouse, index,
modelData)
acceptedButtons: Qt.RightButton | Qt.LeftButton
}
@ -602,6 +604,21 @@ ApplicationWindow {
}
}
function handleCredentialDoubleClick(mouse, index, modelData) {
arrowKeys.forceActiveFocus()
// A double-click should select the credential,
// then generate if needed and copy the code.
selected = modelData
selectedIndex = index
if (selected.code == null || isExpired(selected)) {
generate()
} else {
copy()
}
}
function updateTrayVisability() {
SysTrayIcon.visible = settings.closeToTray
// When the tray option is enabled, closing the last window