Add Edit menu for the credential actions

This commit is contained in:
Dag Heyman 2017-03-22 14:45:33 +01:00
parent 92c97003b7
commit f873e52adb
No known key found for this signature in database
GPG Key ID: 06FC004369E7D338
3 changed files with 45 additions and 14 deletions

View File

@ -7,13 +7,8 @@ Menu {
property bool showGenerate
property bool enableGenerate
signal copy
signal generate
signal deleteCredential
MenuItem {
text: qsTr("\&Copy")
shortcut: StandardKey.Copy
enabled: (credential != null) && (credential.code != null)
onTriggered: copy()
}
@ -21,14 +16,12 @@ Menu {
MenuItem {
visible: showGenerate
enabled: enableGenerate
text: qsTr("\&Generate code")
shortcut: "Space"
text: qsTr("Generate code")
onTriggered: generate()
}
MenuItem {
text: qsTr("\&Delete")
shortcut: StandardKey.Delete
text: qsTr("Delete")
onTriggered: deleteCredential()
}
}

View File

@ -6,6 +6,9 @@ MenuBar {
property bool slotMode
property bool hasDevice
property var credential
property bool enableGenerate
signal openAddCredential
signal openAbout
signal openReset
@ -41,6 +44,32 @@ MenuBar {
}
}
Menu {
title: qsTr("\&Edit")
MenuItem {
text: qsTr("\&Copy")
shortcut: StandardKey.Copy
enabled: (credential != null) && (credential.code != null)
onTriggered: copy()
}
MenuItem {
enabled: enableGenerate
text: qsTr("\&Generate code")
shortcut: "Space"
onTriggered: generate()
}
MenuItem {
text: qsTr("\&Delete")
shortcut: StandardKey.Delete
enabled: (credential != null)
onTriggered: deleteCredential()
}
}
Menu {
title: qsTr("\&Help")
MenuItem {
@ -48,4 +77,8 @@ MenuBar {
onTriggered: openAbout()
}
}
}

View File

@ -27,6 +27,14 @@ ApplicationWindow {
// See http://doc.qt.io/qt-5/qwindow.html#Visibility-enum
property bool shouldRefresh: visibility != 3 && visibility != 0
signal copy
signal generate
signal deleteCredential
onDeleteCredential: confirmDeleteCredential.open()
onGenerate: handleGenerate(repeater.selected)
onCopy: clipboard.setClipboard(repeater.selected.code)
onHasDeviceChanged: handleNewDevice()
onCredentialsChanged: {
@ -37,6 +45,8 @@ ApplicationWindow {
menuBar: MainMenuBar {
slotMode: settings.slotMode
hasDevice: device.hasDevice
credential: repeater.selected
enableGenerate: enableManualGenerate(repeater.selected)
onOpenAddCredential: openClearAddCredential()
onOpenSetPassword: setPassword.open()
onOpenReset: reset.open()
@ -44,13 +54,11 @@ ApplicationWindow {
onOpenAbout: aboutPage.open()
}
Shortcut {
sequence: StandardKey.Close
onActivated: close()
}
SystemPalette {
id: palette
}
@ -159,9 +167,6 @@ ApplicationWindow {
credential: repeater.selected
showGenerate: allowManualGenerate(repeater.selected)
enableGenerate: enableManualGenerate(repeater.selected)
onGenerate: handleGenerate(repeater.selected)
onDeleteCredential: confirmDeleteCredential.open()
onCopy: clipboard.setClipboard(repeater.selected.code)
}
DeleteCredentialConfirmation {