From 740cb407f8279eed31eaee8b5aa1eb69f670a235 Mon Sep 17 00:00:00 2001
From: ababi <albert.babi@savoirfairelinux.com>
Date: Wed, 28 Oct 2020 10:51:47 +0100
Subject: [PATCH] callview: context menu accessible only from call rectangle

Change-Id: Ic687f86ab965b3aa3244a743c5e0e2bd66590cad
Gitlab: #150
---
 src/mainview/components/AudioCallPage.qml | 22 ++++++++++------------
 src/mainview/components/VideoCallPage.qml | 23 +++++++++++------------
 2 files changed, 21 insertions(+), 24 deletions(-)

diff --git a/src/mainview/components/AudioCallPage.qml b/src/mainview/components/AudioCallPage.qml
index f87a6bf3c..645b4e611 100644
--- a/src/mainview/components/AudioCallPage.qml
+++ b/src/mainview/components/AudioCallPage.qml
@@ -91,9 +91,17 @@ Rectangle {
                 hoverEnabled: true
                 propagateComposedEvents: true
 
-                acceptedButtons: Qt.LeftButton
+                acceptedButtons: Qt.LeftButton | Qt.RightButton
 
-                onDoubleClicked: callStackView.toggleFullScreen()
+                onDoubleClicked: {
+                    if (mouse.button === Qt.LeftButton)
+                        callStackView.toggleFullScreen()
+                }
+
+                onClicked: {
+                    if (mouse.button === Qt.RightButton)
+                        audioCallOverlay.openCallViewContextMenuInPos(mouse.x, mouse.y)
+                }
 
                 CallOverlay {
                     id: audioCallOverlay
@@ -239,15 +247,5 @@ Rectangle {
         }
     }
 
-    MouseArea {
-        anchors.fill: parent
-
-        acceptedButtons: Qt.RightButton
-
-        onClicked: {
-            audioCallOverlay.openCallViewContextMenuInPos(mouse.x, mouse.y)
-        }
-    }
-
     color: "black"
 }
diff --git a/src/mainview/components/VideoCallPage.qml b/src/mainview/components/VideoCallPage.qml
index 628def498..0ae2eec41 100644
--- a/src/mainview/components/VideoCallPage.qml
+++ b/src/mainview/components/VideoCallPage.qml
@@ -151,12 +151,21 @@ Rectangle {
 
             MouseArea {
                 anchors.fill: parent
+
                 hoverEnabled: true
                 propagateComposedEvents: true
 
-                acceptedButtons: Qt.LeftButton
+                acceptedButtons: Qt.LeftButton | Qt.RightButton
 
-                onDoubleClicked: callStackView.toggleFullScreen()
+                onDoubleClicked: {
+                    if (mouse.button === Qt.LeftButton)
+                        callStackView.toggleFullScreen()
+                }
+
+                onClicked: {
+                    if (mouse.button === Qt.RightButton)
+                        videoCallOverlay.openCallViewContextMenuInPos(mouse.x, mouse.y)
+                }
 
                 CallOverlay {
                     id: videoCallOverlay
@@ -325,16 +334,6 @@ Rectangle {
         }
     }
 
-    MouseArea {
-        anchors.fill: parent
-
-        acceptedButtons: Qt.RightButton
-
-        onClicked: {
-            videoCallOverlay.openCallViewContextMenuInPos(mouse.x, mouse.y)
-        }
-    }
-
     onBestNameChanged: {
         ContactAdapter.setCalleeDisplayName(bestName)
     }
-- 
GitLab