fix(chat): fix copy and download image

Fixes #4494
This commit is contained in:
Jonathan Rainville 2022-01-19 10:59:08 -05:00 committed by Sale Djenic
parent ddfa3d3e4e
commit d073dd215a
10 changed files with 33 additions and 7 deletions

View File

@ -92,6 +92,12 @@ QtObject:
proc copyToClipboard*(self: Utils, content: string) {.slot.} =
setClipBoardText(content)
proc copyImageToClipboard*(self: Utils, content: string) {.slot.} =
setClipBoardImage(content)
proc downloadImage*(self: Utils, content: string, path: string) {.slot.} =
downloadImage(content, path)
proc generateQRCodeSVG*(self: Utils, text: string, border: int = 0): string =
var qr0: array[0..qrcodegen_BUFFER_LEN_MAX, uint8]
var tempBuffer: array[0..qrcodegen_BUFFER_LEN_MAX, uint8]

View File

@ -170,6 +170,7 @@ StatusAppThreePanelLayout {
MessageContextMenuView {
id: quickActionMessageOptionsMenu
store: root.rootStore
onOpenProfileClicked: {
Global.openProfilePopup(publicKey)

View File

@ -180,7 +180,7 @@ StatusModal {
//% "Pinned messages"
text: qsTrId("pinned-messages")
currentValue: pinnedCount
onClicked: Global.openPopup(pinnedMessagesPopupComponent)
onClicked: Global.openPopup(pinnedMessagesPopupComponent, {store: popup.store})
iconSource: Style.svg("pin")
}

View File

@ -19,6 +19,7 @@ import StatusQ.Controls 0.1 as StatusQControls
ModalPopup {
id: popup
property var store
property var messageStore
property var pinnedMessagesModel //this doesn't belong to the messageStore, it is a part of the ChatContentStore, but we didn't introduce it yet.
property string messageToPin
@ -167,6 +168,7 @@ ModalPopup {
MessageContextMenuView {
id: msgContextMenu
reactionModel: popup.emojiReactionsModel
store: popup.store
pinnedPopup: true
pinnedMessage: true
onShouldCloseParentPopup: {

View File

@ -103,6 +103,14 @@ QtObject {
globalUtilsInst.copyToClipboard(text)
}
function copyImageToClipboard(content) {
globalUtilsInst.copyImageToClipboard(content)
}
function downloadImage(content, path) {
globalUtilsInst.downloadImage(content, path)
}
function getCommunity(communityId) {
// Not Refactored Yet
// try {

View File

@ -133,6 +133,7 @@ Item {
MessageContextMenuView {
id: contextmenu
store: root.rootStore
reactionModel: root.rootStore.emojiReactionsModel
}

View File

@ -84,6 +84,7 @@ ColumnLayout {
return
}
Global.openPopup(pinnedMessagesPopupComponent, {
store: rootStore,
messageStore: messageStore,
pinnedMessagesModel: chatContentModule.pinnedMessagesModel,
messageToPin: ""
@ -228,6 +229,7 @@ ColumnLayout {
return
}
Global.openPopup(pinnedMessagesPopupComponent, {
store: rootStore,
messageStore: messageStore,
pinnedMessagesModel: chatContentModule.pinnedMessagesModel,
messageToPin: ""
@ -307,6 +309,7 @@ ColumnLayout {
MessageContextMenuView {
id: contextmenu
store: chatContentRoot.rootStore
reactionModel: chatContentRoot.rootStore.emojiReactionsModel
onPinMessage: {
messageStore.pinMessage(messageId)
@ -322,6 +325,7 @@ ColumnLayout {
return
}
Global.openPopup(pinnedMessagesPopupComponent, {
store: rootStore,
messageStore: messageStore,
pinnedMessagesModel: chatContentModule.pinnedMessagesModel,
messageToPin: messageId

View File

@ -326,6 +326,7 @@ Item {
chatCommunitySectionModule.prepareChatContentModuleForChatId(chatId)
let chatContentModule = chatCommunitySectionModule.getChatContentModule()
Global.openPopup(pinnedMessagesPopupComponent, {
store: root.store,
messageStore: messageStore,
pinnedMessagesModel: chatContentModule.pinnedMessagesModel,
messageToPin: ""

View File

@ -301,6 +301,7 @@ Item {
chatCommunitySectionModule.prepareChatContentModuleForChatId(chatId)
let chatContentModule = chatCommunitySectionModule.getChatContentModule()
Global.openPopup(pinnedMessagesPopupComponent, {
store: root.store,
messageStore: messageStore,
pinnedMessagesModel: chatContentModule.pinnedMessagesModel,
messageToPin: ""

View File

@ -18,6 +18,7 @@ StatusPopupMenu {
id: root
width: emojiContainer.visible ? emojiContainer.width : 176
property var store
property var reactionModel
property alias emojiContainer: emojiContainer
@ -173,8 +174,9 @@ StatusPopupMenu {
id: copyImageAction
text: qsTr("Copy image")
onTriggered: {
// Not Refactored Yet - Should be in GlobalUtils
// root.store.chatsModelInst.copyImageToClipboard(imageSource ? imageSource : "")
if (root.imageSource) {
root.store.copyImageToClipboard(root.imageSource)
}
root.close()
}
icon.name: "copy"
@ -248,8 +250,7 @@ StatusPopupMenu {
icon.name: "chat"
enabled: root.isDebugEnabled
onTriggered: {
// Not Refactored Yet - Should be in GlobalUtils
// root.store.chatsModelInst.copyToClipboard(SelectedMessage.messageId)
root.store.copyToClipboard(SelectedMessage.messageId)
close()
}
}
@ -353,8 +354,9 @@ StatusPopupMenu {
selectFolder: true
modality: Qt.NonModal
onAccepted: {
// Not Refactored Yet - Should be in GlobalUtils
// root.store.chatsModelInst.downloadImage(imageSource ? imageSource : "", fileDialog.fileUrls)
if (root.imageSource) {
root.store.downloadImage(root.imageSource, fileDialog.fileUrls)
}
fileDialog.close()
}
onRejected: {