From 6b1613d8bb4941c215a3d0bd516e872daf616a83 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Mon, 23 Sep 2013 19:53:26 +0000 Subject: [PATCH] - Added blocking of embedded images (+ settings) to forums and messages - Added image support for forum messages - Renamed LinkTextBrowser to RSTextBrowser - Updated english translation git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6752 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- .../FeedReader/gui/FeedReaderMessageWidget.ui | 6 +- plugins/FeedReader/lang/FeedReader_en.ts | 26 +- retroshare-gui/src/gui/ForumsDialog.cpp | 8 + retroshare-gui/src/gui/ForumsDialog.ui | 373 ++++++++++-------- retroshare-gui/src/gui/FriendsDialog.ui | 6 +- retroshare-gui/src/gui/chat/ChatWidget.ui | 6 +- .../src/gui/common/LinkTextBrowser.cpp | 61 --- .../src/gui/common/LinkTextBrowser.h | 24 -- .../src/gui/common/RSImageBlockWidget.cpp | 16 + .../src/gui/common/RSImageBlockWidget.h | 25 ++ .../src/gui/common/RSImageBlockWidget.ui | 133 +++++++ .../src/gui/common/RSTextBrowser.cpp | 126 ++++++ retroshare-gui/src/gui/common/RSTextBrowser.h | 36 ++ .../src/gui/common/UIStateHelper.cpp | 34 +- retroshare-gui/src/gui/common/UIStateHelper.h | 6 +- .../src/gui/connect/ConfCertDialog.ui | 8 +- .../src/gui/forums/CreateForumMsg.cpp | 15 + .../src/gui/forums/CreateForumMsg.h | 1 + .../src/gui/forums/CreateForumMsg.ui | 53 ++- .../src/gui/gxsforums/GxsForumThreadWidget.ui | 6 +- retroshare-gui/src/gui/msgs/MessageWidget.cpp | 4 + retroshare-gui/src/gui/msgs/MessageWidget.ui | 252 ++++++------ .../src/gui/qss/stylesheet/Standard.qss | 8 + retroshare-gui/src/gui/settings/ForumPage.cpp | 2 + retroshare-gui/src/gui/settings/ForumPage.ui | 7 + .../src/gui/settings/MessagePage.cpp | 2 + .../src/gui/settings/MessagePage.ui | 7 + .../src/gui/settings/rsharesettings.cpp | 20 + .../src/gui/settings/rsharesettings.h | 4 + retroshare-gui/src/lang/retroshare_en.ts | 79 +++- retroshare-gui/src/retroshare-gui.pro | 7 +- 31 files changed, 907 insertions(+), 454 deletions(-) delete mode 100644 retroshare-gui/src/gui/common/LinkTextBrowser.cpp delete mode 100644 retroshare-gui/src/gui/common/LinkTextBrowser.h create mode 100644 retroshare-gui/src/gui/common/RSImageBlockWidget.cpp create mode 100644 retroshare-gui/src/gui/common/RSImageBlockWidget.h create mode 100644 retroshare-gui/src/gui/common/RSImageBlockWidget.ui create mode 100644 retroshare-gui/src/gui/common/RSTextBrowser.cpp create mode 100644 retroshare-gui/src/gui/common/RSTextBrowser.h diff --git a/plugins/FeedReader/gui/FeedReaderMessageWidget.ui b/plugins/FeedReader/gui/FeedReaderMessageWidget.ui index 5f5be1353..ba644889f 100644 --- a/plugins/FeedReader/gui/FeedReaderMessageWidget.ui +++ b/plugins/FeedReader/gui/FeedReaderMessageWidget.ui @@ -265,7 +265,7 @@ - + 0 @@ -287,9 +287,9 @@ - LinkTextBrowser + RSTextBrowser QTextBrowser -
gui/common/LinkTextBrowser.h
+
gui/common/RSTextBrowser.h
LineEditClear diff --git a/plugins/FeedReader/lang/FeedReader_en.ts b/plugins/FeedReader/lang/FeedReader_en.ts index e2f7ae14d..48005b236 100644 --- a/plugins/FeedReader/lang/FeedReader_en.ts +++ b/plugins/FeedReader/lang/FeedReader_en.ts @@ -352,59 +352,59 @@ - + No name - + Add new folder - + Please enter a name for the folder - - + + Create folder - - + + Cannot create folder. - + Remove folder - + Remove feed - + Do you want to remove the folder %1? - + Do you want to remove the feed %1? - + Edit folder - + Please enter a new name for the folder diff --git a/retroshare-gui/src/gui/ForumsDialog.cpp b/retroshare-gui/src/gui/ForumsDialog.cpp index 89ceb6e24..8ff18ffd8 100644 --- a/retroshare-gui/src/gui/ForumsDialog.cpp +++ b/retroshare-gui/src/gui/ForumsDialog.cpp @@ -139,6 +139,8 @@ ForumsDialog::ForumsDialog(QWidget *parent) connect(NotifyQt::getInstance(), SIGNAL(forumMsgReadSatusChanged(QString,QString,int)), this, SLOT(forumMsgReadSatusChanged(QString,QString,int))); + ui.postText->setImageBlockWidget(ui.imageBlockWidget); + /* Set initial size the splitter */ QList sizes; sizes << 300 << width(); // Qt calculates the right sizes @@ -888,6 +890,7 @@ void ForumsDialog::insertThreads() ui.newthreadButton->setEnabled (false); ui.postText->clear(); + ui.postText->resetImagesStatus(false); ui.threadTitle->clear(); if (mCurrForumId.empty()) @@ -1133,6 +1136,7 @@ void ForumsDialog::insertPost() if (mCurrForumId.empty()) { ui.postText->setText(""); + ui.postText->resetImagesStatus(false); ui.threadTitle->setText(""); ui.previousButton->setEnabled(false); ui.nextButton->setEnabled(false); @@ -1149,10 +1153,12 @@ void ForumsDialog::insertPost() ForumInfo fi; if (!rsForums->getForumInfo(mCurrForumId, fi)) { ui.postText->setText(""); + ui.postText->resetImagesStatus(false); ui.threadTitle->setText(""); return; } ui.threadTitle->setText(tr("Forum Description")); + ui.postText->resetImagesStatus(false); ui.postText->setText(QString::fromStdWString(fi.forumDesc)); return; } @@ -1177,6 +1183,7 @@ void ForumsDialog::insertPost() ForumMsgInfo msg; if (!rsForums->getForumMessage(mCurrForumId, mCurrThreadId, msg)) { + ui.postText->resetImagesStatus(false); ui.postText->setText(""); return; } @@ -1203,6 +1210,7 @@ void ForumsDialog::insertPost() QString extraTxt = RsHtml().formatText(ui.postText->document(), messageFromInfo(msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS); + ui.postText->resetImagesStatus(Settings->getForumLoadEmbeddedImages()); ui.postText->setHtml(extraTxt); ui.threadTitle->setText(titleFromInfo(msg)); } diff --git a/retroshare-gui/src/gui/ForumsDialog.ui b/retroshare-gui/src/gui/ForumsDialog.ui index 672738739..1b5b86617 100644 --- a/retroshare-gui/src/gui/ForumsDialog.ui +++ b/retroshare-gui/src/gui/ForumsDialog.ui @@ -114,6 +114,92 @@ + + + + + 0 + 0 + + + + QFrame::Box + + + QFrame::Sunken + + + + 2 + + + + + Qt::NoFocus + + + Start new Thread for Selected Forum + + + + :/images/mail_new.png:/images/mail_new.png + + + + 32 + 16 + + + + true + + + + + + + Qt::NoFocus + + + Reply Message + + + + :/images/mail_reply.png:/images/mail_reply.png + + + + 32 + 16 + + + + true + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 40 + 20 + + + + + + + + + + @@ -192,52 +278,38 @@ - - - - - 9 - - - - Qt::CustomContextMenu - - - true - - - true - - - - Title - - - - - - - - - :/images/message-state-header.png:/images/message-state-header.png - - - - - Date - - - - - Author - - - - - Signed - - - + + + + + + + 75 + true + + + + Loading + + + + + + + + 16777215 + 25 + + + + 1000 + + + 0 + + + + @@ -415,140 +487,87 @@ - - + + + + + 9 + + + + Qt::CustomContextMenu + + + true + + + true + + + + Title + + + + + + + + + :/images/message-state-header.png:/images/message-state-header.png + + + + + Date + + + + + Author + + + + + Signed + + + + + + + + + + 2 + + + 0 0 - - QFrame::Box - - - QFrame::Sunken - - - - 2 - - - - - Qt::NoFocus - - - Start new Thread for Selected Forum - - - - :/images/mail_new.png:/images/mail_new.png - - - - 32 - 16 - - - - true - - - - - - - Qt::NoFocus - - - Reply Message - - - - :/images/mail_reply.png:/images/mail_reply.png - - - - 32 - 16 - - - - true - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 40 - 20 - - - - - - - - - - - - - - - 75 - true - - - - Loading - - - - - - - - 16777215 - 25 - - - - 1000 - - - 0 - - - - + + + + + 0 + 10 + + + + + 9 + + + - - - - 0 - 10 - - - - - 9 - - -
@@ -567,6 +586,17 @@ titleBarFrame + + RSTextBrowser + QTextBrowser +
gui/common/RSTextBrowser.h
+
+ + RSImageBlockWidget + QWidget +
gui/common/RSImageBlockWidget.h
+ 1 +
GroupTreeWidget QWidget @@ -578,11 +608,6 @@ QLineEdit
gui/common/LineEditClear.h
- - LinkTextBrowser - QTextBrowser -
gui/common/LinkTextBrowser.h
-
diff --git a/retroshare-gui/src/gui/FriendsDialog.ui b/retroshare-gui/src/gui/FriendsDialog.ui index 8108ed0d1..a2a32f99d 100644 --- a/retroshare-gui/src/gui/FriendsDialog.ui +++ b/retroshare-gui/src/gui/FriendsDialog.ui @@ -656,7 +656,7 @@ false - + 0 @@ -837,9 +837,9 @@ - LinkTextBrowser + RSTextBrowser QTextBrowser -
gui/common/LinkTextBrowser.h
+
gui/common/RSTextBrowser.h
AvatarWidget diff --git a/retroshare-gui/src/gui/chat/ChatWidget.ui b/retroshare-gui/src/gui/chat/ChatWidget.ui index b0ed1e88a..5fc783656 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.ui +++ b/retroshare-gui/src/gui/chat/ChatWidget.ui @@ -212,7 +212,7 @@ border-image: url(:/images/closepressed.png) false - + 0 @@ -707,9 +707,9 @@ border-image: url(:/images/closepressed.png) - LinkTextBrowser + RSTextBrowser QTextBrowser -
gui/common/LinkTextBrowser.h
+
gui/common/RSTextBrowser.h
HashBox diff --git a/retroshare-gui/src/gui/common/LinkTextBrowser.cpp b/retroshare-gui/src/gui/common/LinkTextBrowser.cpp deleted file mode 100644 index 583609c23..000000000 --- a/retroshare-gui/src/gui/common/LinkTextBrowser.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include -#include - -#include "LinkTextBrowser.h" - -LinkTextBrowser::LinkTextBrowser(QWidget *parent) : - QTextBrowser(parent) -{ - setOpenExternalLinks(true); - setOpenLinks(false); - - connect(this, SIGNAL(anchorClicked(QUrl)), this, SLOT(linkClicked(QUrl))); -} - -void LinkTextBrowser::linkClicked(const QUrl &url) -{ - // some links are opened directly in the QTextBrowser with open external links set to true, - // so we handle links by our own - -#ifdef TO_DO - // If we want extra file links to be anonymous, we need to insert the actual source here. - if(url.host() == HOST_EXTRAFILE) - { - std::cerr << "Extra file link detected. Adding parent id " << _target_sslid << " to sourcelist" << std::endl; - - RetroShareLink link ; - link.fromUrl(url) ; - - link.createExtraFile( link.name(),link.size(),link.hash(), _target_ssl_id) ; - - QDesktopServices::openUrl(link.toUrl()); - } - else -#endif - QDesktopServices::openUrl(url); -} - -void LinkTextBrowser::setPlaceholderText(const QString &text) -{ - placeholderText = text; - viewport()->repaint(); -} - -void LinkTextBrowser::paintEvent(QPaintEvent *event) -{ - QTextBrowser::paintEvent(event); - - if (placeholderText.isEmpty() == false && document()->isEmpty()) { - QWidget *vieportWidget = viewport(); - QPainter painter(vieportWidget); - - QPen pen = painter.pen(); - QColor color = pen.color(); - color.setAlpha(128); - pen.setColor(color); - painter.setPen(pen); - - painter.drawText(QRect(QPoint(), vieportWidget->size()), Qt::AlignHCenter | Qt::AlignVCenter | Qt::TextWordWrap, placeholderText); - } -} - diff --git a/retroshare-gui/src/gui/common/LinkTextBrowser.h b/retroshare-gui/src/gui/common/LinkTextBrowser.h deleted file mode 100644 index f0b9e0246..000000000 --- a/retroshare-gui/src/gui/common/LinkTextBrowser.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef LINKTEXTBROWSER_H -#define LINKTEXTBROWSER_H - -#include - -class LinkTextBrowser : public QTextBrowser -{ - Q_OBJECT - -public: - explicit LinkTextBrowser(QWidget *parent = 0); - - void setPlaceholderText(const QString &text); - -private slots: - void linkClicked(const QUrl &url); - -protected: - void paintEvent(QPaintEvent *event); - - QString placeholderText; -}; - -#endif // LINKTEXTBROWSER_H diff --git a/retroshare-gui/src/gui/common/RSImageBlockWidget.cpp b/retroshare-gui/src/gui/common/RSImageBlockWidget.cpp new file mode 100644 index 000000000..8a3c728ee --- /dev/null +++ b/retroshare-gui/src/gui/common/RSImageBlockWidget.cpp @@ -0,0 +1,16 @@ +#include "RSImageBlockWidget.h" +#include "ui_RSImageBlockWidget.h" + +RSImageBlockWidget::RSImageBlockWidget(QWidget *parent) : + QWidget(parent), + ui(new Ui::RSImageBlockWidget) +{ + ui->setupUi(this); + + connect(ui->loadImagesButton, SIGNAL(clicked()), this, SIGNAL(showImages())); +} + +RSImageBlockWidget::~RSImageBlockWidget() +{ + delete ui; +} diff --git a/retroshare-gui/src/gui/common/RSImageBlockWidget.h b/retroshare-gui/src/gui/common/RSImageBlockWidget.h new file mode 100644 index 000000000..4455e7e74 --- /dev/null +++ b/retroshare-gui/src/gui/common/RSImageBlockWidget.h @@ -0,0 +1,25 @@ +#ifndef RSIMAGEBLOCKWIDGET_H +#define RSIMAGEBLOCKWIDGET_H + +#include + +namespace Ui { +class RSImageBlockWidget; +} + +class RSImageBlockWidget : public QWidget +{ + Q_OBJECT + +public: + explicit RSImageBlockWidget(QWidget *parent = 0); + ~RSImageBlockWidget(); + +signals: + void showImages(); + +private: + Ui::RSImageBlockWidget *ui; +}; + +#endif // RSIMAGEBLOCKWIDGET_H diff --git a/retroshare-gui/src/gui/common/RSImageBlockWidget.ui b/retroshare-gui/src/gui/common/RSImageBlockWidget.ui new file mode 100644 index 000000000..f33a346d3 --- /dev/null +++ b/retroshare-gui/src/gui/common/RSImageBlockWidget.ui @@ -0,0 +1,133 @@ + + + RSImageBlockWidget + + + + 0 + 0 + 476 + 37 + + + + Form + + + + 0 + + + 0 + + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 178 + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 178 + + + + + + + + + 255 + 255 + 178 + + + + + + + 255 + 255 + 178 + + + + + + + + true + + + QFrame::Box + + + + 6 + + + + + The loading of embedded images is blocked. + + + + + + + Qt::Horizontal + + + + 162 + 20 + + + + + + + + Load images + + + + + + + + + + + diff --git a/retroshare-gui/src/gui/common/RSTextBrowser.cpp b/retroshare-gui/src/gui/common/RSTextBrowser.cpp new file mode 100644 index 000000000..f423213c6 --- /dev/null +++ b/retroshare-gui/src/gui/common/RSTextBrowser.cpp @@ -0,0 +1,126 @@ +#include +#include + +#include "RSTextBrowser.h" +#include "RSImageBlockWidget.h" + +RSTextBrowser::RSTextBrowser(QWidget *parent) : + QTextBrowser(parent) +{ + setOpenExternalLinks(true); + setOpenLinks(false); + + mShowImages = true; + mImageBlockWidget = NULL; + + connect(this, SIGNAL(anchorClicked(QUrl)), this, SLOT(linkClicked(QUrl))); +} + +void RSTextBrowser::linkClicked(const QUrl &url) +{ + // some links are opened directly in the QTextBrowser with open external links set to true, + // so we handle links by our own + +#ifdef TO_DO + // If we want extra file links to be anonymous, we need to insert the actual source here. + if(url.host() == HOST_EXTRAFILE) + { + std::cerr << "Extra file link detected. Adding parent id " << _target_sslid << " to sourcelist" << std::endl; + + RetroShareLink link ; + link.fromUrl(url) ; + + link.createExtraFile( link.name(),link.size(),link.hash(), _target_ssl_id) ; + + QDesktopServices::openUrl(link.toUrl()); + } + else +#endif + QDesktopServices::openUrl(url); +} + +void RSTextBrowser::setPlaceholderText(const QString &text) +{ + mPlaceholderText = text; + viewport()->repaint(); +} + +void RSTextBrowser::paintEvent(QPaintEvent *event) +{ + QTextBrowser::paintEvent(event); + + if (mPlaceholderText.isEmpty() == false && document()->isEmpty()) { + QWidget *vieportWidget = viewport(); + QPainter painter(vieportWidget); + + QPen pen = painter.pen(); + QColor color = pen.color(); + color.setAlpha(128); + pen.setColor(color); + painter.setPen(pen); + + painter.drawText(QRect(QPoint(), vieportWidget->size()), Qt::AlignHCenter | Qt::AlignVCenter | Qt::TextWordWrap, mPlaceholderText); + } +} + +QVariant RSTextBrowser::loadResource(int type, const QUrl &name) +{ + if (mShowImages || type != QTextDocument::ImageResource || name.scheme().compare("data", Qt::CaseInsensitive) != 0) { + return QTextBrowser::loadResource(type, name); + } + + if (mImageBlockWidget) { + mImageBlockWidget->show(); + } + + return QPixmap(":/trolltech/styles/commonstyle/images/file-16.png"); +} + +void RSTextBrowser::setImageBlockWidget(RSImageBlockWidget *widget) +{ + if (mImageBlockWidget) { + // disconnect + disconnect(mImageBlockWidget, SIGNAL(destroyed()), this, SLOT(destroyImageBlockWidget())); + disconnect(mImageBlockWidget, SIGNAL(showImages()), this, SLOT(showImages())); + } + + mImageBlockWidget = widget; + + if (mImageBlockWidget) { + // connect + connect(mImageBlockWidget, SIGNAL(destroyed()), this, SLOT(destroyImageBlockWidget())); + connect(mImageBlockWidget, SIGNAL(showImages()), this, SLOT(showImages())); + } + + resetImagesStatus(false); +} + +void RSTextBrowser::destroyImageBlockWidget() +{ + mImageBlockWidget = NULL; +} + +void RSTextBrowser::showImages() +{ + if (mImageBlockWidget && sender() == mImageBlockWidget) { + mImageBlockWidget->hide(); + } + + if (mShowImages) { + return; + } + + mShowImages = true; + + QString html = toHtml(); + clear(); + setHtml(html); +} + +void RSTextBrowser::resetImagesStatus(bool load) +{ + if (mImageBlockWidget) { + mImageBlockWidget->hide(); + } + mShowImages = load; +} diff --git a/retroshare-gui/src/gui/common/RSTextBrowser.h b/retroshare-gui/src/gui/common/RSTextBrowser.h new file mode 100644 index 000000000..1c41ba6dd --- /dev/null +++ b/retroshare-gui/src/gui/common/RSTextBrowser.h @@ -0,0 +1,36 @@ +#ifndef RSTEXTBROWSER_H +#define RSTEXTBROWSER_H + +#include + +class RSImageBlockWidget; + +class RSTextBrowser : public QTextBrowser +{ + Q_OBJECT + +public: + explicit RSTextBrowser(QWidget *parent = 0); + + void setPlaceholderText(const QString &text); + void setImageBlockWidget(RSImageBlockWidget *widget); + void resetImagesStatus(bool load); + + virtual QVariant loadResource(int type, const QUrl &name); + +public slots: + void showImages(); + +private slots: + void linkClicked(const QUrl &url); + void destroyImageBlockWidget(); + +protected: + void paintEvent(QPaintEvent *event); + + QString mPlaceholderText; + bool mShowImages; + RSImageBlockWidget *mImageBlockWidget; +}; + +#endif // RSTEXTBROWSER_H diff --git a/retroshare-gui/src/gui/common/UIStateHelper.cpp b/retroshare-gui/src/gui/common/UIStateHelper.cpp index 13ec454e7..0e2226dc7 100644 --- a/retroshare-gui/src/gui/common/UIStateHelper.cpp +++ b/retroshare-gui/src/gui/common/UIStateHelper.cpp @@ -25,7 +25,7 @@ #include "UIStateHelper.h" #include "RSTreeWidget.h" -#include "LinkTextBrowser.h" +#include "RSTextBrowser.h" class UIStateHelperObject { @@ -45,10 +45,10 @@ public: init(); mTreeWidget = widget; } - UIStateHelperObject(LinkTextBrowser *widget) + UIStateHelperObject(RSTextBrowser *widget) { init(); - mLinkTextBrowser = widget; + mRSTextBrowser = widget; } void setPlaceholder(bool loading, const QString &text, bool clear) const @@ -77,12 +77,12 @@ public: mTreeWidget->setPlaceholderText(text); } - if (mLinkTextBrowser) { + if (mRSTextBrowser) { if (loading && clear) { - mLinkTextBrowser->clear(); + mRSTextBrowser->clear(); } - mLinkTextBrowser->setPlaceholderText(text); + mRSTextBrowser->setPlaceholderText(text); } } @@ -100,8 +100,8 @@ public: mTreeWidget->clear(); } - if (mLinkTextBrowser) { - mLinkTextBrowser->clear(); + if (mRSTextBrowser) { + mRSTextBrowser->clear(); } } @@ -119,8 +119,8 @@ public: return mTreeWidget; } - if (mLinkTextBrowser) { - return mLinkTextBrowser; + if (mRSTextBrowser) { + return mRSTextBrowser; } return NULL; @@ -140,7 +140,7 @@ public: return true; } - if (mLinkTextBrowser == widget) { + if (mRSTextBrowser == widget) { return true; } @@ -152,7 +152,7 @@ public: if (mLabel == data.mLabel && mLineEdit == data.mLineEdit && mTreeWidget == data.mTreeWidget && - mLinkTextBrowser == data.mLinkTextBrowser) { + mRSTextBrowser == data.mRSTextBrowser) { return true; } @@ -164,7 +164,7 @@ public: if (mLabel < data.mLabel || mLineEdit < data.mLineEdit || mTreeWidget < data.mTreeWidget || - mLinkTextBrowser < data.mLinkTextBrowser) { + mRSTextBrowser < data.mRSTextBrowser) { return true; } @@ -177,14 +177,14 @@ private: mLabel = NULL; mLineEdit = NULL; mTreeWidget = NULL; - mLinkTextBrowser = NULL; + mRSTextBrowser = NULL; } private: QLabel *mLabel; QLineEdit *mLineEdit; RSTreeWidget *mTreeWidget; - LinkTextBrowser *mLinkTextBrowser; + RSTextBrowser *mRSTextBrowser; }; class UIStateHelperData @@ -258,7 +258,7 @@ void UIStateHelper::addLoadPlaceholder(int index, RSTreeWidget *widget, bool cle data->mLoad.insert(UIStateHelperObject(widget), QPair(text.isEmpty() ? tr("Loading") : text, clear)); } -void UIStateHelper::addLoadPlaceholder(int index, LinkTextBrowser *widget, bool clear, const QString &text) +void UIStateHelper::addLoadPlaceholder(int index, RSTextBrowser *widget, bool clear, const QString &text) { UIStateHelperData *data = findData(index, true); data->mLoad.insert(UIStateHelperObject(widget), QPair(text.isEmpty() ? tr("Loading") : text, clear)); @@ -291,7 +291,7 @@ void UIStateHelper::addClear(int index, RSTreeWidget *widget) data->mClear.push_back(UIStateHelperObject(widget)); } -void UIStateHelper::addClear(int index, LinkTextBrowser *widget) +void UIStateHelper::addClear(int index, RSTextBrowser *widget) { UIStateHelperData *data = findData(index, true); if (data->mClear.contains(widget)) { diff --git a/retroshare-gui/src/gui/common/UIStateHelper.h b/retroshare-gui/src/gui/common/UIStateHelper.h index 41df920ca..ffe2d0801 100644 --- a/retroshare-gui/src/gui/common/UIStateHelper.h +++ b/retroshare-gui/src/gui/common/UIStateHelper.h @@ -30,7 +30,7 @@ class QLabel; class QLineEdit; class RSTreeWidget; class UIStateHelperData; -class LinkTextBrowser; +class RSTextBrowser; enum UIState // State is untouched when bit is not set { @@ -61,11 +61,11 @@ public: void addLoadPlaceholder(int index, QLabel *widget, bool clear = true, const QString &text = "" /* ="Loading" */); void addLoadPlaceholder(int index, QLineEdit *widget, bool clear = true, const QString &text = "" /* ="Loading" */); void addLoadPlaceholder(int index, RSTreeWidget *widget, bool clear = true, const QString &text = "" /* ="Loading" */); - void addLoadPlaceholder(int index, LinkTextBrowser *widget, bool clear = true, const QString &text = "" /* ="Loading" */); + void addLoadPlaceholder(int index, RSTextBrowser *widget, bool clear = true, const QString &text = "" /* ="Loading" */); void addClear(int index, QLabel *widget); void addClear(int index, QLineEdit *widget); void addClear(int index, RSTreeWidget *widget); - void addClear(int index, LinkTextBrowser *widget); + void addClear(int index, RSTextBrowser *widget); /* Set state */ void setLoading(int index, bool loading); diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.ui b/retroshare-gui/src/gui/connect/ConfCertDialog.ui index 3c5037e2f..04b22950e 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.ui +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.ui @@ -129,7 +129,7 @@
- + true @@ -584,7 +584,7 @@ - + @@ -917,9 +917,9 @@ Some services (Discovery, anonymous routing) can be switched off globally, which 1
- LinkTextBrowser + RSTextBrowser QTextBrowser -
gui/common/LinkTextBrowser.h
+
gui/common/RSTextBrowser.h
diff --git a/retroshare-gui/src/gui/forums/CreateForumMsg.cpp b/retroshare-gui/src/gui/forums/CreateForumMsg.cpp index d4cda839c..e49a0c185 100644 --- a/retroshare-gui/src/gui/forums/CreateForumMsg.cpp +++ b/retroshare-gui/src/gui/forums/CreateForumMsg.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -66,6 +67,7 @@ CreateForumMsg::CreateForumMsg(const std::string &fId, const std::string &pId) connect( ui.buttonBox, SIGNAL(rejected()), this, SLOT(close())); connect( ui.emoticonButton, SIGNAL(clicked()), this, SLOT(smileyWidgetForums())); connect( ui.attachFileButton, SIGNAL(clicked() ), this , SLOT(addFile())); + connect(ui.attachPictureButton, SIGNAL(clicked()), this, SLOT(addPicture())); connect( ui.pastersButton, SIGNAL(clicked() ), this , SLOT(pasteLink())); setAcceptDrops(true); @@ -213,6 +215,19 @@ void CreateForumMsg::addFile() } } +void CreateForumMsg::addPicture() +{ + // select a picture file + QString file; + if (misc::getOpenFileName(window(), RshareSettings::LASTDIR_IMAGES, tr("Load Picture File"), "Pictures (*.png *.xpm *.jpg)", file)) { + QString encodedImage; + if (RsHtml::makeEmbeddedImage(file, encodedImage, 640*480)) { + QTextDocumentFragment fragment = QTextDocumentFragment::fromHtml(encodedImage); + ui.forumMessage->textCursor().insertFragment(fragment); + } + } +} + void CreateForumMsg::fileHashingFinished(QList hashedFiles) { std::cerr << "CreateForumMsg::fileHashingFinished() started." << std::endl; diff --git a/retroshare-gui/src/gui/forums/CreateForumMsg.h b/retroshare-gui/src/gui/forums/CreateForumMsg.h index 1ff855b5a..589068152 100644 --- a/retroshare-gui/src/gui/forums/CreateForumMsg.h +++ b/retroshare-gui/src/gui/forums/CreateForumMsg.h @@ -48,6 +48,7 @@ private slots: void smileyWidgetForums(); void addSmileys(); void addFile(); + void addPicture(); protected: void closeEvent (QCloseEvent * event); diff --git a/retroshare-gui/src/gui/forums/CreateForumMsg.ui b/retroshare-gui/src/gui/forums/CreateForumMsg.ui index 80206caad..305d2ff55 100644 --- a/retroshare-gui/src/gui/forums/CreateForumMsg.ui +++ b/retroshare-gui/src/gui/forums/CreateForumMsg.ui @@ -101,9 +101,6 @@ Attach File - - - :/images/add-share24.png:/images/add-share24.png @@ -120,12 +117,32 @@
- + Qt::NoFocus - - + + Attach a Picture + + + + :/images/add_image24.png:/images/add_image24.png + + + + 24 + 24 + + + + true + + + + + + + Qt::NoFocus @@ -186,9 +203,6 @@ Paste RetroShare Link - - - :/images/pasterslink.png:/images/pasterslink.png @@ -208,7 +222,7 @@ - + Qt::CustomContextMenu @@ -217,7 +231,7 @@ <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p></body></html> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></body></html> @@ -262,18 +276,23 @@ p, li { white-space: pre-wrap; } - - HeaderFrame - QFrame -
gui/common/HeaderFrame.h
- 1 -
HashBox QScrollArea
gui/common/HashBox.h
1
+ + MimeTextEdit + QTextEdit +
gui/common/MimeTextEdit.h
+
+ + HeaderFrame + QFrame +
gui/common/HeaderFrame.h
+ 1 +
diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.ui b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.ui index 50520ebf2..d2956ae81 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.ui +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.ui @@ -490,7 +490,7 @@ - + 0 @@ -509,9 +509,9 @@ - LinkTextBrowser + RSTextBrowser QTextBrowser -
gui/common/LinkTextBrowser.h
+
gui/common/RSTextBrowser.h
LineEditClear diff --git a/retroshare-gui/src/gui/msgs/MessageWidget.cpp b/retroshare-gui/src/gui/msgs/MessageWidget.cpp index 6e646a382..84361342e 100644 --- a/retroshare-gui/src/gui/msgs/MessageWidget.cpp +++ b/retroshare-gui/src/gui/msgs/MessageWidget.cpp @@ -135,6 +135,8 @@ MessageWidget::MessageWidget(bool controlled, QWidget *parent, Qt::WFlags flags) connect(NotifyQt::getInstance(), SIGNAL(messagesTagsChanged()), this, SLOT(messagesTagsChanged())); connect(NotifyQt::getInstance(), SIGNAL(messagesChanged()), this, SLOT(messagesChanged())); + ui.msgText->setImageBlockWidget(ui.imageBlockWidget); + /* hide the Tree +/- */ ui.msgList->setRootIsDecorated( false ); ui.msgList->setSelectionMode( QAbstractItemView::ExtendedSelection ); @@ -452,6 +454,7 @@ void MessageWidget::fill(const std::string &msgId) ui.subjectText->setText(""); ui.msgList->clear(); ui.msgText->clear(); + ui.msgText->resetImagesStatus(false); clearTagLabels(); @@ -557,6 +560,7 @@ void MessageWidget::fill(const std::string &msgId) ui.subjectText->setText(QString::fromStdWString(msgInfo.title)); text = RsHtmlMsg(msgInfo.msgflags).formatText(ui.msgText->document(), QString::fromStdWString(msgInfo.msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS | RSHTML_FORMATTEXT_REPLACE_LINKS); + ui.msgText->resetImagesStatus(Settings->getMsgLoadEmbeddedImages()); ui.msgText->setHtml(text); ui.filesText->setText(QString("(%1 %2)").arg(msgInfo.count).arg(msgInfo.count == 1 ? tr("File") : tr("Files"))); diff --git a/retroshare-gui/src/gui/msgs/MessageWidget.ui b/retroshare-gui/src/gui/msgs/MessageWidget.ui index e7b63ec48..c9afa96c0 100644 --- a/retroshare-gui/src/gui/msgs/MessageWidget.ui +++ b/retroshare-gui/src/gui/msgs/MessageWidget.ui @@ -37,119 +37,11 @@ Qt::Vertical - - - - - - 0 - 0 - - - - false - - - - - - - - - 0 - - - 6 - - - - - - - - :/images/attachment.png - - - - - - - - 10 - 75 - true - - - - Recommended Files - - - - - - - - 10 - true - - - - - - - - - - - - - Qt::Horizontal - - - - 351 - 20 - - - - - - - - Qt::NoFocus - - - Download all Recommended Files - - - - :/images/down.png:/images/down.png - - - - - - - Qt::NoFocus - - - - - - - :/images/edit_remove24.png:/images/edit_remove24.png - - - true - - - true - - - - - - + + + 2 + + 6 @@ -434,6 +326,127 @@ + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + false + + + + + + + + + 0 + + + 6 + + + + + + + + :/images/attachment.png + + + + + + + + 10 + 75 + true + + + + Recommended Files + + + + + + + + 10 + true + + + + + + + + + + + + + Qt::Horizontal + + + + 351 + 20 + + + + + + + + Qt::NoFocus + + + Download all Recommended Files + + + + :/images/down.png:/images/down.png + + + + + + + Qt::NoFocus + + + + + + + :/images/edit_remove24.png:/images/edit_remove24.png + + + true + + + true + + + + +
@@ -482,6 +495,19 @@ + + + RSTextBrowser + QTextBrowser +
gui/common/RSTextBrowser.h
+
+ + RSImageBlockWidget + QWidget +
gui/common/RSImageBlockWidget.h
+ 1 +
+
diff --git a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss index 5461764ec..db9830964 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss +++ b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss @@ -432,3 +432,11 @@ ProfileManager QTextEdit#textEdit background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #FFFFD7, stop:1 #FFFFB2); } +/* RSImageBlockWidget */ + +RSImageBlockWidget QFrame#infoFrame { + border: 1px solid #DCDC41; + border-radius: 6px; + background: #FFFFD7; + background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #FFFFD7, stop:1 #FFFFB2); +} diff --git a/retroshare-gui/src/gui/settings/ForumPage.cpp b/retroshare-gui/src/gui/settings/ForumPage.cpp index c877178d0..bd325383c 100644 --- a/retroshare-gui/src/gui/settings/ForumPage.cpp +++ b/retroshare-gui/src/gui/settings/ForumPage.cpp @@ -44,6 +44,7 @@ ForumPage::save(QString &/*errmsg*/) Settings->setForumMsgSetToReadOnActivate(ui.setMsgToReadOnActivate->isChecked()); Settings->setForumExpandNewMessages(ui.expandNewMessages->isChecked()); Settings->setForumOpenAllInNewTab(ui.openAllInNewTabCheckBox->isChecked()); + Settings->setForumLoadEmbeddedImages(ui.loadEmbeddedImages->isChecked()); return true; } @@ -55,4 +56,5 @@ ForumPage::load() ui.setMsgToReadOnActivate->setChecked(Settings->getForumMsgSetToReadOnActivate()); ui.expandNewMessages->setChecked(Settings->getForumExpandNewMessages()); ui.openAllInNewTabCheckBox->setChecked(Settings->getForumOpenAllInNewTab()); + ui.loadEmbeddedImages->setChecked(Settings->getForumLoadEmbeddedImages()); } diff --git a/retroshare-gui/src/gui/settings/ForumPage.ui b/retroshare-gui/src/gui/settings/ForumPage.ui index 30ed15f11..3fdf7c7ef 100644 --- a/retroshare-gui/src/gui/settings/ForumPage.ui +++ b/retroshare-gui/src/gui/settings/ForumPage.ui @@ -31,6 +31,13 @@ + + + + Load embedded images + + + diff --git a/retroshare-gui/src/gui/settings/MessagePage.cpp b/retroshare-gui/src/gui/settings/MessagePage.cpp index d278a0efd..2d634d605 100644 --- a/retroshare-gui/src/gui/settings/MessagePage.cpp +++ b/retroshare-gui/src/gui/settings/MessagePage.cpp @@ -67,6 +67,7 @@ bool MessagePage::save(QString &/*errmsg*/) { Settings->setMsgSetToReadOnActivate(ui.setMsgToReadOnActivate->isChecked()); + Settings->setMsgLoadEmbeddedImages(ui.loadEmbeddedImages->isChecked()); Settings->setMsgOpen((RshareSettings::enumMsgOpen) ui.openComboBox->itemData(ui.openComboBox->currentIndex()).toInt()); std::map >::iterator Tag; @@ -95,6 +96,7 @@ void MessagePage::load() { ui.setMsgToReadOnActivate->setChecked(Settings->getMsgSetToReadOnActivate()); + ui.loadEmbeddedImages->setChecked(Settings->getMsgLoadEmbeddedImages()); ui.openComboBox->setCurrentIndex(ui.openComboBox->findData(Settings->getMsgOpen())); ui.encryptedMsgs_CB->setChecked(rsMsgs->distantMessagingEnabled()) ; diff --git a/retroshare-gui/src/gui/settings/MessagePage.ui b/retroshare-gui/src/gui/settings/MessagePage.ui index 7680ef67c..58fa2be1e 100644 --- a/retroshare-gui/src/gui/settings/MessagePage.ui +++ b/retroshare-gui/src/gui/settings/MessagePage.ui @@ -30,6 +30,13 @@ + + + + Load embedded images + + + diff --git a/retroshare-gui/src/gui/settings/rsharesettings.cpp b/retroshare-gui/src/gui/settings/rsharesettings.cpp index c596ec2af..972ad6762 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.cpp +++ b/retroshare-gui/src/gui/settings/rsharesettings.cpp @@ -703,6 +703,16 @@ void RshareSettings::setMsgSetToReadOnActivate (bool value) setValueToGroup("MessageDialog", "SetMsgToReadOnActivate", value); } +bool RshareSettings::getMsgLoadEmbeddedImages() +{ + return valueFromGroup("MessageDialog", "LoadEmbeddedImages", false).toBool(); +} + +void RshareSettings::setMsgLoadEmbeddedImages(bool value) +{ + setValueToGroup("MessageDialog", "LoadEmbeddedImages", value); +} + RshareSettings::enumMsgOpen RshareSettings::getMsgOpen() { enumMsgOpen value = (enumMsgOpen) valueFromGroup("MessageDialog", "msgOpen", MSG_OPEN_TAB).toInt(); @@ -775,3 +785,13 @@ void RshareSettings::setMaxTimeBeforeIdle(uint nValue) m_maxTimeBeforeIdle = nValue; setValue("maxTimeBeforeIdle", nValue); } + +bool RshareSettings::getForumLoadEmbeddedImages() +{ + return valueFromGroup("ForumDialog", "LoadEmbeddedImages", false).toBool(); +} + +void RshareSettings::setForumLoadEmbeddedImages(bool value) +{ + setValueToGroup("ForumDialog", "LoadEmbeddedImages", value); +} diff --git a/retroshare-gui/src/gui/settings/rsharesettings.h b/retroshare-gui/src/gui/settings/rsharesettings.h index 27f23bbac..fea1eb7db 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.h +++ b/retroshare-gui/src/gui/settings/rsharesettings.h @@ -238,6 +238,8 @@ public: /* Messages */ bool getMsgSetToReadOnActivate(); void setMsgSetToReadOnActivate(bool value); + bool getMsgLoadEmbeddedImages(); + void setMsgLoadEmbeddedImages(bool value); enumMsgOpen getMsgOpen(); void setMsgOpen(enumMsgOpen value); @@ -249,6 +251,8 @@ public: void setForumExpandNewMessages(bool value); bool getForumOpenAllInNewTab(); void setForumOpenAllInNewTab(bool value); + bool getForumLoadEmbeddedImages(); + void setForumLoadEmbeddedImages(bool value); /* time before idle */ uint getMaxTimeBeforeIdle(); diff --git a/retroshare-gui/src/lang/retroshare_en.ts b/retroshare-gui/src/lang/retroshare_en.ts index f2c081f13..5e893a828 100644 --- a/retroshare-gui/src/lang/retroshare_en.ts +++ b/retroshare-gui/src/lang/retroshare_en.ts @@ -1411,6 +1411,30 @@ Double click lobbies to enter and chat. <h1><img width="32" src=":/images/64px_help.png">&nbsp;&nbsp;Chat Lobbies</h1> <p>Chat lobbies are distributed chat rooms, and work pretty much like IRC. They allow you to talk anonymously with tons of people without the need to make friends.</p> <p>A chat lobby can be public (your friends see it) or private (your friends can't see it, unless you invite them with <img src=":/images/add_24x24.png" width=12/>). Once you have been invited to a private lobby, you will be able to see it when your friends are using it.</p> <p>The list at left shows chat lobbies your friends are participating in. You can either <ul> <li>Right click to create a new chat lobby</li> <li>Double click a chat lobby to enter, chat, and show it to your friends</li> </ul> Note: For the chat lobbies to work properly, your computer needs be on time. So check your system clock! </p> + + Subscribed + + + + Show + + + + Column + + + + Columns + + + + Yes + + + + No + + ChatMsgItem @@ -3823,6 +3847,14 @@ p, li { white-space: pre-wrap; } Add Extra File + + Attach a Picture + + + + Load Picture File + + CreateGroup @@ -5377,6 +5409,10 @@ p, li { white-space: pre-wrap; } Forum + + Load embedded images + + ForumUserNotify @@ -8918,6 +8954,10 @@ Do you want to save message ? Accept encrypted distant messages from everyone + + Load embedded images + + MessageToaster @@ -10703,18 +10743,10 @@ p, li { white-space: pre-wrap; } PostedGroupDialog - - Create New Posted Topic - - Posted Topic - - Edit Posted Topic - - Add Topic Admins @@ -10723,6 +10755,14 @@ p, li { white-space: pre-wrap; } Select Topic Admins + + Create New Topic + + + + Edit Topic + + PostedItem @@ -10730,10 +10770,6 @@ p, li { white-space: pre-wrap; } 0 - - \/ - - This is a very very very very loooooooooooooooonnnnnnnnnnnnnnnnng title don't you think? Yes it is and should wrap around I hope @@ -10763,11 +10799,11 @@ p, li { white-space: pre-wrap; } - Vote Up + I like this - Vote Down + I dislike this @@ -11654,6 +11690,21 @@ p, li { white-space: pre-wrap; } + + RSImageBlockWidget + + Form + + + + The loading of embedded images is blocked. + + + + Load images + + + RSettingsWin diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index 56c04ff2c..2392da3bd 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -450,7 +450,8 @@ HEADERS += rshare.h \ gui/common/HashBox.h \ gui/common/LineEditClear.h \ gui/common/DropLineEdit.h \ - gui/common/LinkTextBrowser.h \ + gui/common/RSTextBrowser.h \ + gui/common/RSImageBlockWidget.h \ gui/common/FeedNotify.h \ gui/common/UserNotify.h \ gui/common/HeaderFrame.h \ @@ -593,6 +594,7 @@ FORMS += gui/StartDialog.ui \ gui/common/FriendList.ui \ gui/common/FriendSelectionWidget.ui \ gui/common/HashBox.ui \ + gui/common/RSImageBlockWidget.ui \ gui/common/RsCollectionDialog.ui \ gui/common/HeaderFrame.ui \ gui/style/StyleDialog.ui \ @@ -729,7 +731,8 @@ SOURCES += main.cpp \ gui/common/HashBox.cpp \ gui/common/LineEditClear.cpp \ gui/common/DropLineEdit.cpp \ - gui/common/LinkTextBrowser.cpp \ + gui/common/RSTextBrowser.cpp \ + gui/common/RSImageBlockWidget.cpp \ gui/common/FeedNotify.cpp \ gui/common/UserNotify.cpp \ gui/common/HeaderFrame.cpp \