diff --git a/src/avatarimageprovider.h b/src/avatarimageprovider.h index 60b9f4d74a3cc43bf29a9e2b361827dca18aed10..3099b974734fdf876a33956ac7c99ed0ce94a113 100644 --- a/src/avatarimageprovider.h +++ b/src/avatarimageprovider.h @@ -29,8 +29,8 @@ class AvatarImageProvider : public QuickImageProviderBase public: AvatarImageProvider(LRCInstance* instance = nullptr) : QuickImageProviderBase(QQuickImageProvider::Image, - QQmlImageProviderBase::ForceAsynchronousImageLoading, - instance) + QQmlImageProviderBase::ForceAsynchronousImageLoading, + instance) {} /* @@ -65,7 +65,7 @@ public: } else if (idType == "contact") { return Utils::contactPhoto(lrcInstance_, idContent, requestedSize); } else if (idType == "fallback") { - return Utils::fallbackAvatar(QString(), idContent, requestedSize); + return Utils::fallbackAvatar(idContent, QString(), requestedSize); } else if (idType == "default") { return Utils::fallbackAvatar(QString(), QString(), requestedSize); } else if (idType == "base64") { diff --git a/src/calladapter.cpp b/src/calladapter.cpp index 7dd9a84e8ba7f8645779fec00d94186fd7988c41..58598b72a2039ee560ae2943b75ff41bbbf367da 100644 --- a/src/calladapter.cpp +++ b/src/calladapter.cpp @@ -339,6 +339,7 @@ CallAdapter::fillParticipantData(QMap<QString, QString> participant) data["videoMuted"] = participant["videoMuted"] == "true"; data["audioLocalMuted"] = participant["audioLocalMuted"] == "true"; data["audioModeratorMuted"] = participant["audioModeratorMuted"] == "true"; + data["isContact"] = false; auto bestName = participant["uri"]; auto& accInfo = lrcInstance_->accountModel().getAccountInfo(accountId_); @@ -356,7 +357,7 @@ CallAdapter::fillParticipantData(QMap<QString, QString> participant) participant["uri"]); if (participant["videoMuted"] == "true") data["avatar"] = contact.profileInfo.avatar; - + data["isContact"] = true; } catch (...) { } } diff --git a/src/mainview/components/CallOverlay.qml b/src/mainview/components/CallOverlay.qml index 07082f91291ed07fd76ca3f05339debd43a594fc..b0c611e9515b6826d0113d280dab808e3458dfd0 100644 --- a/src/mainview/components/CallOverlay.qml +++ b/src/mainview/components/CallOverlay.qml @@ -130,9 +130,9 @@ Rectangle { participantOverlays[p].setMenu(participant.uri, participant.bestName, participant.isLocal, participant.active, showMax) if (participant.videoMuted) - participantOverlays[p].setAvatar(participant.avatar) + participantOverlays[p].setAvatar(true, participant.avatar, participant.uri, participant.isLocal, participant.isContact) else - participantOverlays[p].setAvatar("") + participantOverlays[p].setAvatar(false) currentUris.push(participantOverlays[p].uri) } else { // Participant is no longer in conference @@ -173,9 +173,9 @@ Rectangle { hover.setMenu(infos[infoVariant].uri, infos[infoVariant].bestName, infos[infoVariant].isLocal, infos[infoVariant].active, showMax) if (infos[infoVariant].videoMuted) - hover.setAvatar(infos[infoVariant].avatar) + hover.setAvatar(true, infos[infoVariant].avatar, infos[infoVariant].uri, infos[infoVariant].isLocal, infos[infoVariant].isContact) else - hover.setAvatar("") + hover.setAvatar(false) participantOverlays.push(hover) } } diff --git a/src/mainview/components/ParticipantOverlay.qml b/src/mainview/components/ParticipantOverlay.qml index 23739d725a951fdc0d72fa0c6e83d52a2c9ade79..f800ba07a810954566d2ce8d58cb333ba6a06d00 100644 --- a/src/mainview/components/ParticipantOverlay.qml +++ b/src/mainview/components/ParticipantOverlay.qml @@ -47,15 +47,26 @@ Rectangle { property bool participantIsModerator: false property bool participantIsMuted: false property bool participantIsModeratorMuted: false - property bool participantMenuActive: false - // TODO: try to use AvatarImage as well - function setAvatar(avatar) { - if (avatar === "") { - contactImage.source = "" - } else { - contactImage.source = JamiQmlUtils.base64StringTitle + avatar + function setAvatar(show, avatar, uri, local, isContact) { + if (!show) + contactImage.visible = false + else { + if (avatar) { + contactImage.mode = AvatarImage.Mode.FromBase64 + contactImage.updateImage(avatar) + } else if (local) { + contactImage.mode = AvatarImage.Mode.FromAccount + contactImage.updateImage(AccountAdapter.currentAccountId) + } else if (isContact) { + contactImage.mode = AvatarImage.Mode.FromContactUri + contactImage.updateImage(uri) + } else { + contactImage.mode = AvatarImage.Mode.FromTemporaryName + contactImage.updateImage(uri) + } + contactImage.visible = true } } @@ -173,6 +184,35 @@ Rectangle { } } + AvatarImage { + id: contactImage + + anchors.centerIn: parent + height: Math.min(parent.width / 2, parent.height / 2) + width: Math.min(parent.width / 2, parent.height / 2) + + fillMode: Image.PreserveAspectFit + imageId: "" + visible: false + mode: AvatarImage.Mode.Default + showPresenceIndicator: false + + layer.enabled: true + layer.effect: OpacityMask { + maskSource: Rectangle { + width: contactImage.width + height: contactImage.height + radius: { + var size = ((contactImage.width <= contactImage.height)? + contactImage.width : contactImage.height) + return size / 2 + } + } + } + layer.mipmap: false + layer.smooth: true + } + // Participant background, mousearea, hover and buttons for moderation Rectangle { id: participantRect @@ -190,42 +230,13 @@ Rectangle { propagateComposedEvents: true acceptedButtons: Qt.LeftButton - Image { - id: contactImage - - anchors.centerIn: parent - height: Math.min(parent.width / 2, parent.height / 2) - width: Math.min(parent.width / 2, parent.height / 2) - - fillMode: Image.PreserveAspectFit - source: "" - asynchronous: true - - layer.enabled: true - layer.effect: OpacityMask { - maskSource: Rectangle{ - width: contactImage.width - height: contactImage.height - radius: { - var size = ((contactImage.width <= contactImage.height)? - contactImage.width : contactImage.height) - return size / 2 - } - } - } - layer.mipmap: false - layer.smooth: true - } - ParticipantOverlayMenu { id: overlayMenu visible: participantRect.opacity !== 0 onMouseAreaExited: { - if (contactImage.status === Image.Null) { - root.z = 1 - participantRect.state = "exited" - } + root.z = 1 + participantRect.state = "exited" } onMouseChanged: { participantRect.state = "entered" @@ -235,17 +246,13 @@ Rectangle { } onEntered: { - if (contactImage.status === Image.Null) { - root.z = 2 - participantRect.state = "entered" - } + root.z = 2 + participantRect.state = "entered" } onExited: { - if (contactImage.status === Image.Null) { - root.z = 1 - participantRect.state = "exited" - } + root.z = 1 + participantRect.state = "exited" } onMouseXChanged: {