Added patch from braindead

Embedded images in private chat and messages (only for QT version 4.7.0 and higher)

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5569 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-09-18 22:59:23 +00:00
parent 4d452b4034
commit 02892d4ae5
7 changed files with 3524 additions and 159 deletions

View file

@ -30,6 +30,7 @@
#include <QTextStream>
#include <QTextCodec>
#include <QTimer>
#include <QTextDocumentFragment>
#include "ChatWidget.h"
#include "ui_ChatWidget.h"
@ -117,7 +118,8 @@ ChatWidget::ChatWidget(QWidget *parent) :
ui->chatTextEdit->installEventFilter(this);
#ifdef RS_RELEASE_VERSION
#if QT_VERSION < 0x040700
// embedded images are not supported before QT 4.7.0
ui->attachPictureButton->setVisible(false);
#endif
@ -585,7 +587,11 @@ void ChatWidget::addExtraPicture()
// select a picture file
QString file;
if (misc::getOpenFileName(window(), RshareSettings::LASTDIR_IMAGES, tr("Load Picture File"), "Pictures (*.png *.xpm *.jpg)", file)) {
ui->hashBox->addAttachments(QStringList(file), HashedFile::Picture);
QString encodedImage;
if (RsHtml::makeEmbeddedImage(file, encodedImage, 640*480)) {
QTextDocumentFragment fragment = QTextDocumentFragment::fromHtml(encodedImage);
ui->chatTextEdit->textCursor().insertFragment(fragment);
}
}
}