From ceef2167fd5709b45738d5a5c0b5b48f1ba14eec Mon Sep 17 00:00:00 2001 From: James Graham Date: Sun, 24 Mar 2024 10:01:41 +0000 Subject: [PATCH] Don't Maximize Stickers Make sure that sticker don't open the maximize component as they aren't in the media model BUG: 482701 --- src/eventhandler.cpp | 8 ++++++-- src/eventhandler.h | 5 ++++- src/timeline/ImageComponent.qml | 13 ++++++++----- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/eventhandler.cpp b/src/eventhandler.cpp index a35f2acd5..4b26411d7 100644 --- a/src/eventhandler.cpp +++ b/src/eventhandler.cpp @@ -656,6 +656,7 @@ QVariantMap EventHandler::getMediaInfoForEvent(const Quotient::RoomEvent *event) // Get the file info for the event. const EventContent::FileInfo *fileInfo; + bool isSticker = false; if (event->is()) { auto roomMessageEvent = eventCast(event); if (!roomMessageEvent->hasFileContent()) { @@ -665,14 +666,15 @@ QVariantMap EventHandler::getMediaInfoForEvent(const Quotient::RoomEvent *event) } else if (event->is()) { auto stickerEvent = eventCast(event); fileInfo = &stickerEvent->image(); + isSticker = true; } else { return {}; } - return getMediaInfoFromFileInfo(fileInfo, eventId); + return getMediaInfoFromFileInfo(fileInfo, eventId, false, isSticker); } -QVariantMap EventHandler::getMediaInfoFromFileInfo(const EventContent::FileInfo *fileInfo, const QString &eventId, bool isThumbnail) const +QVariantMap EventHandler::getMediaInfoFromFileInfo(const EventContent::FileInfo *fileInfo, const QString &eventId, bool isThumbnail, bool isSticker) const { QVariantMap mediaInfo; @@ -699,6 +701,8 @@ QVariantMap EventHandler::getMediaInfoFromFileInfo(const EventContent::FileInfo // Add media size if available. mediaInfo["size"_ls] = fileInfo->payloadSize; + mediaInfo["isSticker"_ls] = isSticker; + // Add parameter depending on media type. if (mimeType.name().contains(QStringLiteral("image"))) { if (auto castInfo = static_cast(fileInfo)) { diff --git a/src/eventhandler.h b/src/eventhandler.h index c6d2da10c..68bbafc9a 100644 --- a/src/eventhandler.h +++ b/src/eventhandler.h @@ -229,6 +229,7 @@ public: * - 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. + * - isSticker - Whether the image is a sticker or not */ QVariantMap getMediaInfo() const; @@ -320,6 +321,7 @@ public: * - 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. + * - isSticker - Whether the image is a sticker or not */ QVariantMap getReplyMediaInfo() const; @@ -405,5 +407,6 @@ private: QString getMessageBody(const Quotient::RoomMessageEvent &event, Qt::TextFormat format, bool stripNewlines) const; QVariantMap getMediaInfoForEvent(const Quotient::RoomEvent *event) const; - QVariantMap getMediaInfoFromFileInfo(const Quotient::EventContent::FileInfo *fileInfo, const QString &eventId, bool isThumbnail = false) const; + QVariantMap + getMediaInfoFromFileInfo(const Quotient::EventContent::FileInfo *fileInfo, const QString &eventId, bool isThumbnail = false, bool isSticker = false) const; }; diff --git a/src/timeline/ImageComponent.qml b/src/timeline/ImageComponent.qml index 20508582a..d66f95272 100644 --- a/src/timeline/ImageComponent.qml +++ b/src/timeline/ImageComponent.qml @@ -47,6 +47,7 @@ Item { * - 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. + * - isSticker - Whether the image is a sticker or not */ required property var mediaInfo @@ -139,11 +140,13 @@ Item { _private.imageItem.paused = true; } root.timeline.interactive = false; - // We need to make sure the index is that of the MediaMessageFilterModel. - if (root.timeline.model instanceof MessageFilterModel) { - RoomManager.maximizeMedia(RoomManager.mediaMessageFilterModel.getRowForSourceItem(root.index)); - } else { - RoomManager.maximizeMedia(root.index); + if (!root.mediaInfo.isSticker) { + // We need to make sure the index is that of the MediaMessageFilterModel. + if (root.timeline.model instanceof MessageFilterModel) { + RoomManager.maximizeMedia(RoomManager.mediaMessageFilterModel.getRowForSourceItem(root.index)); + } else { + RoomManager.maximizeMedia(root.index); + } } } }