TempInfo Messageeventmodel
Further improvements to the handling of `mediaInfo` in `messageeventmodel`. `blurhash` and `thumbnailInfo` are now replaced with a single `tempInfo` object that contains a single temp source. The priority is thumbnail > `blurhash` > empty if none exist. Fixes network/neochat#235
This commit is contained in:
committed by
Tobias Fella
parent
20443ba59f
commit
b82d3ab5ad
@@ -1150,14 +1150,19 @@ QVariantMap MessageEventModel::getMediaInfoFromFileInfo(const EventContent::File
|
||||
mediaInfo["height"] = castInfo->imageSize.height();
|
||||
|
||||
if (!isThumbnail) {
|
||||
mediaInfo["thumbnailInfo"] = getMediaInfoFromFileInfo(castInfo->thumbnailInfo(), eventId, true);
|
||||
}
|
||||
|
||||
QString blurhash = castInfo->originalInfoJson["xyz.amorgan.blurhash"].toString();
|
||||
if (blurhash.isEmpty()) {
|
||||
mediaInfo["blurhash"] = QUrl();
|
||||
} else {
|
||||
mediaInfo["blurhash"] = QUrl("image://blurhash/" + blurhash);
|
||||
QVariantMap tempInfo;
|
||||
auto thumbnailInfo = getMediaInfoFromFileInfo(castInfo->thumbnailInfo(), eventId, true);
|
||||
if (thumbnailInfo["source"].toUrl().scheme() == "mxc") {
|
||||
tempInfo = thumbnailInfo;
|
||||
} else {
|
||||
QString blurhash = castInfo->originalInfoJson["xyz.amorgan.blurhash"].toString();
|
||||
if (blurhash.isEmpty()) {
|
||||
tempInfo["source"] = QUrl();
|
||||
} else {
|
||||
tempInfo["source"] = QUrl("image://blurhash/" + blurhash);
|
||||
}
|
||||
}
|
||||
mediaInfo["tempInfo"] = tempInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1168,7 +1173,19 @@ QVariantMap MessageEventModel::getMediaInfoFromFileInfo(const EventContent::File
|
||||
mediaInfo["duration"] = castInfo->duration;
|
||||
|
||||
if (!isThumbnail) {
|
||||
mediaInfo["thumbnailInfo"] = getMediaInfoFromFileInfo(castInfo->thumbnailInfo(), eventId, true);
|
||||
QVariantMap tempInfo;
|
||||
auto thumbnailInfo = getMediaInfoFromFileInfo(castInfo->thumbnailInfo(), eventId, true);
|
||||
if (thumbnailInfo["source"].toUrl().scheme() == "mxc") {
|
||||
tempInfo = thumbnailInfo;
|
||||
} else {
|
||||
QString blurhash = castInfo->originalInfoJson["xyz.amorgan.blurhash"].toString();
|
||||
if (blurhash.isEmpty()) {
|
||||
tempInfo["source"] = QUrl();
|
||||
} else {
|
||||
tempInfo["source"] = QUrl("image://blurhash/" + blurhash);
|
||||
}
|
||||
}
|
||||
mediaInfo["tempInfo"] = tempInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ Components.AlbumMaximizeComponent {
|
||||
Components.AlbumModelItem {
|
||||
type: root.modelData.delegateType === MessageEventModel.Image || root.modelData.delegateType === MessageEventModel.Sticker ? Components.AlbumModelItem.Image : Components.AlbumModelItem.Video
|
||||
source: root.modelData.delegateType === MessageEventModel.Video ? modelData.progressInfo.localPath : modelData.mediaInfo.source
|
||||
tempSource: modelData.mediaInfo.blurhash
|
||||
tempSource: modelData.mediaInfo.tempInfo.source
|
||||
caption: modelData.display
|
||||
}
|
||||
]
|
||||
|
||||
@@ -74,7 +74,7 @@ TimelineContainer {
|
||||
|
||||
Image {
|
||||
anchors.fill: parent
|
||||
source: model.mediaInfo.blurhash
|
||||
source: model.mediaInfo.tempInfo.source
|
||||
visible: parent.status !== Image.Ready
|
||||
}
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ TimelineContainer {
|
||||
anchors.fill: parent
|
||||
visible: false
|
||||
|
||||
source: model.mediaInfo.thumbnailInfo.source
|
||||
source: model.mediaInfo.tempInfo.source
|
||||
fillMode: Image.PreserveAspectFit
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user