Fix copying images
This commit is contained in:
committed by
Tobias Fella
parent
648796b9e0
commit
ef4f11546f
@@ -1290,33 +1290,36 @@ void NeoChatRoom::openEventMediaExternally(const QString &eventId)
|
|||||||
void NeoChatRoom::copyEventMedia(const QString &eventId)
|
void NeoChatRoom::copyEventMedia(const QString &eventId)
|
||||||
{
|
{
|
||||||
const auto evtIt = findInTimeline(eventId);
|
const auto evtIt = findInTimeline(eventId);
|
||||||
if (evtIt != messageEvents().rend() && is<RoomMessageEvent>(**evtIt)) {
|
|
||||||
const auto event = evtIt->viewAs<RoomMessageEvent>();
|
if (evtIt == messageEvents().rend() || !is<RoomMessageEvent>(**evtIt)) {
|
||||||
if (event->has<EventContent::FileContent>()) {
|
return;
|
||||||
const auto transferInfo = fileTransferInfo(eventId);
|
}
|
||||||
if (transferInfo.completed()) {
|
const auto event = evtIt->viewAs<RoomMessageEvent>();
|
||||||
Clipboard clipboard;
|
if (!event->has<EventContent::FileContentBase>()) {
|
||||||
clipboard.setImage(transferInfo.localPath);
|
return;
|
||||||
} else {
|
}
|
||||||
downloadFile(eventId,
|
const auto transferInfo = fileTransferInfo(eventId);
|
||||||
QUrl(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + u'/'
|
if (transferInfo.completed()) {
|
||||||
+ event->id().replace(u':', u'_').replace(u'/', u'_').replace(u'+', u'_') + fileNameToDownload(eventId)));
|
Clipboard clipboard;
|
||||||
connect(
|
clipboard.setImage(transferInfo.localPath);
|
||||||
this,
|
} else {
|
||||||
&Room::fileTransferCompleted,
|
downloadFile(eventId,
|
||||||
this,
|
QUrl(u"file:"_s + QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + u'/'
|
||||||
[this, eventId](QString id, QUrl localFile, FileSourceInfo fileMetadata) {
|
+ event->id().replace(u':', u'_').replace(u'/', u'_').replace(u'+', u'_') + fileNameToDownload(eventId)));
|
||||||
Q_UNUSED(localFile);
|
connect(
|
||||||
Q_UNUSED(fileMetadata);
|
this,
|
||||||
if (id == eventId) {
|
&Room::fileTransferCompleted,
|
||||||
auto transferInfo = fileTransferInfo(eventId);
|
this,
|
||||||
Clipboard clipboard;
|
[this, eventId](QString id, QUrl localFile, FileSourceInfo fileMetadata) {
|
||||||
clipboard.setImage(transferInfo.localPath);
|
Q_UNUSED(localFile);
|
||||||
}
|
Q_UNUSED(fileMetadata);
|
||||||
},
|
if (id == eventId) {
|
||||||
static_cast<Qt::ConnectionType>(Qt::SingleShotConnection));
|
auto transferInfo = fileTransferInfo(eventId);
|
||||||
}
|
Clipboard clipboard;
|
||||||
}
|
clipboard.setImage(transferInfo.localPath);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Qt::SingleShotConnection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user