From 38febbf0bc87d2b14a975a6b9028c2b9c46ab886 Mon Sep 17 00:00:00 2001 From: cberthet <capucine.berthet@savoirfairelinux.com> Date: Tue, 19 Dec 2023 14:21:01 -0500 Subject: [PATCH] fileSending: enable click on image and video Change-Id: I48a68504b8b738a8db59337d48a69b16f5731bbe --- .../DataTransferMessageDelegate.qml | 24 +++++-------- src/app/commoncomponents/SBSMessageBase.qml | 34 +++++++++++++++---- 2 files changed, 36 insertions(+), 22 deletions(-) diff --git a/src/app/commoncomponents/DataTransferMessageDelegate.qml b/src/app/commoncomponents/DataTransferMessageDelegate.qml index dc711101d..1f4cdecae 100644 --- a/src/app/commoncomponents/DataTransferMessageDelegate.qml +++ b/src/app/commoncomponents/DataTransferMessageDelegate.qml @@ -285,12 +285,15 @@ Loader { } bubble.timestampItem.timeLabel.text += " - " + txt bubble.color = "transparent" - bubble.z = 1 + if (mediaInfo.isImage) + bubble.z = 1 + else + timeUnderBubble = true } onContentWidthChanged: { if (bubble.timestampItem.timeLabel.width > contentWidth) - imageTooSmall = true + timeUnderBubble = true else { bubble.timestampItem.timeColor = JamiTheme.whiteColor bubble.timestampItem.timeLabel.opacity = 1 @@ -369,13 +372,7 @@ Loader { localMediaMsgItem.contentWidth = width } - HoverHandler { - target : parent - onHoveredChanged: { - localMediaMsgItem.hoveredLink = hovered ? animatedImg.source : "" - } - cursorShape: Qt.PointingHandCursor - } + Component.onCompleted: localMediaMsgItem.bubble.imgSource = source LinearGradient { id: gradient @@ -410,6 +407,8 @@ Loader { asynchronous: true source: Body !== undefined ? UtilsAdapter.urlFromLocalPath(Body) : '' + Component.onCompleted: localMediaMsgItem.bubble.imgSource = source + // The sourceSize represents the maximum source dimensions. // This should not be a dynamic binding, as property changes // (resizing the chat view) here will trigger a reload of the image. @@ -447,13 +446,6 @@ Loader { radius: msgRadius } } - HoverHandler { - target : parent - onHoveredChanged: { - localMediaMsgItem.hoveredLink = hovered ? img.source : "" - } - cursorShape: Qt.PointingHandCursor - } LinearGradient { id: gradient diff --git a/src/app/commoncomponents/SBSMessageBase.qml b/src/app/commoncomponents/SBSMessageBase.qml index 39e059c82..5ddd9dd91 100644 --- a/src/app/commoncomponents/SBSMessageBase.qml +++ b/src/app/commoncomponents/SBSMessageBase.qml @@ -63,7 +63,7 @@ Control { property real maxMsgWidth: root.width - senderMargin - 2 * hPadding - avatarBlockWidth property bool bigMsg - property bool imageTooSmall: false + property bool timeUnderBubble: false // If the ListView attached properties are not available, // then the root delegate is likely a Loader. @@ -205,7 +205,16 @@ Control { RowLayout { id: msgRowlayout - Layout.preferredHeight: innerContent.height + root.extraHeight + (emojiReactions.emojis === "" ? 0 : emojiReactions.height - 8) + ((IsEmojiOnly && (root.seq === MsgSeq.last || root.seq === MsgSeq.single) && emojiReactions.emojis === "") || root.imageTooSmall ? 15 : 0) + Layout.preferredHeight: { + var h = innerContent.height + root.extraHeight; + if (emojiReactions.emojis !== "") + h += emojiReactions.height - 8; + if ((IsEmojiOnly && (root.seq === MsgSeq.last || root.seq === MsgSeq.single) && emojiReactions.emojis === "")) + h += 15; + if (root.timeUnderBubble) + h += 25; + return h; + } Layout.topMargin: ((seq === MsgSeq.first || seq === MsgSeq.single) && !root.isReply) ? 3.5 : 0 Layout.bottomMargin: root.bigMsg ? timestampItem.timeLabel.height : 0 @@ -343,27 +352,39 @@ Control { property real timePosition: JamiTheme.emojiMargins + emojiReactions.width + 8 property alias timestampItem: timestampItem + property bool bubbleHovered + property string imgSource width: (Type === Interaction.Type.TEXT ? root.textContentWidth : innerContent.childrenRect.width) height: innerContent.childrenRect.height + (visible ? root.extraHeight : 0) + (root.bigMsg ? 15 : 0) + HoverHandler { + target: root + enabled: Type === Interaction.Type.DATA_TRANSFER + onHoveredChanged: { + root.hoveredLink = enabled && hovered ? bubble.imgSource : "" + } + } + TimestampInfo { id: timestampItem showTime: IsEmojiOnly && !(root.seq === MsgSeq.last || root.seq === MsgSeq.single) ? false : true formattedTime: root.formattedTime - timeColor: IsEmojiOnly || root.imageTooSmall? (JamiTheme.darkTheme ? "white" : "dark") : (UtilsAdapter.luma(bubble.color) ? "white" : "dark") + timeColor: IsEmojiOnly || root.timeUnderBubble? (JamiTheme.darkTheme ? "white" : "dark") : (UtilsAdapter.luma(bubble.color) ? "white" : "dark") timeLabel.opacity: 0.5 anchors.bottom: parent.bottom anchors.right: IsEmojiOnly ? (isOutgoing ? parent.right : undefined) : parent.right - anchors.left: ((IsEmojiOnly|| root.imageTooSmall) && !isOutgoing) ? parent.left : undefined + anchors.left: ((IsEmojiOnly|| root.timeUnderBubble) && !isOutgoing) ? parent.left : undefined anchors.leftMargin: (IsEmojiOnly && !isOutgoing && emojiReactions.visible) ? bubble.timePosition : 0 - anchors.rightMargin: IsEmojiOnly ? ((isOutgoing && emojiReactions.visible) ? bubble.timePosition : 0) : (root.imageTooSmall ? 0 : 10) + anchors.rightMargin: IsEmojiOnly ? ((isOutgoing && emojiReactions.visible) ? bubble.timePosition : 0) : (root.timeUnderBubble ? 0 : 10) timeLabel.Layout.bottomMargin: { - if (IsEmojiOnly || root.imageTooSmall) + if (IsEmojiOnly) return -15; + if (root.timeUnderBubble) + return -20; if (root.bigMsg || bubble.isDeleted) return 5; return 9; @@ -418,6 +439,7 @@ Control { } } property bool bubbleHovered: containsMouse || textHovered + cursorShape: enabled ? Qt.PointingHandCursor : Qt.ArrowCursor } } -- GitLab