2019-09-03 03:04:57 -04:00
|
|
|
import QtQuick 2.12
|
|
|
|
import "../../Base"
|
2019-09-19 15:49:29 -04:00
|
|
|
import "../../utils.js" as Utils
|
2019-09-03 03:04:57 -04:00
|
|
|
|
2019-11-04 07:00:28 -04:00
|
|
|
HMxcImage {
|
2019-09-03 03:04:57 -04:00
|
|
|
id: image
|
2019-11-05 09:19:48 -04:00
|
|
|
width: fitSize.width
|
|
|
|
height: fitSize.height
|
2019-11-11 05:34:46 -04:00
|
|
|
|
2019-10-27 13:26:00 -04:00
|
|
|
horizontalAlignment: Image.AlignLeft
|
2019-10-30 09:21:58 -04:00
|
|
|
animated: loader.singleMediaInfo.media_mime === "image/gif" ||
|
|
|
|
Utils.urlExtension(loader.mediaUrl) === "gif"
|
2019-11-04 07:00:28 -04:00
|
|
|
clientUserId: chatPage.userId
|
2019-11-06 06:34:52 -04:00
|
|
|
thumbnail: ! animated && loader.thumbnailMxc
|
2019-11-04 10:46:06 -04:00
|
|
|
mxc: thumbnail ?
|
|
|
|
(loader.thumbnailMxc || loader.mediaUrl) :
|
|
|
|
(loader.mediaUrl || loader.thumbnailMxc)
|
2019-11-04 14:37:25 -04:00
|
|
|
cryptDict: thumbnail && loader.thumbnailMxc ?
|
|
|
|
loader.singleMediaInfo.thumbnail_crypt_dict :
|
|
|
|
loader.singleMediaInfo.media_crypt_dict
|
2019-09-03 03:04:57 -04:00
|
|
|
|
2019-09-14 01:03:56 -04:00
|
|
|
|
2019-10-30 09:21:58 -04:00
|
|
|
property EventMediaLoader loader
|
2019-11-04 14:56:53 -04:00
|
|
|
readonly property bool isEncrypted: ! Utils.isEmptyObject(cryptDict)
|
|
|
|
readonly property string openUrl: isEncrypted ? cachedPath : image.httpUrl
|
2019-09-14 01:03:56 -04:00
|
|
|
|
2019-11-05 09:19:48 -04: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 01:03:56 -04:00
|
|
|
|
2019-09-03 03:04:57 -04:00
|
|
|
TapHandler {
|
2019-11-04 14:56:53 -04:00
|
|
|
onTapped: if (! image.animated) Qt.openUrlExternally(openUrl)
|
|
|
|
onDoubleTapped: Qt.openUrlExternally(openUrl)
|
2019-09-03 03:04:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
HoverHandler {
|
|
|
|
id: hover
|
2019-09-06 17:21:41 -04:00
|
|
|
onHoveredChanged:
|
2019-09-14 18:33:32 -04:00
|
|
|
eventDelegate.hoveredMediaTypeUrl =
|
2019-11-04 14:56:53 -04:00
|
|
|
hovered ? [EventDelegate.Media.Image, openUrl] : []
|
2019-09-03 03:04:57 -04:00
|
|
|
}
|
2019-10-30 09:21:58 -04: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-06 16:11:12 -04:00
|
|
|
text: [loader.showDate, loader.showLocalEcho].join(" ").trim()
|
2019-11-06 09:48:27 -04:00
|
|
|
textFormat: Text.StyledText
|
2019-10-30 09:21:58 -04:00
|
|
|
}
|
2019-09-03 03:04:57 -04:00
|
|
|
}
|