From f1f5796fb8ba5b504043310dba17acd3ef2860bd Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Sat, 17 Jul 2021 19:43:35 -0400 Subject: [PATCH] Get Ctrl+Enter working and fix cleaning up and closing --- resources/qml/InviteDialog.qml | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/resources/qml/InviteDialog.qml b/resources/qml/InviteDialog.qml index 8bdbb767..417de049 100644 --- a/resources/qml/InviteDialog.qml +++ b/resources/qml/InviteDialog.qml @@ -23,12 +23,24 @@ ApplicationWindow { } } + function cleanUpAndClose() { + if (inviteeEntry.text !== "") + addInvite(); + invitees.accept(); + close(); + } + title: qsTr("Invite users to ") + roomName x: MainWindow.x + (MainWindow.width / 2) - (width / 2) y: MainWindow.y + (MainWindow.height / 2) - (height / 2) height: 380 width: 340 + Shortcut { + sequence: "Ctrl+Enter" + onActivated: cleanUpAndClose() + } + Shortcut { sequence: StandardKey.Cancel onActivated: inviteDialogRoot.close() @@ -39,10 +51,6 @@ ApplicationWindow { anchors.margins: 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 { text: qsTr("User ID to invite") Layout.fillWidth: true @@ -64,14 +72,8 @@ ApplicationWindow { } 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.onEnterPressed: if (event.modifiers & Qt.ControlModifier) invitees.accept() - Keys.onReturnPressed: 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() } @@ -208,10 +210,7 @@ ApplicationWindow { Button { text: qsTr("Invite") DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole - onClicked: { - invitees.accept(); - inviteDialogRoot.close(); - } + onClicked: cleanUpAndClose() } Button {