From 67bc66ee0ce9e16d8eacc9ba60d48ded6f8982e7 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Sat, 25 Dec 2021 18:48:23 +0100 Subject: [PATCH] Allow using ESC to go back to room list Fix #392 --- imports/NeoChat/Page/RoomPage.qml | 10 ++++++++++ imports/NeoChat/Page/RoomWindow.qml | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/imports/NeoChat/Page/RoomPage.qml b/imports/NeoChat/Page/RoomPage.qml index c46e55288..1fec99732 100644 --- a/imports/NeoChat/Page/RoomPage.qml +++ b/imports/NeoChat/Page/RoomPage.qml @@ -26,6 +26,10 @@ Kirigami.ScrollablePage { /// Used to determine if scrolling to the bottom should mark the message as unread property bool hasScrolledUpBefore: false; + /// Disable cancel shortcut. Used by the seperate window since it provide its own + /// cancel implementation. + property bool disableCancelShortcut: false + title: currentRoom.htmlSafeDisplayName KeyNavigation.left: pageStack.get(0) @@ -55,6 +59,12 @@ Kirigami.ScrollablePage { connection: Controller.activeConnection } + Shortcut { + sequence: StandardKey.Cancel + onActivated: applicationWindow().pageStack.get(0).forceActiveFocus() + enabled: !page.disableCancelShortcut + } + Connections { target: Controller.activeConnection function onJoinedRoom(room, invited) { diff --git a/imports/NeoChat/Page/RoomWindow.qml b/imports/NeoChat/Page/RoomWindow.qml index 112f06feb..6711023e9 100644 --- a/imports/NeoChat/Page/RoomWindow.qml +++ b/imports/NeoChat/Page/RoomWindow.qml @@ -12,8 +12,14 @@ Kirigami.ApplicationWindow { required property var currentRoom minimumWidth: Kirigami.Units.gridUnit * 10 minimumHeight: Kirigami.Units.gridUnit * 15 + + Shortcut { + sequence: StandardKey.Cancel + onActivated: window.close() + } pageStack.initialPage: RoomPage { visible: true currentRoom: window.currentRoom + disableCancelShortcut: true } }