Allow use of the delete key to delete PCs

This commit is contained in:
Cameron Gutman 2023-03-25 16:33:16 -05:00
parent 5e6b60bae0
commit ca91f9b702

View file

@ -211,7 +211,7 @@ CenteredGridView {
text: qsTr("Delete PC") text: qsTr("Delete PC")
onTriggered: { onTriggered: {
deletePcDialog.pcIndex = index deletePcDialog.pcIndex = index
// get confirmation first, actual closing is called from the dialog deletePcDialog.pcName = model.name
deletePcDialog.open() deletePcDialog.open()
} }
} }
@ -271,6 +271,12 @@ CenteredGridView {
// the ItemDelegate and not where the mouse cursor is // the ItemDelegate and not where the mouse cursor is
pcContextMenu.open() pcContextMenu.open()
} }
Keys.onDeletePressed: {
deletePcDialog.pcIndex = index
deletePcDialog.pcName = model.name
deletePcDialog.open()
}
} }
ErrorMessageDialog { ErrorMessageDialog {
@ -302,16 +308,14 @@ CenteredGridView {
NavigableMessageDialog { NavigableMessageDialog {
id: deletePcDialog id: deletePcDialog
// don't allow edits to the rest of the window while open // don't allow edits to the rest of the window while open
property int pcIndex : -1; property int pcIndex : -1
text:qsTr("Are you sure you want to remove this PC?") property string pcName : ""
text: qsTr("Are you sure you want to remove '%1'?").arg(pcName)
standardButtons: Dialog.Yes | Dialog.No standardButtons: Dialog.Yes | Dialog.No
function deletePc() { onAccepted: {
console.log("deleting PC pairing for PC at index: " + pcIndex) computerModel.deleteComputer(pcIndex)
computerModel.deleteComputer(pcIndex);
} }
onAccepted: deletePc()
} }
NavigableMessageDialog { NavigableMessageDialog {