diff --git a/TODO.md b/TODO.md index 71851f36..99004f12 100644 --- a/TODO.md +++ b/TODO.md @@ -10,7 +10,7 @@ - can leave room with a reason? - field/area focus line in popups weird - use new nio `restore_login()` -- verify all popups and boxes work +- verify all popups and boxes work: enter/esc, tab focus, operations ## Refactoring diff --git a/src/gui/Base/HBox.qml b/src/gui/Base/HBox.qml index 861caf09..9e690709 100644 --- a/src/gui/Base/HBox.qml +++ b/src/gui/Base/HBox.qml @@ -7,10 +7,6 @@ HFlickableColumnPage { implicitWidth: Math.min(parent.width, theme.controls.box.defaultWidth) implicitHeight: Math.min(parent.height, flickable.contentHeight) - // XXX - // Keys.onReturnPressed: if (clickButtonOnEnter) enterClickButton() - // Keys.onEnterPressed: Keys.onReturnPressed(event) - background: Rectangle { color: theme.controls.box.background radius: theme.controls.box.radius diff --git a/src/gui/Base/HPage.qml b/src/gui/Base/HPage.qml index 379861f4..9026957d 100644 --- a/src/gui/Base/HPage.qml +++ b/src/gui/Base/HPage.qml @@ -7,6 +7,10 @@ Page { padding: currentSpacing < theme.spacing ? 0 : currentSpacing background: null + Keys.onReturnPressed: keyboardAccept() + Keys.onEnterPressed: keyboardAccept() + Keys.onEscapePressed: keyboardCancel() + property bool useVariableSpacing: true @@ -19,6 +23,9 @@ Page { ) : theme.spacing + signal keyboardAccept() + signal keyboardCancel() + Behavior on padding { HNumberAnimation {} } } diff --git a/src/gui/Pages/AccountSettings/Account.qml b/src/gui/Pages/AccountSettings/Account.qml index 4a8f0a90..81f33f36 100644 --- a/src/gui/Pages/AccountSettings/Account.qml +++ b/src/gui/Pages/AccountSettings/Account.qml @@ -87,7 +87,8 @@ HFlickableColumnPage { } } - Keys.onEscapePressed: cancel() + onKeyboardCancel: cancel() + onKeyboardAccept: applyChanges() HUserAvatar { @@ -221,8 +222,6 @@ HFlickableColumnPage { // TODO: Qt 5.14+: use a Binding enabled when text not empty color: utils.nameColor(text) - - onAccepted: applyChanges() } } @@ -262,7 +261,6 @@ HFlickableColumnPage { HTextField { width: parent.width error: aliasField.alreadyTakenBy !== "" - onAccepted: applyChanges() defaultText: aliasField.currentAlias placeholderText: qsTr("e.g. %1").arg(( nameField.item.text || diff --git a/src/gui/Pages/AddAccount/SignIn.qml b/src/gui/Pages/AddAccount/SignIn.qml index a443cb3c..855408a5 100644 --- a/src/gui/Pages/AddAccount/SignIn.qml +++ b/src/gui/Pages/AddAccount/SignIn.qml @@ -92,7 +92,7 @@ HFlickableColumnPage { } } - Keys.onEscapePressed: page.cancel() + onKeyboardCancel: page.cancel() Timer { diff --git a/src/gui/Pages/AddChat/CreateRoom.qml b/src/gui/Pages/AddChat/CreateRoom.qml index 279e4acd..fd944374 100644 --- a/src/gui/Pages/AddChat/CreateRoom.qml +++ b/src/gui/Pages/AddChat/CreateRoom.qml @@ -64,7 +64,7 @@ HFlickableColumnPage { } } - Keys.onEscapePressed: cancel() + onKeyboardCancel: cancel() HRoomAvatar { diff --git a/src/gui/Pages/AddChat/DirectChat.qml b/src/gui/Pages/AddChat/DirectChat.qml index 337fa0b8..292ad334 100644 --- a/src/gui/Pages/AddChat/DirectChat.qml +++ b/src/gui/Pages/AddChat/DirectChat.qml @@ -81,7 +81,7 @@ HFlickableColumnPage { } } - Keys.onEscapePressed: cancel() + onKeyboardCancel: cancel() CurrentUserAvatar { diff --git a/src/gui/Pages/AddChat/JoinRoom.qml b/src/gui/Pages/AddChat/JoinRoom.qml index f1317b85..1bdf9d9c 100644 --- a/src/gui/Pages/AddChat/JoinRoom.qml +++ b/src/gui/Pages/AddChat/JoinRoom.qml @@ -69,7 +69,7 @@ HFlickableColumnPage { } } - Keys.onEscapePressed: cancel() + onKeyboardCancel: cancel() CurrentUserAvatar { diff --git a/src/gui/Pages/Chat/RoomPane/SettingsView.qml b/src/gui/Pages/Chat/RoomPane/SettingsView.qml index 437a8ed9..529b8023 100644 --- a/src/gui/Pages/Chat/RoomPane/SettingsView.qml +++ b/src/gui/Pages/Chat/RoomPane/SettingsView.qml @@ -79,7 +79,8 @@ HFlickableColumnPage { } } - Keys.onEscapePressed: cancel() + onKeyboardAccept: save() + onKeyboardCancel: cancel() HRoomAvatar { diff --git a/src/gui/Popups/HColumnPopup.qml b/src/gui/Popups/HColumnPopup.qml index 08531bd8..a800a781 100644 --- a/src/gui/Popups/HColumnPopup.qml +++ b/src/gui/Popups/HColumnPopup.qml @@ -10,6 +10,8 @@ HPopup { default property alias pageData: page.columnData readonly property alias page: page + signal keyboardAccept() + HColumnPage { id: page @@ -23,5 +25,8 @@ HPopup { topPadding + bottomPadding + implicitContentHeight, ) useVariableSpacing: false + + Keys.onReturnPressed: popup.keyboardAccept() + Keys.onEnterPressed: popup.keyboardAccept() } } diff --git a/src/gui/Popups/HFlickableColumnPopup.qml b/src/gui/Popups/HFlickableColumnPopup.qml index a2aefec0..970289f9 100644 --- a/src/gui/Popups/HFlickableColumnPopup.qml +++ b/src/gui/Popups/HFlickableColumnPopup.qml @@ -10,6 +10,8 @@ HPopup { default property alias pageData: page.columnData readonly property alias page: page + signal keyboardAccept() + HFlickableColumnPage { id: page @@ -21,5 +23,8 @@ HPopup { popup.maximumPreferredHeight, implicitHeaderHeight + implicitFooterHeight + contentHeight, ) + + Keys.onReturnPressed: popup.keyboardAccept() + Keys.onEnterPressed: popup.keyboardAccept() } } diff --git a/src/gui/Popups/PasswordPopup.qml b/src/gui/Popups/PasswordPopup.qml index 53bbcb56..a4237a20 100644 --- a/src/gui/Popups/PasswordPopup.qml +++ b/src/gui/Popups/PasswordPopup.qml @@ -74,6 +74,7 @@ HFlickableColumnPopup { } onOpened: passwordField.forceActiveFocus() + onKeyboardAccept: popup.validate() SummaryLabel { id: summary } @@ -90,8 +91,6 @@ HFlickableColumnPopup { onTextChanged: passwordValid = validateWhileTyping ? verifyPassword(text) : null - onAccepted: popup.validate() - Layout.fillWidth: true } diff --git a/src/gui/Popups/RedactPopup.qml b/src/gui/Popups/RedactPopup.qml index b8984030..10ef0d9e 100644 --- a/src/gui/Popups/RedactPopup.qml +++ b/src/gui/Popups/RedactPopup.qml @@ -51,6 +51,7 @@ HFlickableColumnPopup { } onOpened: reasonField.item.forceActiveFocus() + onKeyboardAccept: popup.remove() SummaryLabel { @@ -80,7 +81,6 @@ HFlickableColumnPopup { HTextField { width: parent.width - onAccepted: popup.remove() } } } diff --git a/src/gui/Popups/RemoveMemberPopup.qml b/src/gui/Popups/RemoveMemberPopup.qml index 2d5d5c01..1b90a98f 100644 --- a/src/gui/Popups/RemoveMemberPopup.qml +++ b/src/gui/Popups/RemoveMemberPopup.qml @@ -48,6 +48,7 @@ HFlickableColumnPopup { } onOpened: reasonField.item.forceActiveFocus() + onKeyboardAccept: popup.remove() SummaryLabel { @@ -70,7 +71,6 @@ HFlickableColumnPopup { HTextField { width: parent.width - onAccepted: popup.remove() } } }