diff --git a/src/qml/Chat/Timeline/EventFile.qml b/src/qml/Chat/Timeline/EventFile.qml index 9eca6376..1ae404e6 100644 --- a/src/qml/Chat/Timeline/EventFile.qml +++ b/src/qml/Chat/Timeline/EventFile.qml @@ -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" diff --git a/src/qml/Chat/Timeline/EventMediaLoader.qml b/src/qml/Chat/Timeline/EventMediaLoader.qml index d3f6c1f2..3c9f6765 100644 --- a/src/qml/Chat/Timeline/EventMediaLoader.qml +++ b/src/qml/Chat/Timeline/EventMediaLoader.qml @@ -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 }