From 0ea5d48385d206ead9c51c70bb65c5ff4a9d0281 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sat, 19 Aug 2023 14:04:19 -0400 Subject: [PATCH] Add support for xyz.amorgan.blurhash in ImageContent This adds an optional key to ImageContent, for displaying a blurhash on the client before an image is loaded. --- Quotient/events/eventcontent.cpp | 5 ++++- Quotient/events/eventcontent.h | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Quotient/events/eventcontent.cpp b/Quotient/events/eventcontent.cpp index 5c9f5ed6e..f5a8c7cbe 100644 --- a/Quotient/events/eventcontent.cpp +++ b/Quotient/events/eventcontent.cpp @@ -82,9 +82,10 @@ ImageInfo::ImageInfo(const QFileInfo& fi, QSize imageSize) ImageInfo::ImageInfo(FileSourceInfo sourceInfo, qint64 fileSize, const QMimeType& type, QSize imageSize, - const QString& originalFilename) + const QString& originalFilename, const QString &imageBlurhash) : FileInfo(std::move(sourceInfo), fileSize, type, originalFilename) , imageSize(imageSize) + , blurhash(imageBlurhash) {} ImageInfo::ImageInfo(FileSourceInfo sourceInfo, const QJsonObject& infoJson, @@ -100,6 +101,8 @@ QJsonObject Quotient::EventContent::toInfoJson(const ImageInfo& info) infoJson.insert(QStringLiteral("w"), info.imageSize.width()); if (info.imageSize.height() != -1) infoJson.insert(QStringLiteral("h"), info.imageSize.height()); + if (!info.blurhash.isEmpty()) + infoJson.insert(QStringLiteral("xyz.amorgan.blurhash"), info.blurhash); return infoJson; } diff --git a/Quotient/events/eventcontent.h b/Quotient/events/eventcontent.h index 8ce99282b..0668af87c 100644 --- a/Quotient/events/eventcontent.h +++ b/Quotient/events/eventcontent.h @@ -126,11 +126,13 @@ struct QUOTIENT_API ImageInfo : public FileInfo { explicit ImageInfo(const QFileInfo& fi, QSize imageSize = {}); explicit ImageInfo(FileSourceInfo sourceInfo, qint64 fileSize = -1, const QMimeType& type = {}, QSize imageSize = {}, - const QString& originalFilename = {}); + const QString& originalFilename = {}, + const QString& imageBlurhash = {}); ImageInfo(FileSourceInfo sourceInfo, const QJsonObject& infoJson, const QString& originalFilename = {}); QSize imageSize; + QString blurhash; }; QUOTIENT_API QJsonObject toInfoJson(const ImageInfo& info);