From 964af7fe3c3c4814922f264e5188e1426d15574c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Sat, 27 Mar 2021 18:48:53 -0400 Subject: [PATCH] misc: improve touch screen support Support single tap for showing call overlay and long press to show context menu for the smartlist Change-Id: I31a77169827860c07ec9d60e076c0c5c4e875408 --- src/mainview/components/CallOverlay.qml | 19 ++++---- .../ConversationSmartListViewItemDelegate.qml | 45 ++++++++++++------- 2 files changed, 38 insertions(+), 26 deletions(-) diff --git a/src/mainview/components/CallOverlay.qml b/src/mainview/components/CallOverlay.qml index 1a01bfc09..07082f912 100644 --- a/src/mainview/components/CallOverlay.qml +++ b/src/mainview/components/CallOverlay.qml @@ -485,9 +485,9 @@ Rectangle { hoverEnabled: true propagateComposedEvents: true - acceptedButtons: Qt.NoButton + acceptedButtons: Qt.LeftButton - onEntered: { + function resetStates() { if (overlayUpperPartRect.state !== 'entered') { overlayUpperPartRect.state = 'entered' } @@ -497,14 +497,15 @@ Rectangle { callOverlayTimer.restart() } + onReleased: { + resetStates() + } + onEntered: { + resetStates() + } + onMouseXChanged: { - if (overlayUpperPartRect.state !== 'entered') { - overlayUpperPartRect.state = 'entered' - } - if (callOverlayButtonGroup.state !== 'entered') { - callOverlayButtonGroup.state = 'entered' - } - callOverlayTimer.restart() + resetStates() } } diff --git a/src/mainview/components/ConversationSmartListViewItemDelegate.qml b/src/mainview/components/ConversationSmartListViewItemDelegate.qml index d1c00efb9..cac1eb71b 100644 --- a/src/mainview/components/ConversationSmartListViewItemDelegate.qml +++ b/src/mainview/components/ConversationSmartListViewItemDelegate.qml @@ -34,6 +34,8 @@ ItemDelegate { signal updateContactAvatarUidRequested(string uid) + property bool openedMenu: false + function convUid() { return UID } @@ -190,6 +192,26 @@ ItemDelegate { hoverEnabled: true acceptedButtons: Qt.LeftButton | Qt.RightButton + function openContextMenu(mouse) { + openedMenu = true + smartListContextMenu.parent = mouseAreaSmartListItemDelegate + + // Make menu pos at mouse. + var relativeMousePos = mapToItem(itemSmartListBackground, + mouse.x, mouse.y) + smartListContextMenu.x = relativeMousePos.x + smartListContextMenu.y = relativeMousePos.y + smartListContextMenu.responsibleAccountId = AccountAdapter.currentAccountId + smartListContextMenu.responsibleConvUid = UID + smartListContextMenu.contactType = ContactType + userProfile.responsibleConvUid = UID + userProfile.aliasText = DisplayName + userProfile.registeredNameText = DisplayID + userProfile.idText = URI + userProfile.contactImageUid = UID + smartListContextMenu.openMenu() + } + onPressed: { if (!InCall) { itemSmartListBackground.color = JamiTheme.pressColor @@ -207,31 +229,20 @@ ItemDelegate { communicationPageMessageWebView.setSendContactRequestButtonVisible(false) } } + onPressAndHold: { + openContextMenu(mouse) + } onReleased: { if (!InCall) { itemSmartListBackground.color = JamiTheme.selectionBlue } if (mouse.button === Qt.RightButton) { - smartListContextMenu.parent = mouseAreaSmartListItemDelegate - - // Make menu pos at mouse. - var relativeMousePos = mapToItem(itemSmartListBackground, - mouse.x, mouse.y) - smartListContextMenu.x = relativeMousePos.x - smartListContextMenu.y = relativeMousePos.y - smartListContextMenu.responsibleAccountId = AccountAdapter.currentAccountId - smartListContextMenu.responsibleConvUid = UID - smartListContextMenu.contactType = ContactType - userProfile.responsibleConvUid = UID - userProfile.aliasText = DisplayName - userProfile.registeredNameText = DisplayID - userProfile.idText = URI - userProfile.contactImageUid = UID - smartListContextMenu.openMenu() - } else if (mouse.button === Qt.LeftButton) { + openContextMenu(mouse) + } else if (mouse.button === Qt.LeftButton && !openedMenu) { conversationSmartListView.currentIndex = -1 conversationSmartListView.currentIndex = index } + openedMenu = false } onEntered: { if (!InCall) { -- GitLab