Fixed bug when the user clicks on a link without http:// in a QTextBrowser. This link was opened directly in RetroShare.

Show clickable links in the channel feed message.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4923 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-02-11 13:42:42 +00:00
parent 6a44342e4f
commit 340a313fea
11 changed files with 78 additions and 40 deletions

View file

@ -0,0 +1,19 @@
#include <QDesktopServices>
#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
QDesktopServices::openUrl(url);
}

View file

@ -0,0 +1,17 @@
#ifndef LINKTEXTBROWSER_H
#define LINKTEXTBROWSER_H
#include <QTextBrowser>
class LinkTextBrowser : public QTextBrowser
{
Q_OBJECT
public:
explicit LinkTextBrowser(QWidget *parent = 0);
private slots:
void linkClicked(const QUrl &url);
};
#endif // LINKTEXTBROWSER_H