From f8ff14f2782126ef619a84c57b2b309747498241 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Mon, 31 Oct 2022 12:00:02 -0400
Subject: [PATCH] misc: change "hide audio-only behavior"

+ Rename to "Hide spectators"
+ Hide if audio + video are disabled and not hand raised

Change-Id: I08e18731c28ceaa8222806ea6223e35d7af445a2
GitLab: #822
---
 daemon                                            |  2 +-
 src/app/appsettingsmanager.h                      |  2 +-
 src/app/callparticipantsmodel.cpp                 |  5 +++++
 src/app/callparticipantsmodel.h                   |  1 +
 src/app/constant/JamiStrings.qml                  |  2 +-
 src/app/currentconversation.h                     |  2 +-
 src/app/mainview/components/CallActionBar.qml     | 10 +++++-----
 src/app/mainview/components/ParticipantsLayer.qml |  8 ++++----
 8 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/daemon b/daemon
index 8abb7a04d..54ffd0f43 160000
--- a/daemon
+++ b/daemon
@@ -1 +1 @@
-Subproject commit 8abb7a04dcd08078662b95a26bf4dd5e15f1a2f2
+Subproject commit 54ffd0f4380bdbdc6a2fcb80847b2f5aefad4958
diff --git a/src/app/appsettingsmanager.h b/src/app/appsettingsmanager.h
index 3e5ab24e2..6acca9096 100644
--- a/src/app/appsettingsmanager.h
+++ b/src/app/appsettingsmanager.h
@@ -47,7 +47,7 @@ extern const QString defaultDownloadPath;
     X(BaseZoom, 1.0) \
     X(ParticipantsSide, false) \
     X(HideSelf, false) \
-    X(HideAudioOnly, false) \
+    X(HideSpectators, false) \
     X(AutoUpdate, true) \
     X(StartMinimized, false) \
     X(ShowChatviewHorizontally, true) \
diff --git a/src/app/callparticipantsmodel.cpp b/src/app/callparticipantsmodel.cpp
index e79b29771..a40070697 100644
--- a/src/app/callparticipantsmodel.cpp
+++ b/src/app/callparticipantsmodel.cpp
@@ -63,6 +63,11 @@ CallParticipantsModel::data(const QModelIndex& index, int role) const
         return QVariant(item.value(DEVICE).toString());
     case Role::Active:
         return QVariant(item.value(ACTIVE).toBool());
+    case Role::HideSpectators:
+        return QVariant((item.value(AUDIOLOCALMUTED).toBool()
+                        || item.value(AUDIOMODERATORMUTED).toBool())
+                        && item.value(VIDEOMUTED).toBool()
+                        && !item.value(HANDRAISED).toBool());
     case Role::AudioLocalMuted:
         return QVariant(item.value(AUDIOLOCALMUTED).toBool());
     case Role::AudioModeratorMuted:
diff --git a/src/app/callparticipantsmodel.h b/src/app/callparticipantsmodel.h
index b701cf239..b2cf49ec0 100644
--- a/src/app/callparticipantsmodel.h
+++ b/src/app/callparticipantsmodel.h
@@ -39,6 +39,7 @@
     X(YPosition) \
     X(Width) \
     X(Height) \
+    X(HideSpectators) \
     X(AudioLocalMuted) \
     X(AudioModeratorMuted) \
     X(VideoMuted) \
diff --git a/src/app/constant/JamiStrings.qml b/src/app/constant/JamiStrings.qml
index 4a9c572ac..070de9197 100644
--- a/src/app/constant/JamiStrings.qml
+++ b/src/app/constant/JamiStrings.qml
@@ -255,7 +255,7 @@ Item {
     property string participantsSide: qsTr("On the side")
     property string participantsTop: qsTr("On the top")
     property string hideSelf: qsTr("Hide self")
-    property string hideAudioOnly: qsTr("Hide audio-only participants")
+    property string hideSpectators: qsTr("Hide spectators")
 
     // LineEditContextMenu
     property string copy: qsTr("Copy")
diff --git a/src/app/currentconversation.h b/src/app/currentconversation.h
index 01fd61027..25f705305 100644
--- a/src/app/currentconversation.h
+++ b/src/app/currentconversation.h
@@ -54,7 +54,7 @@ class CurrentConversation final : public QObject
 
     // TODO: these belong in CurrentCall(which doesn't exist yet)
     QML_PROPERTY(bool, hideSelf)
-    QML_PROPERTY(bool, hideAudioOnly)
+    QML_PROPERTY(bool, hideSpectators)
 
 public:
     explicit CurrentConversation(LRCInstance* lrcInstance, QObject* parent = nullptr);
diff --git a/src/app/mainview/components/CallActionBar.qml b/src/app/mainview/components/CallActionBar.qml
index 6eecc9638..401be4bc2 100644
--- a/src/app/mainview/components/CallActionBar.qml
+++ b/src/app/mainview/components/CallActionBar.qml
@@ -180,9 +180,9 @@ Control {
                         UtilsAdapter.setAppValue(Settings.HideSelf, !layoutModel.get(index).ActiveSetting)
                         CurrentConversation.hideSelf = UtilsAdapter.getAppValue(Settings.HideSelf)
                         break
-                  case JamiStrings.hideAudioOnly:
-                        UtilsAdapter.setAppValue(Settings.HideAudioOnly, !layoutModel.get(index).ActiveSetting)
-                        CurrentConversation.hideAudioOnly = UtilsAdapter.getAppValue(Settings.HideAudioOnly)
+                  case JamiStrings.hideSpectators:
+                        UtilsAdapter.setAppValue(Settings.HideSpectators, !layoutModel.get(index).ActiveSetting)
+                        CurrentConversation.hideSpectators = UtilsAdapter.getAppValue(Settings.HideSpectators)
                         break
                 }
             }
@@ -224,9 +224,9 @@ Control {
                                     "BottomMargin": true,
                                     "SectionEnd": isConference})
                 if (isConference) {
-                    layoutModel.append({"Name": JamiStrings.hideAudioOnly,
+                    layoutModel.append({"Name": JamiStrings.hideSpectators,
                                         "IconSource": JamiResources.videocam_off_24dp_svg,
-                                        "ActiveSetting": UtilsAdapter.getAppValue(Settings.HideAudioOnly),
+                                        "ActiveSetting": UtilsAdapter.getAppValue(Settings.HideSpectators),
                                         "TopMargin": true,
                                         "BottomMargin": true})
                 }
diff --git a/src/app/mainview/components/ParticipantsLayer.qml b/src/app/mainview/components/ParticipantsLayer.qml
index b3fddbf0d..89f11a46c 100644
--- a/src/app/mainview/components/ParticipantsLayer.qml
+++ b/src/app/mainview/components/ParticipantsLayer.qml
@@ -36,10 +36,11 @@ Item {
     property int count: 0
     property bool inLine: CallParticipantsModel.conferenceLayout === CallParticipantsModel.ONE_WITH_SMALL
     property bool participantsSide
+    property bool enableHideSpectators: CallParticipantsModel.count > 1 && CurrentConversation.hideSpectators
 
     onVisibleChanged: {
         CurrentConversation.hideSelf = UtilsAdapter.getAppValue(Settings.HideSelf)
-        CurrentConversation.hideAudioOnly = UtilsAdapter.getAppValue(Settings.HideAudioOnly)
+        CurrentConversation.hideSpectators = UtilsAdapter.getAppValue(Settings.HideSpectators)
     }
 
     Component {
@@ -96,9 +97,8 @@ Item {
                 value: false
             }
             ValueFilter {
-                enabled: CallParticipantsModel.count > 1 &&
-                         CurrentConversation.hideAudioOnly
-                roleName: "VideoMuted"
+                enabled: root.enableHideSpectators
+                roleName: "HideSpectators"
                 value: false
             }
         }
-- 
GitLab