Page MenuHomePhorge

No OneTemporary

Size
4 KB
Referenced Files
None
Subscribers
None
diff --git a/src/contents/ui/event-types/Image.qml b/src/contents/ui/event-types/Image.qml
index 0ed47f1..31e7dc8 100644
--- a/src/contents/ui/event-types/Image.qml
+++ b/src/contents/ui/event-types/Image.qml
@@ -1,91 +1,95 @@
/*
* This file is part of kazv.
* SPDX-FileCopyrightText: 2020-2023 Tusooa Zhu <tusooa@kazv.moe>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import moe.kazv.mxc.kazv 0.0 as MK
import org.kde.kirigami 2.13 as Kirigami
import '.' as Types
import '..' as Kazv
Simple {
id: upper
property var gender: 'neutral'
property var body: event.content.body
- property var thumbnailMxcUri: event.content.info.thumbnail_file.url || event.content.info.thumbnail_url
- property var thumbnailKey: event.content.info.thumbnail_file.key.k || ""
- property var thumbnailIv: event.content.info.thumbnail_file.iv || ""
+ property var thumbnailFile: imageFile.thumbnail_file || {}
+ property var thumbnailInfo: imageInfo.thumbnail_info || {}
+ property var thumbnailMxcUri: thumbnailFile.url || imageInfo.thumbnail_url || ""
+ property var thumbnailKey: thumbnailFile.key ? thumbnailFile.key.k : ""
+ property var thumbnailIv: thumbnailFile.iv || ""
property var thumbnailUri: thumbnailMxcUri ? kazvIOManager.cacheFile(matrixSdk.mxcUriToHttp(thumbnailMxcUri), event.eventId, thumbnailKey, thumbnailIv) : undefined
- property var thumbnailWidth: event.content.info.thumbnail_info.w
- property var thumbnailHeight: event.content.info.thumbnail_info.h
-
- property var imageMxcUri: event.content.file.url || event.content.url
- property var imageKey: event.content.file.key.k || ""
- property var imageIv: event.content.file.iv || ""
+ property var thumbnailWidth: thumbnailInfo.w
+ property var thumbnailHeight: thumbnailInfo.h
+
+ property var imageInfo: event.content.info || {}
+ property var imageFile: event.content.file || {}
+ property var imageMxcUri: imageFile.url || event.content.url
+ property var imageKey: imageFile.key ? imageFile.key.k : ""
+ property var imageIv: imageFile.iv || ""
property var imageUri: thumbnailMxcUri ? matrixSdk.mxcUriToHttp(imageMxcUri) : kazvIOManager.cacheFile(matrixSdk.mxcUriToHttp(imageMxcUri), event.eventId) // If there are no thumbnail, cache the image
- property var imageWidth: event.content.info.w
- property var imageHeight: event.content.info.h
+ property var imageWidth: imageInfo.w
+ property var imageHeight: imageInfo.h
property var previewUri: thumbnailMxcUri ? thumbnailUri : imageUri // Uri for source of Image QML type
property var innerContentWidth: upper.contentMaxWidth - bubble.bubbleSpacing
property var kazvIOJob: thumbnailUri ? kazvIOManager.getDownloadJob(event.eventId) : (imageUri ? kazvIOManager.getDownloadJob(event.eventId) : null) // If the network environment is normal, this property becomes null when the image (or thumbnail) has been cached
Types.MediaBubble {
id: bubble
eventId: event.eventId
serverUrl: upper.imageUri
fileName: body
key: upper.imageKey
iv: upper.imageIv
property var label: Label {
width: contentWidth > innerContentWidth ? innerContentWidth : contentWidth
wrapMode: Text.Wrap
text: l10n.get('event-message-image-sent', { gender, body })
}
property var image: Image {
id: image
source: kazvIOJob ? "" : previewUri
width: calcImageWidth() > innerContentWidth ? innerContentWidth : calcImageWidth()
height: calcImageHeight()
fillMode: Image.PreserveAspectFit
}
Column {
id: layout
width: childrenRect.width > innerContentWidth ? innerContentWidth : childrenRect.width
data: [
bubble.mediaFileMenu,
bubble.label,
bubble.image,
bubble.progressBar
]
}
}
function calcImageWidth() {
const eventSpecWidth = thumbnailMxcUri ? thumbnailWidth : imageWidth
- const width = eventSpecWidth || image.implictWidth
- return width || 1 // lest we divide by 0
+ return eventSpecWidth || image.implicitWidth || 1
}
function calcImageHeight() {
const eventSpecHeight = thumbnailMxcUri ? thumbnailHeight : imageHeight
- const height = eventSpecHeight || image.implictHeight || 1
- if (calcImageWidth() > innerContentWidth) {
+ const height = eventSpecHeight || image.implicitHeight || 1
+ const width = calcImageWidth()
+ if (width > innerContentWidth) {
return height * (innerContentWidth / width)
}
return height
}
}

File Metadata

Mime Type
text/x-diff
Expires
Sun, Jan 19, 8:49 AM (1 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
55044
Default Alt Text
(4 KB)

Event Timeline