From ad7d8e136feb6298f6778e8a13f923eb6c0d9caa Mon Sep 17 00:00:00 2001
From: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
Date: Mon, 13 Feb 2023 12:24:34 -0300
Subject: [PATCH] callviewcontextmenu: cleanup

Change-Id: I76f77f7e5f7eb3e2c46e01f9cdd51b2d40af7739
GitLab: #975
---
 resources/icons/informations_black_24dp.svg   |  13 +
 resources/icons/screenshot_black_24dp.svg     |  19 ++
 src/app/mainview/components/CallOverlay.qml   |  16 +-
 .../components/CallViewContextMenu.qml        | 297 +++++++-----------
 .../components/ParticipantOverlay.qml         |   2 +-
 5 files changed, 145 insertions(+), 202 deletions(-)
 create mode 100644 resources/icons/informations_black_24dp.svg
 create mode 100644 resources/icons/screenshot_black_24dp.svg

diff --git a/resources/icons/informations_black_24dp.svg b/resources/icons/informations_black_24dp.svg
new file mode 100644
index 000000000..cd6609af3
--- /dev/null
+++ b/resources/icons/informations_black_24dp.svg
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 24.3.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+	 viewBox="0 0 24 24" style="enable-background:new 0 0 24 24;" xml:space="preserve">
+<g id="noun-about-3359358" transform="translate(-188.36 -188.36)">
+	<path id="Path_14" d="M200.4,190.4c-5.5,0-10,4.5-10,10s4.5,10,10,10s10-4.5,10-10C210.4,194.8,205.9,190.4,200.4,190.4z
+		 M200.4,208.5c-4.5,0-8.2-3.7-8.2-8.2s3.7-8.2,8.2-8.2c4.5,0,8.2,3.7,8.2,8.2C208.5,204.9,204.9,208.5,200.4,208.5L200.4,208.5z"/>
+	<path id="Path_15" d="M200.4,197.7c-0.5,0-0.9,0.4-0.9,0.9c0,0,0,0,0,0v7.7c0,0.5,0.4,0.9,0.9,0.9s0.9-0.4,0.9-0.9l0,0v-7.7
+		C201.3,198.1,200.9,197.7,200.4,197.7C200.4,197.7,200.4,197.7,200.4,197.7z"/>
+	<path id="Path_16" d="M201.3,195.3c0,0.5-0.4,0.9-0.9,0.9c-0.5,0-0.9-0.4-0.9-0.9c0-0.5,0.4-0.9,0.9-0.9l0,0
+		C200.9,194.4,201.3,194.8,201.3,195.3"/>
+</g>
+</svg>
diff --git a/resources/icons/screenshot_black_24dp.svg b/resources/icons/screenshot_black_24dp.svg
new file mode 100644
index 000000000..d3b513e3b
--- /dev/null
+++ b/resources/icons/screenshot_black_24dp.svg
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 24.3.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+	 viewBox="0 0 24 24" style="enable-background:new 0 0 24 24;" xml:space="preserve">
+<g>
+	<path d="M2.9,9.1c0.5,0,0.9-0.4,0.9-0.9V4.2c0-0.2,0.2-0.3,0.3-0.3h3.9c0.5,0,1-0.4,1-0.9S8.6,2,8.1,2H4.2C3,2,2,3,2,4.2v3.9
+		C2,8.6,2.4,9.1,2.9,9.1z"/>
+	<path d="M21.1,14.9c-0.5,0-0.9,0.4-0.9,0.9v3.9c0,0.2-0.2,0.3-0.3,0.3h-3.9c-0.5,0-0.9,0.4-0.9,0.9c0,0.5,0.4,1,0.9,1h3.9
+		c1.2,0,2.2-1,2.2-2.2v-3.9C22,15.4,21.6,14.9,21.1,14.9z"/>
+	<path d="M8.1,20.1H4.2c-0.2,0-0.3-0.2-0.3-0.3v-3.9c0-0.5-0.4-1-1-1c-0.5,0-0.9,0.4-0.9,1v3.9C2,21,3,22,4.2,22h3.9
+		c0.5,0,1-0.4,1-1C9.1,20.5,8.6,20.1,8.1,20.1z"/>
+	<path d="M15.9,3.9h3.9c0.2,0,0.3,0.2,0.3,0.3v3.9c0,0.5,0.4,0.9,0.9,0.9S22,8.6,22,8.1V4.2C22,3,21,2,19.8,2h-3.9
+		c-0.5,0-0.9,0.4-0.9,0.9S15.4,3.9,15.9,3.9z"/>
+	<path d="M16.8,12c0-1.3-0.5-2.5-1.4-3.4c-0.9-0.9-2.1-1.4-3.4-1.4c0,0,0,0,0,0c-1.3,0-2.5,0.5-3.4,1.4C7.7,9.5,7.2,10.7,7.2,12
+		c0,2.7,2.2,4.8,4.8,4.8c0,0,0,0,0,0C14.7,16.8,16.8,14.7,16.8,12z M12,9.1C12,9.1,12,9.1,12,9.1c1.6,0,2.9,1.3,2.9,2.9
+		c0,0.8-0.3,1.5-0.9,2.1c-0.5,0.5-1.3,0.9-2.1,0.9c0,0,0,0,0,0c-1.6,0-2.9-1.3-2.9-2.9c0-0.8,0.3-1.5,0.9-2.1
+		C10.5,9.4,11.2,9.1,12,9.1z"/>
+</g>
+</svg>
diff --git a/src/app/mainview/components/CallOverlay.qml b/src/app/mainview/components/CallOverlay.qml
index d6123739a..5a108d992 100644
--- a/src/app/mainview/components/CallOverlay.qml
+++ b/src/app/mainview/components/CallOverlay.qml
@@ -56,12 +56,12 @@ Item {
                                           hoveredOverlaySinkId,
                                           hoveredOverVideoMuted)
     {
-        callViewContextMenu.x = x
-        callViewContextMenu.y = y
+        callViewContextMenu.x = root.width - x >= callViewContextMenu.width ? x : root.width - callViewContextMenu.width
+        callViewContextMenu.y = root.height - y >= callViewContextMenu.height ? y : root.height - callViewContextMenu.height
         callViewContextMenu.hoveredOverlayUri = hoveredOverlayUri
         callViewContextMenu.hoveredOverlaySinkId = hoveredOverlaySinkId
         callViewContextMenu.hoveredOverVideoMuted = hoveredOverVideoMuted
-        callViewContextMenu.openMenu()
+        callViewContextMenu.open()
     }
 
     DropArea {
@@ -178,18 +178,14 @@ Item {
     CallViewContextMenu {
         id: callViewContextMenu
 
-        onTransferCallButtonClicked: openContactPicker(ContactList.TRANSFER)
-        onPluginItemClicked: openPluginsMenu()
         onScreenshotTaken: {
             toastManager.instantiateToast();
         }
-        onRecordCallClicked: CallAdapter.recordThisCallToggle()
-        onOpenSelectionWindow: {
-            SelectScreenWindowCreation.presentSelectScreenWindow(
-                        appWindow, windowSelection)
-        }
         onScreenshotButtonHoveredChanged: {
             participantsLayer.screenshotButtonHovered = screenshotButtonHovered
         }
     }
+    onVisibleChanged: {
+        callViewContextMenu.close()
+    }
 }
diff --git a/src/app/mainview/components/CallViewContextMenu.qml b/src/app/mainview/components/CallViewContextMenu.qml
index 4a7aa35d3..91611dad6 100644
--- a/src/app/mainview/components/CallViewContextMenu.qml
+++ b/src/app/mainview/components/CallViewContextMenu.qml
@@ -19,6 +19,8 @@
  */
 
 import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
 
 import net.jami.Models 1.1
 import net.jami.Adapters 1.1
@@ -28,206 +30,119 @@ import "../../commoncomponents"
 import "../../commoncomponents/contextmenu"
 import "../js/screenrubberbandcreation.js" as ScreenRubberBandCreation
 
-ContextMenuAutoLoader {
+Popup {
     id: root
 
-    property bool windowSelection: false
-
-    signal pluginItemClicked
-    signal transferCallButtonClicked
-    signal recordCallClicked
-    signal openSelectionWindow
     signal screenshotTaken
-    property bool screenshotButtonHovered: screenShot.itemHovered
+    property bool screenshotButtonHovered: false
 
     property string hoveredOverlayUri: ""
     property string hoveredOverlaySinkId: ""
     property bool hoveredOverVideoMuted: true
 
-    property list<GeneralMenuItem> menuItems: [
-        GeneralMenuItem {
-            id: resumePauseCall
-
-            canTrigger: CurrentCall.isSIP
-            itemName: CurrentCall.isPaused ?
-                          JamiStrings.resumeCall :
-                          JamiStrings.pauseCall
-            iconSource: CurrentCall.isPaused ?
-                            JamiResources.play_circle_outline_24dp_svg :
-                            JamiResources.pause_circle_outline_24dp_svg
-            onClicked: {
-                CallAdapter.holdThisCallToggle()
-            }
-        },
-        GeneralMenuItem {
-            id: inputPanelSIP
-
-            canTrigger: CurrentCall.isSIP
-            itemName: JamiStrings.sipInputPanel
-            iconSource: JamiResources.ic_keypad_svg
-            onClicked: {
-                sipInputPanel.open()
-            }
-        },
-        GeneralMenuItem {
-            id: callTransfer
-
-            canTrigger: CurrentCall.isSIP
-            itemName: JamiStrings.transferCall
-            iconSource: JamiResources.phone_forwarded_24dp_svg
-            addMenuSeparatorAfter: CurrentCall.isSIP
-            onClicked: {
-                root.transferCallButtonClicked()
-            }
-        },
-        GeneralMenuItem {
-            id: localRecord
-
-            itemName: CurrentCall.isRecordingLocally ?
-                          JamiStrings.stopRec :
-                          JamiStrings.startRec
-            iconSource: JamiResources.fiber_manual_record_24dp_svg
-            iconColor: JamiTheme.recordIconColor
-            onClicked: {
-                root.recordCallClicked()
-            }
-        },
-        GeneralMenuItem {
-            id: fullScreen
-
-            itemName: layoutManager.isCallFullscreen ?
-                          JamiStrings.exitFullScreen :
-                          JamiStrings.viewFullScreen
-            iconSource: layoutManager.isCallFullscreen ?
-                            JamiResources.close_fullscreen_24dp_svg :
-                            JamiResources.open_in_full_24dp_svg
-            onClicked: {
-                callStackView.toggleFullScreen()
-            }
-        },
-        GeneralMenuItem {
-            id: stopSharing
-
-            canTrigger: CurrentCall.isSharing
-                        && !CurrentCall.isSIP
-                        && !CurrentCall.isVideoMuted
-            itemName: JamiStrings.stopSharing
-            iconSource: JamiResources.share_stop_black_24dp_svg
-            iconColor: JamiTheme.redColor
-            onClicked: AvAdapter.stopSharing(CurrentCall.sharingSource)
-        },
-        GeneralMenuItem {
-            id: shareScreen
-
-            canTrigger: CurrentAccount.videoEnabled_Video
-                        && AvAdapter.currentRenderingDeviceType !== Video.DeviceType.DISPLAY
-                        && !CurrentCall.isSIP
-            itemName: JamiStrings.shareScreen
-            iconSource: JamiResources.laptop_black_24dp_svg
-            onClicked: {
-                if (Qt.application.screens.length === 1) {
-                    AvAdapter.shareEntireScreen(0)
-                } else {
-                    windowSelection = false
-                    openSelectionWindow()
-                }
-            }
-        },
-        GeneralMenuItem {
-            id: shareWindow
-
-            canTrigger: CurrentAccount.videoEnabled_Video
-                        && AvAdapter.currentRenderingDeviceType !== Video.DeviceType.DISPLAY
-                        && !CurrentCall.isSIP
-            itemName: JamiStrings.shareWindow
-            iconSource: JamiResources.window_black_24dp_svg
-            onClicked: {
-                AvAdapter.getListWindows()
-                if (AvAdapter.windowsNames.length >= 1) {
-                    windowSelection = true
-                    openSelectionWindow()
-                }
-            }
-        },
-        GeneralMenuItem {
-            id: shareScreenArea
-
-            canTrigger: CurrentAccount.videoEnabled_Video
-                        && AvAdapter.currentRenderingDeviceType !== Video.DeviceType.DISPLAY
-                        && !CurrentCall.isSIP
-                        && Qt.platform.os.toString() !== "windows" // temporarily disable for windows
-            itemName: JamiStrings.shareScreenArea
-            iconSource: JamiResources.share_area_black_24dp_svg
-            onClicked: {
-                if (Qt.platform.os !== "windows") {
-                    AvAdapter.shareScreenArea(0, 0, 0, 0)
-                } else {
-                    ScreenRubberBandCreation.createScreenRubberBandWindowObject()
-                    ScreenRubberBandCreation.showScreenRubberBandWindow()
-                }
-            }
-        },
-        GeneralMenuItem {
-            id: shareFile
-
-            canTrigger: CurrentAccount.videoEnabled_Video
-                        && !CurrentCall.isSIP
-            itemName: JamiStrings.shareFile
-            iconSource: JamiResources.file_black_24dp_svg
-            onClicked: {
-                jamiFileDialog.open()
-            }
-        },
-        GeneralMenuItem {
-            id: viewPlugin
-
-            canTrigger: PluginAdapter.isEnabled &&
-                        PluginAdapter.callMediaHandlersListCount
-            itemName: JamiStrings.viewPlugin
-            iconSource: JamiResources.extension_24dp_svg
-            onClicked: {
-                root.pluginItemClicked()
-            }
-        },
-        GeneralMenuItem {
-            id: advancedInformation
-
-            canTrigger: true
-            itemName: JamiStrings.advancedInformation
-            iconSource: JamiResources.settings_24dp_svg
-
-            onClicked: {
-                CallAdapter.startTimerInformation();
-                callInformationOverlay.open()
-            }
-        },
-        GeneralMenuItem {
-            id: screenShot
-
-            canTrigger: hoveredOverlayUri !== "" && hoveredOverVideoMuted === false
-            itemName: JamiStrings.tileScreenshot
-            iconSource: JamiResources.baseline_camera_alt_24dp_svg
-
-            MaterialToolTip {
-                id: tooltip
-
-                parent: screenShot
-                visible: screenShot.itemHovered
-                delay: Qt.styleHints.mousePressAndHoldInterval
-                property bool isMe: CurrentAccount.uri === hoveredOverlayUri
-                text: isMe ? JamiStrings.me
-                           : UtilsAdapter.getBestNameForUri(CurrentAccount.id, hoveredOverlayUri)
-            }
-
-            onClicked: {
-                if (CallAdapter.takeScreenshot(videoProvider.captureRawVideoFrame(hoveredOverlaySinkId),
-                                               UtilsAdapter.getDirScreenshot())) {
-                    screenshotTaken()
+    property var listModel: ListModel {
+        id: actionsModel
+    }
+
+    onAboutToShow: {
+        actionsModel.clear()
+        actionsModel.append({"Top": true})
+        if (hoveredOverlayUri !== "" && hoveredOverVideoMuted === false)
+            actionsModel.append({"Name": JamiStrings.tileScreenshot,
+                                "IconSource" : JamiResources.screenshot_black_24dp_svg})
+        actionsModel.append({"Name": JamiStrings.advancedInformation,
+                            "IconSource": JamiResources.informations_black_24dp_svg})
+        actionsModel.append({"Bottom": true})
+        itemListView.implicitHeight = 20 + 45 * (actionsModel.count - 2)
+    }
+
+    onAboutToHide: {
+        screenshotButtonHovered = false
+        hoveredOverlayUri = ""
+        hoveredOverlaySinkId = ""
+        hoveredOverVideoMuted = true
+        actionsModel.clear()
+    }
+
+    background: Rectangle {
+        color: "transparent"
+    }
+
+    contentItem: Rectangle {
+        id: container
+        width: childrenRect.width
+        height: childrenRect.height
+        color: "#c4272727"
+        radius: 4
+
+        ColumnLayout {
+            anchors.topMargin: 8
+            anchors.bottomMargin: 8
+            ListView {
+                id: itemListView
+
+                orientation: ListView.Vertical
+                implicitWidth: 200
+                implicitHeight: 100
+                interactive: false
+
+                model: actionsModel
+                delegate: ItemDelegate {
+                    id: menuItem
+
+                    width: 200
+                    height: Top || Bottom ? 10 : 45
+
+                    background: Rectangle {
+                        visible: !Top && !Bottom
+                        anchors.fill: parent
+                        color: menuItem.down ? "#c4aaaaaa" : menuItem.hovered ? "#c4777777" : "transparent"
+                    }
+
+                    RowLayout {
+                        anchors.fill: parent
+                        visible: !Top && !Bottom
+                        ResponsiveImage {
+                            Layout.leftMargin: JamiTheme.preferredMarginSize
+                            source: IconSource
+                            color: "white"
+                            width: 20
+                            height: 20
+                        }
+                        Text {
+                            Layout.fillWidth: true
+                            horizontalAlignment: Text.AlignLeft
+                            verticalAlignment: Text.AlignVCenter
+                            text: Name
+                            elide: Text.ElideRight
+                            font.pointSize: JamiTheme.participantFontSize
+                            color: "white"
+                        }
+                    }
+
+                    onClicked: {
+                        switch(Name) {
+                            case JamiStrings.advancedInformation:
+                                CallAdapter.startTimerInformation()
+                                callInformationOverlay.open()
+                                break
+                            case JamiStrings.tileScreenshot:
+                                if (CallAdapter.takeScreenshot(videoProvider.captureRawVideoFrame(hoveredOverlaySinkId),
+                                                            UtilsAdapter.getDirScreenshot())) {
+                                    screenshotTaken()
+                                }
+                                break
+                        }
+                        root.close()
+                    }
+
+                    onHoveredChanged: {
+                        if (Name === JamiStrings.tileScreenshot) {
+                            screenshotButtonHovered = hovered
+                        }
+                    }
                 }
             }
         }
-    ]
-
-
-    Component.onCompleted: menuItemsToLoad = menuItems
+    }
 }
diff --git a/src/app/mainview/components/ParticipantOverlay.qml b/src/app/mainview/components/ParticipantOverlay.qml
index d83f59a91..2aa3d9cba 100644
--- a/src/app/mainview/components/ParticipantOverlay.qml
+++ b/src/app/mainview/components/ParticipantOverlay.qml
@@ -106,7 +106,7 @@ Item {
 
     Rectangle {
         z: -1
-        border.color: JamiTheme.buttonTintedBlue
+        border.color: voiceActive ? JamiTheme.buttonTintedBlue : "yellow"
         border.width: 2
         color: "transparent"
         radius: 10
-- 
GitLab