Enabled 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@6083 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2013-01-22 00:14:10 +00:00
parent a2a27a874f
commit 138a35b2a2
3 changed files with 24 additions and 24 deletions

View File

@ -118,10 +118,10 @@ ChatWidget::ChatWidget(QWidget *parent) :
ui->chatTextEdit->installEventFilter(this);
//#if QT_VERSION < 0x040700
#if QT_VERSION < 0x040700
// embedded images are not supported before QT 4.7.0
ui->attachPictureButton->setVisible(false);
//#endif
#endif
resetStatusBar();
}

View File

@ -33,11 +33,11 @@ bool MimeTextEdit::canInsertFromMimeData(const QMimeData* source) const
{
#if QT_VERSION >= 0x040700
// embedded images are not supported before QT 4.7.0
// if (source != NULL) {
// if (source->hasImage()) {
// return true;
// }
// }
if (source != NULL) {
if (source->hasImage()) {
return true;
}
}
#endif
return QTextEdit::canInsertFromMimeData(source);
@ -47,20 +47,20 @@ void MimeTextEdit::insertFromMimeData(const QMimeData* source)
{
#if QT_VERSION >= 0x040700
// embedded images are not supported before QT 4.7.0
// if (source != NULL) {
// if (source->hasImage()) {
// // insert as embedded image
// QImage image = qvariant_cast<QImage>(source->imageData());
// if (image.isNull() == false) {
// QString encodedImage;
// if (RsHtml::makeEmbeddedImage(image, encodedImage, 640*480)) {
// QTextDocumentFragment fragment = QTextDocumentFragment::fromHtml(encodedImage);
// this->textCursor().insertFragment(fragment);
// return;
// }
// }
// }
// }
if (source != NULL) {
if (source->hasImage()) {
// insert as embedded image
QImage image = qvariant_cast<QImage>(source->imageData());
if (image.isNull() == false) {
QString encodedImage;
if (RsHtml::makeEmbeddedImage(image, encodedImage, 640*480)) {
QTextDocumentFragment fragment = QTextDocumentFragment::fromHtml(encodedImage);
this->textCursor().insertFragment(fragment);
return;
}
}
}
}
#endif
return QTextEdit::insertFromMimeData(source);

View File

@ -310,10 +310,10 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WFlags flags)
ui.hashBox->setDropWidget(this);
ui.hashBox->setAutoHide(true);
//#if QT_VERSION < 0x040700
// embedded images are not supported before QT 4.7.0
#if QT_VERSION < 0x040700
// embedded images are not supported before QT 4.7.0
ui.imagebtn->setVisible(false);
//#endif
#endif
/* Hide platform specific features */
#ifdef Q_WS_WIN