Get Ctrl+Enter working and fix cleaning up and closing

This commit is contained in:
Loren Burkholder 2021-07-17 19:43:35 -04:00
parent 67fff656b3
commit f1f5796fb8
1 changed files with 14 additions and 15 deletions

View File

@ -23,12 +23,24 @@ ApplicationWindow {
} }
} }
function cleanUpAndClose() {
if (inviteeEntry.text !== "")
addInvite();
invitees.accept();
close();
}
title: qsTr("Invite users to ") + roomName title: qsTr("Invite users to ") + roomName
x: MainWindow.x + (MainWindow.width / 2) - (width / 2) x: MainWindow.x + (MainWindow.width / 2) - (width / 2)
y: MainWindow.y + (MainWindow.height / 2) - (height / 2) y: MainWindow.y + (MainWindow.height / 2) - (height / 2)
height: 380 height: 380
width: 340 width: 340
Shortcut {
sequence: "Ctrl+Enter"
onActivated: cleanUpAndClose()
}
Shortcut { Shortcut {
sequence: StandardKey.Cancel sequence: StandardKey.Cancel
onActivated: inviteDialogRoot.close() onActivated: inviteDialogRoot.close()
@ -39,10 +51,6 @@ ApplicationWindow {
anchors.margins: 10 anchors.margins: 10
spacing: 10 spacing: 10
Keys.onShortcutOverride: event.accepted = ((event.key === Qt.Key_Return || event.key === Qt.Key_Enter) && (event.modifiers & Qt.ControlModifier))
Keys.onEnterPressed: if (event.modifiers & Qt.ControlModifier) invitees.accept()
Keys.onReturnPressed: if (event.modifiers & Qt.ControlModifier) invitees.accept()
Label { Label {
text: qsTr("User ID to invite") text: qsTr("User ID to invite")
Layout.fillWidth: true Layout.fillWidth: true
@ -64,14 +72,8 @@ ApplicationWindow {
} }
Component.onCompleted: forceActiveFocus() Component.onCompleted: forceActiveFocus()
// Shortcut {
// sequence: "Ctrl+Enter"
// onActivated: invitees.accept()
// }
Keys.onShortcutOverride: event.accepted = ((event.key === Qt.Key_Return || event.key === Qt.Key_Enter) && (event.modifiers & Qt.ControlModifier)) Keys.onShortcutOverride: event.accepted = ((event.key === Qt.Key_Return || event.key === Qt.Key_Enter) && (event.modifiers & Qt.ControlModifier))
Keys.onEnterPressed: if (event.modifiers & Qt.ControlModifier) invitees.accept() Keys.onPressed: if ((event.key === Qt.Key_Return || event.key === Qt.Key_Enter) && (event.modifiers === Qt.ControlModifier)) cleanUpAndClose()
Keys.onReturnPressed: if (event.modifiers & Qt.ControlModifier) invitees.accept()
} }
@ -208,10 +210,7 @@ ApplicationWindow {
Button { Button {
text: qsTr("Invite") text: qsTr("Invite")
DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole
onClicked: { onClicked: cleanUpAndClose()
invitees.accept();
inviteDialogRoot.close();
}
} }
Button { Button {