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

View File

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

View File

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