From 77b8f2858e3f5e73cd3a7441767ce827cce1da6f Mon Sep 17 00:00:00 2001 From: Ming Rui Zhang <mingrui.zhang@savoirfairelinux.com> Date: Fri, 6 Aug 2021 15:29:11 -0400 Subject: [PATCH] keyEvent: replace the unclear StandardKey comparisons StandardKey.MoveToNextLine, StandardKey.MoveToPreviousLine and StandardKey.InsertParagraphSeparator maybe confusing and better to be replaced by direct key comparisons Change-Id: I13361a43437214b9368d01a97b2e542f57835964 --- src/commoncomponents/BackButton.qml | 3 ++- src/commoncomponents/JamiSwitch.qml | 3 ++- src/commoncomponents/MaterialButton.qml | 3 ++- src/commoncomponents/PhotoboothView.qml | 15 +++++++++------ src/mainview/components/ContactSearchBar.qml | 3 ++- src/mainview/components/MessageBarTextArea.qml | 3 ++- src/wizardview/components/ProfilePage.qml | 4 ++-- 7 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/commoncomponents/BackButton.qml b/src/commoncomponents/BackButton.qml index 71eea2764..239893223 100644 --- a/src/commoncomponents/BackButton.qml +++ b/src/commoncomponents/BackButton.qml @@ -31,7 +31,8 @@ PushButton { toolTipText: JamiStrings.back Keys.onPressed: function (keyEvent) { - if (keyEvent.matches(StandardKey.InsertParagraphSeparator)) { + if (keyEvent.key === Qt.Key_Enter || + keyEvent.key === Qt.Key_Return) { clicked() keyEvent.accepted = true } diff --git a/src/commoncomponents/JamiSwitch.qml b/src/commoncomponents/JamiSwitch.qml index 055919efd..70e89ec17 100644 --- a/src/commoncomponents/JamiSwitch.qml +++ b/src/commoncomponents/JamiSwitch.qml @@ -54,7 +54,8 @@ Switch { } Keys.onPressed: function (keyEvent) { - if (keyEvent.matches(StandardKey.InsertParagraphSeparator)) { + if (keyEvent.key === Qt.Key_Enter || + keyEvent.key === Qt.Key_Return) { checked = !checked keyEvent.accepted = true } diff --git a/src/commoncomponents/MaterialButton.qml b/src/commoncomponents/MaterialButton.qml index 85a9f0a82..6eed704e7 100644 --- a/src/commoncomponents/MaterialButton.qml +++ b/src/commoncomponents/MaterialButton.qml @@ -191,7 +191,8 @@ Button { } Keys.onPressed: function (keyEvent) { - if (keyEvent.matches(StandardKey.InsertParagraphSeparator)) { + if (keyEvent.key === Qt.Key_Enter || + keyEvent.key === Qt.Key_Return) { clicked() keyEvent.accepted = true } diff --git a/src/commoncomponents/PhotoboothView.qml b/src/commoncomponents/PhotoboothView.qml index 0ad3c88f5..a0496e603 100644 --- a/src/commoncomponents/PhotoboothView.qml +++ b/src/commoncomponents/PhotoboothView.qml @@ -198,10 +198,11 @@ Item { JamiResources.baseline_camera_alt_24dp_svg Keys.onPressed: function (keyEvent) { - if (keyEvent.matches(StandardKey.InsertParagraphSeparator)) { + if (keyEvent.key === Qt.Key_Enter || + keyEvent.key === Qt.Key_Return) { clicked() keyEvent.accepted = true - } else if (keyEvent.matches(StandardKey.MoveToPreviousLine)) { + } else if (keyEvent.key === Qt.Key_Up) { root.focusOnPreviousItem() keyEvent.accepted = true } @@ -245,11 +246,12 @@ Item { KeyNavigation.up: takePhotoButton Keys.onPressed: function (keyEvent) { - if (keyEvent.matches(StandardKey.InsertParagraphSeparator)) { + if (keyEvent.key === Qt.Key_Enter || + keyEvent.key === Qt.Key_Return) { clicked() takePhotoButton.forceActiveFocus() keyEvent.accepted = true - } else if (keyEvent.matches(StandardKey.MoveToNextLine) || + } else if (keyEvent.key === Qt.Key_Down || keyEvent.key === Qt.Key_Tab) { if (isPreviewing) { root.focusOnNextItem() @@ -283,11 +285,12 @@ Item { imageColor: JamiTheme.textColor Keys.onPressed: function (keyEvent) { - if (keyEvent.matches(StandardKey.InsertParagraphSeparator)) { + if (keyEvent.key === Qt.Key_Enter || + keyEvent.key === Qt.Key_Return) { focusAfterFileDialogClosed = true clicked() keyEvent.accepted = true - } else if (keyEvent.matches(StandardKey.MoveToNextLine) || + } else if (keyEvent.key === Qt.Key_Down || keyEvent.key === Qt.Key_Tab) { root.focusOnNextItem() keyEvent.accepted = true diff --git a/src/mainview/components/ContactSearchBar.qml b/src/mainview/components/ContactSearchBar.qml index c67912cbe..1d8dda8dc 100644 --- a/src/mainview/components/ContactSearchBar.qml +++ b/src/mainview/components/ContactSearchBar.qml @@ -134,7 +134,8 @@ Rectangle { } Keys.onPressed: function (keyEvent) { - if (keyEvent.matches(StandardKey.InsertParagraphSeparator)) { + if (keyEvent.key === Qt.Key_Enter || + keyEvent.key === Qt.Key_Return) { if (contactSearchBar.text !== "") { returnPressedWhileSearching() keyEvent.accepted = true diff --git a/src/mainview/components/MessageBarTextArea.qml b/src/mainview/components/MessageBarTextArea.qml index dffeac603..9a2310c0b 100644 --- a/src/mainview/components/MessageBarTextArea.qml +++ b/src/mainview/components/MessageBarTextArea.qml @@ -138,7 +138,8 @@ Flickable { if (keyEvent.matches(StandardKey.Paste)) { MessagesAdapter.pasteKeyDetected() keyEvent.accepted = true - } else if (keyEvent.matches(StandardKey.InsertParagraphSeparator)) { + } else if (keyEvent.key === Qt.Key_Enter || + keyEvent.key === Qt.Key_Return) { if (!(keyEvent.modifiers & Qt.ShiftModifier)) { root.sendMessagesRequired() keyEvent.accepted = true diff --git a/src/wizardview/components/ProfilePage.qml b/src/wizardview/components/ProfilePage.qml index c5d187b27..91d48292b 100644 --- a/src/wizardview/components/ProfilePage.qml +++ b/src/wizardview/components/ProfilePage.qml @@ -154,7 +154,7 @@ Rectangle { KeyNavigation.down: KeyNavigation.tab Keys.onPressed: function (keyEvent) { - if (keyEvent.matches(StandardKey.MoveToPreviousLine)) { + if (keyEvent.key === Qt.Key_Up) { setAvatarWidget.focusOnPreviousPhotoBoothItem() keyEvent.accepted = true } @@ -221,7 +221,7 @@ Rectangle { KeyNavigation.up: saveProfileBtn Keys.onPressed: function (keyEvent) { - if (keyEvent.matches(StandardKey.MoveToNextLine) || + if (keyEvent.key === Qt.Key_Down || keyEvent.key === Qt.Key_Tab) { setAvatarWidget.focusOnNextPhotoBoothItem() keyEvent.accepted = true -- GitLab