Quick GUI: Add shortcuts

This commit is contained in:
Martchus 2018-09-10 20:43:58 +02:00
parent 24bc27ce8f
commit 55eddd3fed
4 changed files with 26 additions and 0 deletions

View File

@ -9,4 +9,10 @@ Controls.Dialog {
x: (parent.width - width) / 2
y: (parent.height - height) / 2
width: Math.min(parent.width, Kirigami.Units.gridUnit * 30)
function acceptOnReturn(event) {
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
this.accept()
}
}
}

View File

@ -17,6 +17,7 @@ Kirigami.ScrollablePage {
iconName: "list-add"
text: qsTr("Add account")
onTriggered: insertEntry("Account")
shortcut: "Ctrl+A"
}
left: Kirigami.Action {
iconName: "edit-paste"
@ -32,11 +33,13 @@ Kirigami.ScrollablePage {
showPassiveNotification(
qsTr("Pasted ") + pastedEntries.join(", "))
}
shortcut: StandardKey.Paste
}
right: Kirigami.Action {
iconName: "folder-add"
text: qsTr("Add category")
onTriggered: insertEntry("Node")
shortcut: "Ctrl+Shift+A"
}
}
background: Rectangle {
@ -91,6 +94,7 @@ Kirigami.ScrollablePage {
id: entryNameTextField
Layout.preferredWidth: renameDialog.availableWidth
placeholderText: qsTr("enter new name here")
Keys.onPressed: renameDialog.acceptOnReturn(event)
}
}
@ -194,17 +198,20 @@ Kirigami.ScrollablePage {
rootIndex))
showPassiveNotification(text + " " + model.name)
}
shortcut: StandardKey.Cut
},
Kirigami.Action {
iconName: "edit-delete"
text: qsTr("Delete")
onTriggered: confirmDeletionDialog.confirmDeletion(
model.name, index)
shortcut: StandardKey.Delete
},
Kirigami.Action {
iconName: "edit-rename"
text: qsTr("Rename")
onTriggered: renameDialog.renameEntry(model.name, index)
shortcut: "F2"
}
]
}

View File

@ -46,6 +46,7 @@ BasicDialog {
background: Rectangle {
border.color: "#5d5e6d"
}
Keys.onPressed: passwordDialog.acceptOnReturn(event)
}
Controls.TextField {
id: repeatPasswordTextField
@ -57,6 +58,7 @@ BasicDialog {
background: Rectangle {
border.color: passwordDialog.canAccept ? "#089900" : "#ff0000"
}
Keys.onPressed: passwordDialog.acceptOnReturn(event)
}
Controls.CheckBox {
id: showCharactersCheckBox

View File

@ -93,22 +93,26 @@ Kirigami.ApplicationWindow {
text: qsTr("Create new file")
iconName: "document-new"
onTriggered: fileDialog.createNew()
shortcut: StandardKey.New
},
Kirigami.Action {
text: qsTr("Open existing file")
iconName: "document-open"
onTriggered: fileDialog.openExisting()
shortcut: StandardKey.Open
},
Kirigami.Action {
text: qsTr("Recently opened ...")
iconName: "document-open-recent"
children: createFileActions(nativeInterface.recentFiles)
shortcut: "Ctrl+R"
},
Kirigami.Action {
text: qsTr("Save modifications")
enabled: nativeInterface.fileOpen
iconName: "document-save"
onTriggered: nativeInterface.save()
shortcut: StandardKey.Save
},
Kirigami.Action {
text: nativeInterface.passwordSet ? qsTr("Change password") : qsTr(
@ -117,12 +121,14 @@ Kirigami.ApplicationWindow {
iconName: "document-encrypt"
onTriggered: enterPasswordDialog.askForNewPassword(
"Change password for " + nativeInterface.filePath)
shortcut: "Ctrl+P"
},
Kirigami.Action {
text: "Close file"
enabled: nativeInterface.fileOpen
iconName: "document-close"
onTriggered: nativeInterface.close()
shortcut: StandardKey.Close
}
]
Controls.Switch {
@ -239,6 +245,11 @@ Kirigami.ApplicationWindow {
}
}
Shortcut {
sequence: "Ctrl+M"
onActivated: leftMenu.visible = !leftMenu.visible
}
function clearStack() {
pageStack.pop(root.pageStack.initialPage, Controls.StackView.Immediate)
}