fix(@desktop/chat): Downlaoding/Copying an image from chat crashes the app

The issue was caused because the data being passed to the UI is now a URL and not image data.

Added support to download/copy image by URL

fixes #5194
This commit is contained in:
Khushboo Mehta 2022-03-29 00:16:56 +02:00 committed by Khushboo-dev-cpp
parent f1493df8c3
commit 4b9b93a873
5 changed files with 14 additions and 8 deletions

View File

@ -105,9 +105,15 @@ QtObject:
proc copyImageToClipboard*(self: Utils, content: string) {.slot.} = proc copyImageToClipboard*(self: Utils, content: string) {.slot.} =
setClipBoardImage(content) setClipBoardImage(content)
proc copyImageToClipboardByUrl*(self: Utils, url: string) {.slot.} =
setClipBoardImageByUrl(url)
proc downloadImage*(self: Utils, content: string, path: string) {.slot.} = proc downloadImage*(self: Utils, content: string, path: string) {.slot.} =
downloadImage(content, path) downloadImage(content, path)
proc downloadImageByUrl*(self: Utils, url: string, path: string) {.slot.} =
downloadImageByUrl(url, path)
proc generateQRCodeSVG*(self: Utils, text: string, border: int = 0): string = proc generateQRCodeSVG*(self: Utils, text: string, border: int = 0): string =
var qr0: array[0..qrcodegen_BUFFER_LEN_MAX, uint8] var qr0: array[0..qrcodegen_BUFFER_LEN_MAX, uint8]
var tempBuffer: array[0..qrcodegen_BUFFER_LEN_MAX, uint8] var tempBuffer: array[0..qrcodegen_BUFFER_LEN_MAX, uint8]

View File

@ -167,12 +167,12 @@ QtObject {
globalUtilsInst.copyToClipboard(text) globalUtilsInst.copyToClipboard(text)
} }
function copyImageToClipboard(content) { function copyImageToClipboardByUrl(content) {
globalUtilsInst.copyImageToClipboard(content) globalUtilsInst.copyImageToClipboardByUrl(content)
} }
function downloadImage(content, path) { function downloadImageByUrl(url, path) {
globalUtilsInst.downloadImage(content, path) globalUtilsInst.downloadImageByUrl(url, path)
} }
function isCurrentUser(pubkey) { function isCurrentUser(pubkey) {

View File

@ -141,7 +141,7 @@ StatusPopupMenu {
text: qsTr("Copy image") text: qsTr("Copy image")
onTriggered: { onTriggered: {
if (root.imageSource) { if (root.imageSource) {
root.store.copyImageToClipboard(root.imageSource) root.store.copyImageToClipboardByUrl(root.imageSource)
} }
root.close() root.close()
} }
@ -324,7 +324,7 @@ StatusPopupMenu {
modality: Qt.NonModal modality: Qt.NonModal
onAccepted: { onAccepted: {
if (root.imageSource) { if (root.imageSource) {
root.store.downloadImage(root.imageSource, fileDialog.fileUrls) root.store.downloadImageByUrl(root.imageSource, fileDialog.fileUrls)
} }
fileDialog.close() fileDialog.close()
} }

2
vendor/DOtherSide vendored

@ -1 +1 @@
Subproject commit 676b1d9bc8a3b0d6e87d10f0ac7b5deff626266f Subproject commit 7c9d386121d18a2deb8943286a6980a62d1f7b91

2
vendor/nimqml vendored

@ -1 +1 @@
Subproject commit eb20a5ffb964507e508bfaa120c71f7c81c5cf8e Subproject commit d1b79f8a4c0d35e5b7accd4620c727dabfa0b223