From cb4c6cb677004cd760ae180f534af356ebe409a4 Mon Sep 17 00:00:00 2001 From: Andreas Gattringer Date: Mon, 15 Jul 2024 17:24:48 +0200 Subject: [PATCH] Audio filename, caption and seeking - display caption independent of filename (consistancy to File) - fix audio seeking not working - change two comments and a variable name --- src/eventhandler.cpp | 4 ++-- src/models/messagecontentmodel.cpp | 1 + src/timeline/AudioComponent.qml | 10 +++------- src/timeline/FileComponent.qml | 7 +------ 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/eventhandler.cpp b/src/eventhandler.cpp index 44749b101..ae18ecb70 100644 --- a/src/eventhandler.cpp +++ b/src/eventhandler.cpp @@ -246,9 +246,9 @@ QString EventHandler::rawMessageBody(const Quotient::RoomMessageEvent &event) if (event.hasFileContent()) { // if filename is given or body is equal to filename, // then body is a caption - QString fileName = event.content()->fileInfo()->originalName; + QString filename = event.content()->fileInfo()->originalName; QString body = event.plainBody(); - if (fileName.isEmpty() || fileName == body) { + if (filename.isEmpty() || filename == body) { return QString(); } return body; diff --git a/src/models/messagecontentmodel.cpp b/src/models/messagecontentmodel.cpp index b8788ef8c..b30103a0d 100644 --- a/src/models/messagecontentmodel.cpp +++ b/src/models/messagecontentmodel.cpp @@ -482,6 +482,7 @@ QList MessageContentModel::componentsForType(MessageComponentT return components; } case MessageComponentType::Image: + case MessageComponentType::Audio: case MessageComponentType::Video: { if (!m_event->is()) { const auto event = eventCast(m_event); diff --git a/src/timeline/AudioComponent.qml b/src/timeline/AudioComponent.qml index fee3a6017..355e2035e 100644 --- a/src/timeline/AudioComponent.qml +++ b/src/timeline/AudioComponent.qml @@ -28,11 +28,6 @@ ColumnLayout { */ required property string eventId - /** - * @brief The display text of the message. - */ - required property string display - /** * @brief The media info for the event. * @@ -44,6 +39,7 @@ ColumnLayout { * - width - The width in pixels of the audio media. * - height - The height in pixels of the audio media. * - tempInfo - mediaInfo (with the same properties as this except no tempInfo) for a temporary image while the file downloads. + * - filename - original filename of the media */ required property var mediaInfo @@ -138,7 +134,7 @@ ColumnLayout { id: playButton } QQC2.Label { - text: root.display + text: root.mediaInfo.filename wrapMode: Text.Wrap Layout.fillWidth: true } @@ -159,7 +155,7 @@ ColumnLayout { from: 0 to: audio.duration value: audio.position - onMoved: audio.seek(value) + onMoved: audio.setPosition(value) } QQC2.Label { diff --git a/src/timeline/FileComponent.qml b/src/timeline/FileComponent.qml index 1bbfe2021..7e8322113 100644 --- a/src/timeline/FileComponent.qml +++ b/src/timeline/FileComponent.qml @@ -29,11 +29,6 @@ ColumnLayout { */ required property string eventId - /** - * @brief The display text of the message. - */ - required property string display - /** * @brief The media info for the event. * @@ -45,7 +40,7 @@ ColumnLayout { * - width - The width in pixels of the audio media. * - height - The height in pixels of the audio media. * - tempInfo - mediaInfo (with the same properties as this except no tempInfo) for a temporary image while the file downloads. - * - filename + * - filename - original filename of the media */ required property var mediaInfo