mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-10 01:55:19 -04:00
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:
parent
6a44342e4f
commit
340a313fea
11 changed files with 78 additions and 40 deletions
19
retroshare-gui/src/gui/common/LinkTextBrowser.cpp
Normal file
19
retroshare-gui/src/gui/common/LinkTextBrowser.cpp
Normal 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);
|
||||
}
|
17
retroshare-gui/src/gui/common/LinkTextBrowser.h
Normal file
17
retroshare-gui/src/gui/common/LinkTextBrowser.h
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue