mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-26 01:31:30 -05:00
embed preview for images on file attach in chat
This commit is contained in:
parent
c19919962d
commit
2dc69cb000
@ -1598,7 +1598,7 @@ void ChatWidget::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();
|
QString ext = QFileInfo(hashedFile.filename).suffix().toUpper();
|
||||||
|
|
||||||
RetroShareLink link;
|
RetroShareLink link;
|
||||||
|
|
||||||
@ -1610,11 +1610,25 @@ void ChatWidget::fileHashingFinished(QList<HashedFile> hashedFiles)
|
|||||||
message += QString("<img src=\"file:///%1\" width=\"100\" height=\"100\">").arg(hashedFile.filepath);
|
message += QString("<img src=\"file:///%1\" width=\"100\" height=\"100\">").arg(hashedFile.filepath);
|
||||||
message+="<br>";
|
message+="<br>";
|
||||||
} else {
|
} else {
|
||||||
|
bool preview = false;
|
||||||
|
if(hashedFiles.size()==1 && (ext == "JPG" || ext == "PNG" || ext == "JPEG" || ext == "GIF"))
|
||||||
|
{
|
||||||
|
QString encodedImage;
|
||||||
|
uint32_t maxMessageSize = this->maxMessageSize();
|
||||||
|
if (RsHtml::makeEmbeddedImage(hashedFile.filepath, encodedImage, 640*480, maxMessageSize - 200 - link.toHtmlSize().length()))
|
||||||
|
{ QTextDocumentFragment fragment = QTextDocumentFragment::fromHtml(encodedImage);
|
||||||
|
ui->chatTextEdit->textCursor().insertFragment(fragment);
|
||||||
|
preview=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!preview)
|
||||||
|
{
|
||||||
QString image = FilesDefs::getImageFromFilename(hashedFile.filename, false);
|
QString image = FilesDefs::getImageFromFilename(hashedFile.filename, false);
|
||||||
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();
|
||||||
|
|
||||||
if (it != hashedFiles.end()) {
|
if (it != hashedFiles.end()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user