Bring back EventFile (also for video/audio for now)

This commit is contained in:
miruka 2019-11-11 05:26:32 -04:00
parent bca73c13b8
commit 4b76725006
2 changed files with 17 additions and 29 deletions

View File

@ -3,24 +3,22 @@ import QtQuick.Layouts 1.12
import "../../Base"
HTile {
onLeftClicked: Qt.openUrlExternally(fileUrl)
onLeftClicked: Qt.openUrlExternally(loader.mediaUrl)
onRightClicked: eventDelegate.openContextMenu()
// TODO: have the right URL, not mxc
onHoveredChanged:
eventDelegate.hoveredMediaTypeUrl =
hovered ? [EventDelegate.Media.File, fileUrl] : []
hovered ? [EventDelegate.Media.File, loader.mediaUrl] : []
property url thumbnailUrl
property url fileUrl
property string fileTitle: ""
property int fileSize: 0
property EventMediaLoader loader
title.text: fileTitle || qsTr("Untitled file")
title.text: loader.singleMediaInfo.media_title || qsTr("Untitled file")
title.elide: Text.ElideMiddle
subtitle.text: CppUtils.formattedBytes(fileSize)
subtitle.text: CppUtils.formattedBytes(loader.singleMediaInfo.media_size)
image: HIcon {
svgName: "download"

View File

@ -29,13 +29,15 @@ HLoader {
]
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 (main_type === "video") return EventDelegate.Media.Video
if (main_type === "audio") return EventDelegate.Media.Audio
if (mainType === "image") return EventDelegate.Media.Image
if (mainType === "video") return EventDelegate.Media.Video
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
// If this is a preview for a link in a normal message
@ -49,28 +51,16 @@ HLoader {
}
readonly property string thumbnailMxc: singleMediaInfo.thumbnail_url
Component.onCompleted: if (singleMediaInfo.media_title.includes("i3-gaps"))
Utils.debug(this)
onTypeChanged: {
if (type === EventDelegate.Media.Image) {
var file = "EventImage.qml"
// } else if (type === EventDelegate.Media.File) {
// 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 if (type !== EventDelegate.Media.Page) {
var file = "EventFile.qml"
} else { return }