diff --git a/imports/NeoChat/Component/FullScreenImage.qml b/imports/NeoChat/Component/FullScreenImage.qml index e22eeb67d..c4d5fe39c 100644 --- a/imports/NeoChat/Component/FullScreenImage.qml +++ b/imports/NeoChat/Component/FullScreenImage.qml @@ -9,8 +9,8 @@ import org.kde.kirigami 2.15 as Kirigami ApplicationWindow { id: root + property alias source: image.source property string filename - property url localPath property string blurhash: "" property int imageWidth: -1 property int imageHeight: -1 @@ -45,8 +45,6 @@ ApplicationWindow { fillMode: Image.PreserveAspectFit - source: localPath - Image { anchors.centerIn: parent width: image.width diff --git a/imports/NeoChat/Component/Timeline/ImageDelegate.qml b/imports/NeoChat/Component/Timeline/ImageDelegate.qml index da91f4433..06f4f60fb 100644 --- a/imports/NeoChat/Component/Timeline/ImageDelegate.qml +++ b/imports/NeoChat/Component/Timeline/ImageDelegate.qml @@ -35,9 +35,9 @@ TimelineContainer { innerObject: Image { id: img - Layout.maximumWidth: imageDelegate.bubbleMaxWidth - source: "image://mxc/" + mediaId + Layout.maximumHeight: imageDelegate.bubbleMaxWidth / imageDelegate.info.w * imageDelegate.info.h + source: model.mediaUrl Image { anchors.fill: parent @@ -95,7 +95,7 @@ TimelineContainer { onTapped: { fullScreenImage.createObject(parent, { filename: eventId, - localPath: currentRoom.urlToDownload(eventId), + source: model.mediaUrl, blurhash: model.content.info["xyz.amorgan.blurhash"], imageWidth: content.info.w, imageHeight: content.info.h diff --git a/imports/NeoChat/Component/Timeline/VideoDelegate.qml b/imports/NeoChat/Component/Timeline/VideoDelegate.qml index 092d7414d..99d720c25 100644 --- a/imports/NeoChat/Component/Timeline/VideoDelegate.qml +++ b/imports/NeoChat/Component/Timeline/VideoDelegate.qml @@ -55,14 +55,6 @@ TimelineContainer { fillMode: VideoOutput.PreserveAspectFit - Component.onCompleted: { - if (downloaded) { - source = progressInfo.localPath - } else { - source = currentRoom.urlToMxcUrl(content.url) - } - } - onDurationChanged: { if (!duration) { vid.supportStreaming = false; diff --git a/imports/NeoChat/Dialog/UserDetailDialog.qml b/imports/NeoChat/Dialog/UserDetailDialog.qml index 289b8c937..f5b574b2c 100644 --- a/imports/NeoChat/Dialog/UserDetailDialog.qml +++ b/imports/NeoChat/Dialog/UserDetailDialog.qml @@ -52,7 +52,7 @@ Kirigami.OverlaySheet { onClicked: { if (avatarMediaId) { - fullScreenImage.createObject(parent, {"filename": displayName, "localPath": room.urlToMxcUrl(avatarUrl)}).showFullScreen() + fullScreenImage.createObject(parent, {"filename": displayName, "source": room.urlToMxcUrl(avatarUrl)}).showFullScreen() } } } diff --git a/src/messageeventmodel.cpp b/src/messageeventmodel.cpp index cf2ce1ea0..5e9726fe1 100644 --- a/src/messageeventmodel.cpp +++ b/src/messageeventmodel.cpp @@ -54,6 +54,7 @@ QHash MessageEventModel::roleNames() const roles[MimeTypeRole] = "mimeType"; roles[FormattedBodyRole] = "formattedBody"; roles[AuthorIdRole] = "authorId"; + roles[MediaUrlRole] = "mediaUrl"; return roles; } @@ -772,6 +773,23 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const return evt.senderId(); } + if (role == MediaUrlRole) { +#ifdef QUOTIENT_07 + if (auto e = eventCast(&evt)) { + if (!e->hasFileContent()) { + return QVariant(); + } + if (e->content()->originalJson.contains(QStringLiteral("file")) && e->content()->originalJson["file"].toObject().contains(QStringLiteral("url"))) { + return m_currentRoom->makeMediaUrl(e->id(), e->content()->originalJson["file"]["url"].toString()); + } + if (e->content()->originalJson.contains(QStringLiteral("url"))) { + return m_currentRoom->makeMediaUrl(e->id(), e->content()->originalJson["url"].toString()); + } + } +#endif + return m_currentRoom->urlToDownload(evt.id()); + } + return {}; } diff --git a/src/messageeventmodel.h b/src/messageeventmodel.h index cc8388fd1..4f2b33349 100644 --- a/src/messageeventmodel.h +++ b/src/messageeventmodel.h @@ -44,7 +44,7 @@ public: IsEditedRole, SourceRole, - + MediaUrlRole, // For debugging EventResolvedTypeRole, AuthorIdRole, diff --git a/src/neochatroom.cpp b/src/neochatroom.cpp index d22617228..fb8c3f6b1 100644 --- a/src/neochatroom.cpp +++ b/src/neochatroom.cpp @@ -311,7 +311,11 @@ QVariantMap NeoChatRoom::getUser(const QString &userID) const QUrl NeoChatRoom::urlToMxcUrl(const QUrl &mxcUrl) { +#ifdef QUOTIENT_07 + return connection()->makeMediaUrl(mxcUrl); +#else return DownloadFileJob::makeRequestUrl(connection()->homeserver(), mxcUrl); +#endif } QString NeoChatRoom::avatarMediaId() const