From 99017adc1d3610f959f0c0587324cbaa7c012bf6 Mon Sep 17 00:00:00 2001 From: miruka Date: Mon, 20 Jul 2020 23:09:28 -0400 Subject: [PATCH] Model item events: add a media_http_url field --- TODO.md | 1 + src/backend/matrix_client.py | 1 + src/backend/models/items.py | 1 + src/backend/nio_callbacks.py | 5 ++++- src/gui/Pages/Chat/Timeline/EventDelegate.qml | 7 +------ 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/TODO.md b/TODO.md index a5f813b7..55cffb93 100644 --- a/TODO.md +++ b/TODO.md @@ -1,6 +1,7 @@ # TODO - Image viewer: + - room avatar change event: test open, open externally, copy url & path - open externally in context menu in timeline thumbnail, also button - hflickable: support kinetic scrolling disabler diff --git a/src/backend/matrix_client.py b/src/backend/matrix_client.py index 978599eb..31685822 100644 --- a/src/backend/matrix_client.py +++ b/src/backend/matrix_client.py @@ -838,6 +838,7 @@ class MatrixClient(nio.AsyncClient): inline_content = content["body"], media_url = url, + media_http_url = await self.mxc_to_http(url), media_title = path.name, media_width = content["info"].get("w", 0), media_height = content["info"].get("h", 0), diff --git a/src/backend/models/items.py b/src/backend/models/items.py index 5f0793cd..cb5943ed 100644 --- a/src/backend/models/items.py +++ b/src/backend/models/items.py @@ -280,6 +280,7 @@ class Event(ModelItem): source: Optional[nio.Event] = None media_url: str = "" + media_http_url: str = "" media_title: str = "" media_width: int = 0 media_height: int = 0 diff --git a/src/backend/nio_callbacks.py b/src/backend/nio_callbacks.py index 190d8503..b12cb049 100644 --- a/src/backend/nio_callbacks.py +++ b/src/backend/nio_callbacks.py @@ -209,6 +209,7 @@ class NioCallbacks: inline_content = ev.body, media_url = ev.url, + media_http_url = await self.client.mxc_to_http(ev.url), media_title = ev.body, media_width = info.get("w") or 0, media_height = info.get("h") or 0, @@ -615,8 +616,10 @@ class NioCallbacks: else: co = "%1 removed the room's picture" + http = await self.client.mxc_to_http(ev.avatar_url) + await self.client.register_nio_event( - room, ev, content=co, media_url=ev.avatar_url, + room, ev, content=co, media_url=ev.avatar_url, media_http_url=http, ) diff --git a/src/gui/Pages/Chat/Timeline/EventDelegate.qml b/src/gui/Pages/Chat/Timeline/EventDelegate.qml index 82aee287..06bdf4ad 100644 --- a/src/gui/Pages/Chat/Timeline/EventDelegate.qml +++ b/src/gui/Pages/Chat/Timeline/EventDelegate.qml @@ -199,12 +199,7 @@ HColumnLayout { qsTr("Copy audio address") visible: Boolean(text) - onTriggered: py.callClientCoro( - chat.userId, - "mxc_to_http", - [contextMenu.media[1]], - httpUrl => Clipboard.text = httpUrl, - ) + onTriggered: Clipboard.text = model.media_http_url } HMenuItem {