Play m.image events GIFs, rename some properties
This commit is contained in:
parent
b11c9d5675
commit
2e4a7904d5
|
@ -13,7 +13,7 @@ Image {
|
|||
|
||||
property bool animate: true
|
||||
|
||||
readonly property bool animated: Utils.urlExtension(image.source) == "gif"
|
||||
property bool animated: Utils.urlExtension(image.source) === "gif"
|
||||
readonly property alias loadingLabel: loadingLabel
|
||||
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ HRowLayout {
|
|||
model: eventDelegate.currentItem.links
|
||||
|
||||
EventMediaLoader {
|
||||
info: eventDelegate.currentItem
|
||||
singleMediaInfo: eventDelegate.currentItem
|
||||
mediaUrl: modelData
|
||||
|
||||
transform: Translate { x: xOffset }
|
||||
|
@ -151,12 +151,12 @@ HRowLayout {
|
|||
|
||||
Layout.minimumWidth:
|
||||
type === EventDelegate.Media.Image ?
|
||||
(info.media_width ||
|
||||
(singleMediaInfo.media_width ||
|
||||
(item ? item.loadingLabel.implicitWidth : -1)) : -1
|
||||
|
||||
Layout.minimumHeight:
|
||||
type === EventDelegate.Media.Image ?
|
||||
(info.media_height ||
|
||||
(singleMediaInfo.media_height ||
|
||||
(item ? item.loadingLabel.implicitHeight : -1)) : -1
|
||||
|
||||
// Layout.minimumWidth:
|
||||
|
|
|
@ -6,21 +6,24 @@ HImage {
|
|||
id: image
|
||||
horizontalAlignment: Image.AlignLeft
|
||||
sourceSize.width: theme.chat.message.thumbnailWidth // FIXME
|
||||
source: animated ? openUrl : thumbnailUrl
|
||||
|
||||
|
||||
// source = thumbnail, fullSource = full original image
|
||||
property url fullSource: source
|
||||
property url thumbnailUrl
|
||||
property url fullImageUrl
|
||||
|
||||
readonly property url openUrl: fullImageUrl || thumbnailUrl
|
||||
|
||||
|
||||
TapHandler {
|
||||
onTapped: if (! image.animated) Qt.openUrlExternally(fullSource)
|
||||
onDoubleTapped: Qt.openUrlExternally(fullSource)
|
||||
onTapped: if (! image.animated) Qt.openUrlExternally(openUrl)
|
||||
onDoubleTapped: Qt.openUrlExternally(openUrl)
|
||||
}
|
||||
|
||||
HoverHandler {
|
||||
id: hover
|
||||
onHoveredChanged:
|
||||
eventDelegate.hoveredMediaTypeUrl =
|
||||
hovered ? [EventDelegate.Media.Image, fullSource] : []
|
||||
hovered ? [EventDelegate.Media.Image, openUrl] : []
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ HLoader {
|
|||
x: eventContent.spacing
|
||||
|
||||
|
||||
property QtObject info
|
||||
property QtObject singleMediaInfo
|
||||
property url mediaUrl
|
||||
|
||||
readonly property var imageExtensions: [
|
||||
|
@ -26,15 +26,16 @@ HLoader {
|
|||
]
|
||||
|
||||
readonly property int type: {
|
||||
let main_type = info.media_mime.split("/")[0].toLowerCase()
|
||||
let main_type = singleMediaInfo.media_mime.split("/")[0].toLowerCase()
|
||||
|
||||
if (main_type === "image") return EventDelegate.Media.Image
|
||||
if (main_type === "video") return EventDelegate.Media.Video
|
||||
if (main_type === "audio") return EventDelegate.Media.Audio
|
||||
|
||||
if (info.event_type === "RoomMessageFile")
|
||||
if (singleMediaInfo.event_type === "RoomMessageFile")
|
||||
return EventDelegate.Media.File
|
||||
|
||||
// If this is a preview for a link in a normal message
|
||||
let ext = Utils.urlExtension(mediaUrl)
|
||||
|
||||
if (imageExtensions.includes(ext)) return EventDelegate.Media.Image
|
||||
|
@ -47,15 +48,19 @@ HLoader {
|
|||
readonly property url previewUrl: (
|
||||
type === EventDelegate.Media.File ||
|
||||
type === EventDelegate.Media.Image ?
|
||||
info.thumbnail_url : ""
|
||||
singleMediaInfo.thumbnail_url : ""
|
||||
) || mediaUrl
|
||||
|
||||
|
||||
onPreviewUrlChanged: {
|
||||
print( mediaUrl)
|
||||
if (type === EventDelegate.Media.Image) {
|
||||
var file = "EventImage.qml"
|
||||
var props = { source: previewUrl, fullSource: mediaUrl }
|
||||
var props = {
|
||||
thumbnailUrl: previewUrl,
|
||||
fullImageUrl: mediaUrl,
|
||||
animated: singleMediaInfo.media_mime === "image/gif" ||
|
||||
Utils.urlExtension(mediaUrl) === "gif",
|
||||
}
|
||||
|
||||
// } else if (type === EventDelegate.Media.File) {
|
||||
// var file = "EventFile.qml"
|
||||
|
|
Loading…
Reference in New Issue
Block a user