From 474bc5f6a4f699722905fba8b37ec787f19bd2d5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois-Simon=20Fauteux-Chapleau?=
 <francois-simon.fauteux-chapleau@savoirfairelinux.com>
Date: Thu, 4 Apr 2024 11:39:44 -0400
Subject: [PATCH] incalllocalvideo: allow resizing/changing opacity of local
 video

This feature was accidentally removed in a recent refactoring of the
local video preview:
https://review.jami.net/c/jami-client-qt/+/27740

Change-Id: I8b621d4f692124311f0807d1bc0be0e96717a499
---
 .../mainview/components/InCallLocalVideo.qml  | 22 ++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/app/mainview/components/InCallLocalVideo.qml b/src/app/mainview/components/InCallLocalVideo.qml
index 1b244b691..9ec70efdd 100644
--- a/src/app/mainview/components/InCallLocalVideo.qml
+++ b/src/app/mainview/components/InCallLocalVideo.qml
@@ -43,8 +43,14 @@ LocalVideo {
 
     visibilityCondition: (CurrentCall.isSharing || !CurrentCall.isVideoMuted) &&
                          !CurrentCall.isConference
+
+    // Keep the area of the preview a proportion of the screen size plus a
+    // modifier to allow the user to scale it.
+    readonly property real containerArea: container.width * container.height
+    property real scalingFactor: 1
+    width: Math.sqrt(containerArea / 16) * scalingFactor
     height: width * invAspectRatio
-    width: Math.max(container.width / 5, JamiTheme.minimumPreviewWidth)
+
     flip: CurrentCall.flipSelf && !CurrentCall.isSharing
     blurRadius: hidden ? 25 : 0
 
@@ -62,6 +68,20 @@ LocalVideo {
     // Animate the hiddenSize with a Behavior.
     Behavior on sideMargin { NumberAnimation { duration: 250; easing.type: Easing.OutExpo }}
     readonly property bool onLeft: state.indexOf("left") !== -1
+
+    MouseArea {
+        anchors.fill: parent
+        enabled: !localPreview.hidden
+        onWheel: function(event) {
+            const delta = event.angleDelta.y / 120 * 0.1;
+            if (event.modifiers & Qt.ControlModifier) {
+                parent.opacity = JamiQmlUtils.clamp(parent.opacity + delta, 0.25, 1);
+            } else {
+                localPreview.scalingFactor = JamiQmlUtils.clamp(localPreview.scalingFactor + delta, 0.5, 4);
+            }
+        }
+    }
+
     PushButton {
         id: hidePreviewButton
         objectName: "hidePreviewButton"
-- 
GitLab