mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-20 21:29:01 -04:00
Merge d3071e8fe2
into c3640306bd
This commit is contained in:
commit
0aab883ff9
2 changed files with 33 additions and 3 deletions
|
@ -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>";
|
||||||
|
|
|
@ -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()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue