2019-09-03 17:04:57 +10:00
|
|
|
import QtQuick 2.12
|
|
|
|
import "../../Base"
|
2019-09-20 05:49:29 +10:00
|
|
|
import "../../utils.js" as Utils
|
2019-09-03 17:04:57 +10:00
|
|
|
|
2019-11-04 22:00:28 +11:00
|
|
|
HMxcImage {
|
2019-09-03 17:04:57 +10:00
|
|
|
id: image
|
2019-11-06 00:19:48 +11:00
|
|
|
width: fitSize.width
|
|
|
|
height: fitSize.height
|
2019-11-11 20:34:46 +11:00
|
|
|
|
2019-10-28 04:26:00 +11:00
|
|
|
horizontalAlignment: Image.AlignLeft
|
2019-10-31 00:21:58 +11:00
|
|
|
animated: loader.singleMediaInfo.media_mime === "image/gif" ||
|
|
|
|
Utils.urlExtension(loader.mediaUrl) === "gif"
|
2019-11-04 22:00:28 +11:00
|
|
|
clientUserId: chatPage.userId
|
2019-11-06 21:34:52 +11:00
|
|
|
thumbnail: ! animated && loader.thumbnailMxc
|
2019-11-05 01:46:06 +11:00
|
|
|
mxc: thumbnail ?
|
|
|
|
(loader.thumbnailMxc || loader.mediaUrl) :
|
|
|
|
(loader.mediaUrl || loader.thumbnailMxc)
|
2019-11-05 05:37:25 +11:00
|
|
|
cryptDict: thumbnail && loader.thumbnailMxc ?
|
|
|
|
loader.singleMediaInfo.thumbnail_crypt_dict :
|
|
|
|
loader.singleMediaInfo.media_crypt_dict
|
2019-09-03 17:04:57 +10:00
|
|
|
|
2019-09-14 15:03:56 +10:00
|
|
|
|
2019-10-31 00:21:58 +11:00
|
|
|
property EventMediaLoader loader
|
2019-11-05 05:56:53 +11:00
|
|
|
readonly property bool isEncrypted: ! Utils.isEmptyObject(cryptDict)
|
|
|
|
readonly property string openUrl: isEncrypted ? cachedPath : image.httpUrl
|
2019-09-14 15:03:56 +10:00
|
|
|
|
2019-11-06 00:19:48 +11:00
|
|
|
readonly property size fitSize: Utils.fitSize(
|
|
|
|
// Minimum display size
|
|
|
|
192,
|
|
|
|
192,
|
|
|
|
|
|
|
|
// Real size
|
|
|
|
loader.singleMediaInfo.thumbnail_width ||
|
|
|
|
loader.singleMediaInfo.media_width ||
|
|
|
|
implicitWidth ||
|
|
|
|
800,
|
|
|
|
|
|
|
|
loader.singleMediaInfo.thumbnail_height ||
|
|
|
|
loader.singleMediaInfo.media_height ||
|
|
|
|
implicitHeight ||
|
|
|
|
600,
|
|
|
|
|
|
|
|
// Maximum display size
|
|
|
|
Math.min(eventList.height / 3, eventContent.messageBodyWidth),
|
|
|
|
eventList.height / 3,
|
|
|
|
)
|
|
|
|
|
2019-09-14 15:03:56 +10:00
|
|
|
|
2019-09-03 17:04:57 +10:00
|
|
|
TapHandler {
|
2019-11-05 05:56:53 +11:00
|
|
|
onTapped: if (! image.animated) Qt.openUrlExternally(openUrl)
|
|
|
|
onDoubleTapped: Qt.openUrlExternally(openUrl)
|
2019-09-03 17:04:57 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
HoverHandler {
|
|
|
|
id: hover
|
2019-09-07 07:21:41 +10:00
|
|
|
onHoveredChanged:
|
2019-09-15 08:33:32 +10:00
|
|
|
eventDelegate.hoveredMediaTypeUrl =
|
2019-11-05 05:56:53 +11:00
|
|
|
hovered ? [EventDelegate.Media.Image, openUrl] : []
|
2019-09-03 17:04:57 +10:00
|
|
|
}
|
2019-10-31 00:21:58 +11:00
|
|
|
|
|
|
|
EventImageTextBubble {
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.top: parent.top
|
|
|
|
text: loader.showSender
|
|
|
|
textFormat: Text.StyledText
|
|
|
|
}
|
|
|
|
|
|
|
|
EventImageTextBubble {
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.bottom: parent.bottom
|
2019-11-07 07:11:12 +11:00
|
|
|
text: [loader.showDate, loader.showLocalEcho].join(" ").trim()
|
2019-11-07 00:48:27 +11:00
|
|
|
textFormat: Text.StyledText
|
2019-10-31 00:21:58 +11:00
|
|
|
}
|
2019-09-03 17:04:57 +10:00
|
|
|
}
|