Bring back EventFile (also for video/audio for now)
This commit is contained in:
parent
bca73c13b8
commit
4b76725006
|
@ -3,24 +3,22 @@ import QtQuick.Layouts 1.12
|
||||||
import "../../Base"
|
import "../../Base"
|
||||||
|
|
||||||
HTile {
|
HTile {
|
||||||
onLeftClicked: Qt.openUrlExternally(fileUrl)
|
onLeftClicked: Qt.openUrlExternally(loader.mediaUrl)
|
||||||
onRightClicked: eventDelegate.openContextMenu()
|
onRightClicked: eventDelegate.openContextMenu()
|
||||||
|
|
||||||
|
// TODO: have the right URL, not mxc
|
||||||
onHoveredChanged:
|
onHoveredChanged:
|
||||||
eventDelegate.hoveredMediaTypeUrl =
|
eventDelegate.hoveredMediaTypeUrl =
|
||||||
hovered ? [EventDelegate.Media.File, fileUrl] : []
|
hovered ? [EventDelegate.Media.File, loader.mediaUrl] : []
|
||||||
|
|
||||||
|
|
||||||
property url thumbnailUrl
|
property EventMediaLoader loader
|
||||||
property url fileUrl
|
|
||||||
property string fileTitle: ""
|
|
||||||
property int fileSize: 0
|
|
||||||
|
|
||||||
|
|
||||||
title.text: fileTitle || qsTr("Untitled file")
|
title.text: loader.singleMediaInfo.media_title || qsTr("Untitled file")
|
||||||
title.elide: Text.ElideMiddle
|
title.elide: Text.ElideMiddle
|
||||||
|
|
||||||
subtitle.text: CppUtils.formattedBytes(fileSize)
|
subtitle.text: CppUtils.formattedBytes(loader.singleMediaInfo.media_size)
|
||||||
|
|
||||||
image: HIcon {
|
image: HIcon {
|
||||||
svgName: "download"
|
svgName: "download"
|
||||||
|
|
|
@ -29,13 +29,15 @@ HLoader {
|
||||||
]
|
]
|
||||||
|
|
||||||
readonly property int type: {
|
readonly property int type: {
|
||||||
let main_type = singleMediaInfo.media_mime.split("/")[0].toLowerCase()
|
let mainType = singleMediaInfo.media_mime.split("/")[0].toLowerCase()
|
||||||
|
|
||||||
if (main_type === "image") return EventDelegate.Media.Image
|
if (mainType === "image") return EventDelegate.Media.Image
|
||||||
if (main_type === "video") return EventDelegate.Media.Video
|
if (mainType === "video") return EventDelegate.Media.Video
|
||||||
if (main_type === "audio") return EventDelegate.Media.Audio
|
if (mainType === "audio") return EventDelegate.Media.Audio
|
||||||
|
|
||||||
if (singleMediaInfo.event_type === "RoomMessageFile")
|
let fileEvents = ["RoomMessageFile", "RoomEncryptedFile"]
|
||||||
|
|
||||||
|
if (fileEvents.includes(singleMediaInfo.event_type))
|
||||||
return EventDelegate.Media.File
|
return EventDelegate.Media.File
|
||||||
|
|
||||||
// If this is a preview for a link in a normal message
|
// If this is a preview for a link in a normal message
|
||||||
|
@ -49,28 +51,16 @@ HLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly property string thumbnailMxc: singleMediaInfo.thumbnail_url
|
readonly property string thumbnailMxc: singleMediaInfo.thumbnail_url
|
||||||
|
Component.onCompleted: if (singleMediaInfo.media_title.includes("i3-gaps"))
|
||||||
|
Utils.debug(this)
|
||||||
|
|
||||||
|
|
||||||
onTypeChanged: {
|
onTypeChanged: {
|
||||||
if (type === EventDelegate.Media.Image) {
|
if (type === EventDelegate.Media.Image) {
|
||||||
var file = "EventImage.qml"
|
var file = "EventImage.qml"
|
||||||
|
|
||||||
// } else if (type === EventDelegate.Media.File) {
|
} else if (type !== EventDelegate.Media.Page) {
|
||||||
// var file = "EventFile.qml"
|
var file = "EventFile.qml"
|
||||||
// var props = {
|
|
||||||
// thumbnailMxc: thumbnailMxc,
|
|
||||||
// fileUrl: mediaUrl,
|
|
||||||
// fileTitle: info.media_title,
|
|
||||||
// fileSize: info.media_size,
|
|
||||||
// }
|
|
||||||
|
|
||||||
// } else if (type === EventDelegate.Media.Video) {
|
|
||||||
// var file = "EventVideo.qml"
|
|
||||||
// var props = { source: mediaUrl }
|
|
||||||
|
|
||||||
// } else if (type === EventDelegate.Media.Audio) {
|
|
||||||
// var file = "EventAudio.qml"
|
|
||||||
// var props = { source: mediaUrl }
|
|
||||||
|
|
||||||
} else { return }
|
} else { return }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user