mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 00:49:28 -05: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
@ -339,6 +339,7 @@ HEADERS += rshare.h \
|
|||||||
gui/common/FriendList.h \
|
gui/common/FriendList.h \
|
||||||
gui/common/FriendSelectionWidget.h \
|
gui/common/FriendSelectionWidget.h \
|
||||||
gui/common/HashBox.h \
|
gui/common/HashBox.h \
|
||||||
|
gui/common/LinkTextBrowser.h \
|
||||||
gui/style/RSStyle.h \
|
gui/style/RSStyle.h \
|
||||||
gui/style/StyleDialog.h \
|
gui/style/StyleDialog.h \
|
||||||
gui/MessagesDialog.h \
|
gui/MessagesDialog.h \
|
||||||
@ -584,6 +585,7 @@ SOURCES += main.cpp \
|
|||||||
gui/common/FriendList.cpp \
|
gui/common/FriendList.cpp \
|
||||||
gui/common/FriendSelectionWidget.cpp \
|
gui/common/FriendSelectionWidget.cpp \
|
||||||
gui/common/HashBox.cpp \
|
gui/common/HashBox.cpp \
|
||||||
|
gui/common/LinkTextBrowser.cpp \
|
||||||
gui/style/RSStyle.cpp \
|
gui/style/RSStyle.cpp \
|
||||||
gui/style/StyleDialog.cpp \
|
gui/style/StyleDialog.cpp \
|
||||||
gui/settings/configpage.cpp \
|
gui/settings/configpage.cpp \
|
||||||
|
@ -1250,7 +1250,7 @@ border-image: url(:/images/closepressed.png)
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QTextBrowser" name="postText">
|
<widget class="LinkTextBrowser" name="postText">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
@ -1262,12 +1262,6 @@ border-image: url(:/images/closepressed.png)
|
|||||||
<pointsize>9</pointsize>
|
<pointsize>9</pointsize>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="openExternalLinks">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="openLinks">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
@ -1285,6 +1279,11 @@ border-image: url(:/images/closepressed.png)
|
|||||||
</action>
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>LinkTextBrowser</class>
|
||||||
|
<extends>QTextBrowser</extends>
|
||||||
|
<header>gui/common/LinkTextBrowser.h</header>
|
||||||
|
</customwidget>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>GroupTreeWidget</class>
|
<class>GroupTreeWidget</class>
|
||||||
<extends>QWidget</extends>
|
<extends>QWidget</extends>
|
||||||
|
@ -1218,7 +1218,7 @@ border: 1px solid #CCCCCC;}</string>
|
|||||||
<property name="childrenCollapsible">
|
<property name="childrenCollapsible">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QTextBrowser" name="msgText">
|
<widget class="LinkTextBrowser" name="msgText">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
@ -1238,12 +1238,6 @@ background: white;}</string>
|
|||||||
<property name="readOnly">
|
<property name="readOnly">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="openExternalLinks">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="openLinks">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="layoutWidget_2">
|
<widget class="QWidget" name="layoutWidget_2">
|
||||||
<layout class="QVBoxLayout" name="verticalLayoutEdit">
|
<layout class="QVBoxLayout" name="verticalLayoutEdit">
|
||||||
@ -1477,6 +1471,11 @@ background: white;}</string>
|
|||||||
<header>gui/common/FriendList.h</header>
|
<header>gui/common/FriendList.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>LinkTextBrowser</class>
|
||||||
|
<extends>QTextBrowser</extends>
|
||||||
|
<header>gui/common/LinkTextBrowser.h</header>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="images.qrc"/>
|
<include location="images.qrc"/>
|
||||||
|
@ -173,7 +173,7 @@ border-image: url(:/images/closepressed.png)
|
|||||||
<widget class="QWidget" name="verticalLayoutWidget">
|
<widget class="QWidget" name="verticalLayoutWidget">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTextBrowser" name="textBrowser">
|
<widget class="LinkTextBrowser" name="textBrowser">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
|
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
@ -191,12 +191,6 @@ border-image: url(:/images/closepressed.png)
|
|||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
background: white;}</string>
|
background: white;}</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="openExternalLinks">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="openLinks">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@ -665,6 +659,11 @@ border: 1px solid #CCCCCC;
|
|||||||
<header location="global">gui/common/HashBox.h</header>
|
<header location="global">gui/common/HashBox.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>LinkTextBrowser</class>
|
||||||
|
<extends>QTextBrowser</extends>
|
||||||
|
<header>gui/common/LinkTextBrowser.h</header>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../images.qrc"/>
|
<include location="../images.qrc"/>
|
||||||
|
@ -80,7 +80,7 @@ public:
|
|||||||
EmbedInHtmlAhref() :
|
EmbedInHtmlAhref() :
|
||||||
EmbedInHtml(Ahref)
|
EmbedInHtml(Ahref)
|
||||||
{
|
{
|
||||||
myRE.setPattern("(\\bretroshare://[^\\s]*)|(\\bhttps?://[^\\s]*)|(\\bwww\\.[^\\s]*)");
|
myRE.setPattern("(\\bretroshare://[^\\s]*)|(\\bhttps?://[^\\s]*)|(\\bfile://[^\\s]*)|(\\bwww\\.[^\\s]*)");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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
|
@ -116,7 +116,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="QTextBrowser" name="rsid">
|
<widget class="LinkTextBrowser" name="rsid">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
@ -141,9 +141,6 @@
|
|||||||
<property name="readOnly">
|
<property name="readOnly">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="openExternalLinks">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0">
|
<item row="5" column="0">
|
||||||
@ -549,11 +546,7 @@
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="_11">
|
<layout class="QVBoxLayout" name="_11">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTextBrowser" name="signers">
|
<widget class="LinkTextBrowser" name="signers"/>
|
||||||
<property name="openExternalLinks">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
@ -765,6 +758,11 @@ p, li { white-space: pre-wrap; }
|
|||||||
<header>gui/common/AvatarWidget.h</header>
|
<header>gui/common/AvatarWidget.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>LinkTextBrowser</class>
|
||||||
|
<extends>QTextBrowser</extends>
|
||||||
|
<header>gui/common/LinkTextBrowser.h</header>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../images.qrc"/>
|
<include location="../images.qrc"/>
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "gui/notifyqt.h"
|
#include "gui/notifyqt.h"
|
||||||
#include "util/misc.h"
|
#include "util/misc.h"
|
||||||
#include "gui/RetroShareLink.h"
|
#include "gui/RetroShareLink.h"
|
||||||
|
#include "gui/chat/HandleRichText.h"
|
||||||
|
|
||||||
#include <retroshare/rschannels.h>
|
#include <retroshare/rschannels.h>
|
||||||
|
|
||||||
@ -125,7 +126,7 @@ void ChanMsgItem::updateItemStatic()
|
|||||||
{
|
{
|
||||||
/* subject */
|
/* subject */
|
||||||
titleLabel->setText(QString::fromStdWString(cmi.subject));
|
titleLabel->setText(QString::fromStdWString(cmi.subject));
|
||||||
subjectLabel->setText(QString::fromStdWString(cmi.msg));
|
subjectLabel->setText(RsHtml::formatText(QString::fromStdWString(cmi.msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
|
||||||
|
|
||||||
/* disable buttons: deletion facility not enabled with cache services yet */
|
/* disable buttons: deletion facility not enabled with cache services yet */
|
||||||
clearButton->setEnabled(false);
|
clearButton->setEnabled(false);
|
||||||
@ -162,7 +163,7 @@ void ChanMsgItem::updateItemStatic()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
msgLabel->setText(QString::fromStdWString(cmi.msg));
|
msgLabel->setText(RsHtml::formatText(QString::fromStdWString(cmi.msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
|
||||||
msgWidget->setVisible(!cmi.msg.empty());
|
msgWidget->setVisible(!cmi.msg.empty());
|
||||||
|
|
||||||
QDateTime qtime;
|
QDateTime qtime;
|
||||||
|
@ -466,6 +466,9 @@ border-radius: 10px;}</string>
|
|||||||
<property name="wordWrap">
|
<property name="wordWrap">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="openExternalLinks">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
<property name="textInteractionFlags">
|
<property name="textInteractionFlags">
|
||||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
|
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
|
||||||
</property>
|
</property>
|
||||||
|
@ -39,19 +39,13 @@
|
|||||||
<widget class="QWidget" name="layoutWidget">
|
<widget class="QWidget" name="layoutWidget">
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QTextBrowser" name="msgText">
|
<widget class="LinkTextBrowser" name="msgText">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="openExternalLinks">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="openLinks">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
@ -481,6 +475,13 @@ p, li { white-space: pre-wrap; }
|
|||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>LinkTextBrowser</class>
|
||||||
|
<extends>QTextBrowser</extends>
|
||||||
|
<header>gui/common/LinkTextBrowser.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../images.qrc"/>
|
<include location="../images.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user