This commit is contained in:
defnax 2025-07-08 12:41:15 +00:00 committed by GitHub
commit 0aab883ff9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 33 additions and 3 deletions

View file

@ -1737,9 +1737,11 @@ void ChatWidget::fileHashingFinished(QList<HashedFile> hashedFiles)
if (!image.isEmpty()) { if (!image.isEmpty()) {
message += QString("<img src=\"%1\">").arg(image); message += QString("<img src=\"%1\">").arg(image);
} }
}
}
message += link.toHtmlSize(); message += link.toHtmlSize();
} else {
message += "<br>" + link.toHtmlSize();
}
}
if (it != hashedFiles.end()) { if (it != hashedFiles.end()) {
message += "<BR>"; message += "<BR>";

View file

@ -560,11 +560,39 @@ void CreateGxsForumMsg::fileHashingFinished(QList<HashedFile> hashedFiles)
QList<HashedFile>::iterator it; QList<HashedFile>::iterator it;
for (it = hashedFiles.begin(); it != hashedFiles.end(); ++it) { for (it = hashedFiles.begin(); it != hashedFiles.end(); ++it) {
HashedFile& hashedFile = *it; HashedFile& hashedFile = *it;
QString ext = QFileInfo(hashedFile.filename).suffix().toUpper();
RetroShareLink link = RetroShareLink::createFile(hashedFile.filename, hashedFile.size, RetroShareLink link = RetroShareLink::createFile(hashedFile.filename, hashedFile.size,
QString::fromStdString(hashedFile.hash.toStdString())); QString::fromStdString(hashedFile.hash.toStdString()));
bool preview = false;
if(hashedFiles.size()==1 && (ext == "JPG" || ext == "PNG" || ext == "JPEG" || ext == "GIF" || ext == "WEBP"))
{
QString encodedImage;
uint32_t maxImageSize = 32000;
if (link.valid()){
if (RsHtml::makeEmbeddedImage(hashedFile.filepath, encodedImage, 320*240, maxImageSize - 200 - link.toHtmlSize().length()))
{ QTextDocumentFragment fragment = QTextDocumentFragment::fromHtml(encodedImage);
ui.forumMessage->textCursor().insertFragment(fragment);
preview=true;
}
}
}
if(!preview)
{
QString image = FilesDefs::getImageFromFilename(hashedFile.filename, false);
if (!image.isEmpty()) {
mesgString += QString("<img src=\"%1\">").arg(image);
}
if (link.valid()) { if (link.valid()) {
mesgString += link.toHtmlSize() + "<br>"; mesgString += link.toHtmlSize() + "<br>";
} }
} else {
if (link.valid()) {
mesgString += "<br>" + link.toHtmlSize() + "<br>";
}
}
} }
if (!mesgString.isEmpty()) { if (!mesgString.isEmpty()) {