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
This commit is contained in:
Andreas Gattringer
2024-07-15 17:24:48 +02:00
parent d574a97a35
commit cb4c6cb677
4 changed files with 7 additions and 15 deletions

View File

@@ -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;

View File

@@ -482,6 +482,7 @@ QList<MessageComponent> MessageContentModel::componentsForType(MessageComponentT
return components;
}
case MessageComponentType::Image:
case MessageComponentType::Audio:
case MessageComponentType::Video: {
if (!m_event->is<StickerEvent>()) {
const auto event = eventCast<const Quotient::RoomMessageEvent>(m_event);

View File

@@ -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 {

View File

@@ -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