diff --git a/src/python/backend.py b/src/python/backend.py index 6acd3bc8..7ed4b776 100644 --- a/src/python/backend.py +++ b/src/python/backend.py @@ -138,6 +138,11 @@ class Backend: return hsluv.hsluv_to_rgb([hue, saturation, lightness]) + @staticmethod + async def mxc_to_http(mxc: str) -> Optional[str]: + return nio.Api.mxc_to_http(mxc) + + @staticmethod async def check_exported_keys_passphrase(file_path: str, passphrase: str, ) -> Union[bool, Tuple[str, bool]]: diff --git a/src/qml/Base/HMxcImage.qml b/src/qml/Base/HMxcImage.qml index 9148984f..29d8f476 100644 --- a/src/qml/Base/HMxcImage.qml +++ b/src/qml/Base/HMxcImage.qml @@ -3,10 +3,18 @@ import QtQuick 2.12 HImage { id: image source: sourceOverride || (show ? cachedPath : "") - onMxcChanged: Qt.callLater(update) onWidthChanged: Qt.callLater(update) onHeightChanged: Qt.callLater(update) onVisibleChanged: Qt.callLater(update) + onMxcChanged: { + Qt.callLater(update) + + if (mxc.startsWith("mxc://")) { + py.callCoro("mxc_to_http", [mxc], http => { httpUrl = http || "" }) + } else { + httpUrl = mxc + } + } property string clientUserId @@ -16,6 +24,7 @@ HImage { property bool show: false property string cachedPath: "" + property string httpUrl: "" function update() { diff --git a/src/qml/Chat/Timeline/EventImage.qml b/src/qml/Chat/Timeline/EventImage.qml index 123c9e63..6fc6f653 100644 --- a/src/qml/Chat/Timeline/EventImage.qml +++ b/src/qml/Chat/Timeline/EventImage.qml @@ -11,23 +11,24 @@ HMxcImage { Utils.urlExtension(loader.mediaUrl) === "gif" clientUserId: chatPage.userId thumbnail: ! animated - mxc: thumbnail ? (loader.thumbnailMxc || loader.mediaUrl) : openUrl + mxc: thumbnail ? + (loader.thumbnailMxc || loader.mediaUrl) : + (loader.mediaUrl || loader.thumbnailMxc) property EventMediaLoader loader - readonly property url openUrl: loader.mediaUrl || loader.thumbnailMxc TapHandler { - onTapped: if (! image.animated) Qt.openUrlExternally(openUrl) - onDoubleTapped: Qt.openUrlExternally(openUrl) + onTapped: if (! image.animated) Qt.openUrlExternally(image.httpUrl) + onDoubleTapped: Qt.openUrlExternally(image.httpUrl) } HoverHandler { id: hover onHoveredChanged: eventDelegate.hoveredMediaTypeUrl = - hovered ? [EventDelegate.Media.Image, openUrl] : [] + hovered ? [EventDelegate.Media.Image, image.httpUrl] : [] } EventImageTextBubble {