From 2c019d984ffc7733aedbffd0f6df1ef5f566f44c Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 13 Jan 2016 00:39:22 -0500 Subject: [PATCH] added load image option in forum posts when images are to be displayed --- .../src/gui/common/RSTextBrowser.cpp | 13 +--- .../gui/gxsforums/GxsForumThreadWidget.cpp | 3 + .../src/gui/gxsforums/GxsForumThreadWidget.ui | 59 +++++++++++++------ 3 files changed, 48 insertions(+), 27 deletions(-) diff --git a/retroshare-gui/src/gui/common/RSTextBrowser.cpp b/retroshare-gui/src/gui/common/RSTextBrowser.cpp index 7571b9b44..20c76703d 100644 --- a/retroshare-gui/src/gui/common/RSTextBrowser.cpp +++ b/retroshare-gui/src/gui/common/RSTextBrowser.cpp @@ -74,27 +74,20 @@ void RSTextBrowser::paintEvent(QPaintEvent *event) QVariant RSTextBrowser::loadResource(int type, const QUrl &name) { - std::cerr << "TEXTBROWSER: load ressource request: type=" << type << " scheme=" << name.scheme().toStdString() << ", url=" << name.toString().toStdString() << std::endl; - // case 1: always trust the image if it comes from an internal resource if(name.scheme().compare("qrc",Qt::CaseInsensitive)==0 && type == QTextDocument::ImageResource) - { - std::cerr << "loading because it's qrc..." << std::endl; return QTextBrowser::loadResource(type, name); - } - // case 2: only display if the ser allows it + // case 2: only display if the user allows it. Data resources can be bad (svg bombs) but we filter them out globally at the network layer. + // It would be good to add here a home-made resource loader that only loads images and not svg crap, just in case. if(name.scheme().compare("data",Qt::CaseInsensitive)==0 && mShowImages) - { - std::cerr << "loading because it's data and mShowImages is true..." << std::endl; return QTextBrowser::loadResource(type, name); - } // case 3: otherwise, do not display - std::cerr << "not loading " << std::endl; + std::cerr << "TEXTBROWSER: refusing load ressource request: type=" << type << " scheme=" << name.scheme().toStdString() << ", url=" << name.toString().toStdString() << std::endl; if (mImageBlockWidget) mImageBlockWidget->show(); diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index 6280f029c..fe2e1aad3 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -213,6 +213,8 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget ui->line_2->hide() ; ui->by_text_label->hide() ; ui->by_label->hide() ; + ui->postText->setImageBlockWidget(ui->imageBlockWidget); + ui->postText->resetImagesStatus(Settings->getForumLoadEmbeddedImages()) ; ui->subscribeToolButton->setToolTip(tr("

Subscribing to the forum will gather \ available posts from your subscribed friends, and make the \ @@ -590,6 +592,7 @@ void GxsForumThreadWidget::changedThread() if (mFillThread) { return; } + ui->postText->resetImagesStatus(Settings->getForumLoadEmbeddedImages()) ; insertMessage(); } diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.ui b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.ui index d7018afd7..f156d3a2c 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.ui +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.ui @@ -6,17 +6,14 @@ 0 0 - 622 - 412 + 851 + 721 Form - - - 0 - + @@ -117,6 +114,12 @@ QSizePolicy::MinimumExpanding + + + 0 + 0 + + @@ -446,21 +449,37 @@ - - - - 0 - 10 - - - - Qt::CustomContextMenu - + + + + + + + 0 + 0 + + + + + + + + + 0 + 10 + + + + Qt::CustomContextMenu + + + + - + :/images/document_save.png:/images/document_save.png @@ -502,6 +521,12 @@

gui/common/ElidedLabel.h
1 + + RSImageBlockWidget + QWidget +
gui/common/RSImageBlockWidget.h
+ 1 +