Copy image to the clipboard
Add a context menu option to save an image in the timeline to the clipboard BUG: 466478
This commit is contained in:
committed by
Tobias Fella
parent
bd4eeb405b
commit
d1f7e7091e
@@ -67,3 +67,15 @@ void Clipboard::saveText(QString message)
|
|||||||
mineData->setText(message.replace(re, ""));
|
mineData->setText(message.replace(re, ""));
|
||||||
m_clipboard->setMimeData(mineData);
|
m_clipboard->setMimeData(mineData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Clipboard::setImage(const QUrl &url)
|
||||||
|
{
|
||||||
|
if (url.isLocalFile()) {
|
||||||
|
QImage img(url.path());
|
||||||
|
auto *mimeData = new QMimeData;
|
||||||
|
mimeData->setImageData(img);
|
||||||
|
if (!img.isNull()) {
|
||||||
|
m_clipboard->setMimeData(mimeData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ public:
|
|||||||
Q_INVOKABLE QString saveImage(QString localPath = {}) const;
|
Q_INVOKABLE QString saveImage(QString localPath = {}) const;
|
||||||
|
|
||||||
Q_INVOKABLE void saveText(QString message);
|
Q_INVOKABLE void saveText(QString message);
|
||||||
|
Q_INVOKABLE void setImage(const QUrl &image);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QClipboard *m_clipboard;
|
QClipboard *m_clipboard;
|
||||||
|
|||||||
@@ -55,6 +55,20 @@ MessageDelegateContextMenu {
|
|||||||
root.closeFullscreen()
|
root.closeFullscreen()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Kirigami.Action {
|
||||||
|
text: i18n("Copy")
|
||||||
|
icon.name: "edit-copy"
|
||||||
|
onTriggered: {
|
||||||
|
if(file.downloaded) {
|
||||||
|
Clipboard.setImage(progressInfo.localPath)
|
||||||
|
} else {
|
||||||
|
file.onDownloadedChanged.connect(function() {
|
||||||
|
Clipboard.setImage(progressInfo.localPath)
|
||||||
|
});
|
||||||
|
currentRoom.downloadFile(eventId, StandardPaths.writableLocation(StandardPaths.CacheLocation) + "/" + eventId.replace(":", "_").replace("/", "_").replace("+", "_") + currentRoom.fileNameToDownload(eventId))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
Kirigami.Action {
|
Kirigami.Action {
|
||||||
visible: author.id === currentRoom.localUser.id || currentRoom.canSendState("redact")
|
visible: author.id === currentRoom.localUser.id || currentRoom.canSendState("redact")
|
||||||
text: i18n("Remove")
|
text: i18n("Remove")
|
||||||
|
|||||||
Reference in New Issue
Block a user