mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-18 12:24:22 -05:00
re implement chat parsing for urls. External web browser call might not work on some systems
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2224 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
37e9bf527c
commit
db225bdcb7
@ -193,8 +193,8 @@ PeersDialog::PeersDialog(QWidget *parent)
|
|||||||
|
|
||||||
ui.menupushButton->setMenu(menu);
|
ui.menupushButton->setMenu(menu);
|
||||||
|
|
||||||
ui.msgText->setOpenExternalLinks ( false );
|
//ui.msgText->setOpenExternalLinks ( false );
|
||||||
ui.msgText->setOpenLinks ( false );
|
//ui.msgText->setOpenLinks ( false );
|
||||||
|
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
ui.lineEdit->setAcceptDrops(false);
|
ui.lineEdit->setAcceptDrops(false);
|
||||||
@ -933,6 +933,20 @@ void PeersDialog::insertChat()
|
|||||||
emit notifyGroupChat(QString("New group chat"), notifyMsg);
|
emit notifyGroupChat(QString("New group chat"), notifyMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//replace http://, https:// and www. with <a href> links
|
||||||
|
QRegExp rx("(https?://[^ <>]*)|(www\\.[^ <>]*)");
|
||||||
|
int count = 0;
|
||||||
|
int pos = 200; //ignore the first 200 char because of the standard DTD ref
|
||||||
|
while ( (pos = rx.indexIn(extraTxt, pos)) != -1 ) {
|
||||||
|
//we need to look ahead to see if it's already a well formed link
|
||||||
|
if (extraTxt.mid(pos - 6, 6) != "href=\"" && extraTxt.mid(pos - 6, 6) != "href='" && extraTxt.mid(pos - 6, 6) != "ttp://" ) {
|
||||||
|
QString tempMessg = extraTxt.left(pos) + "<a href=\"" + rx.cap(count) + "\">" + rx.cap(count) + "</a>" + extraTxt.mid(pos + rx.matchedLength(), -1);
|
||||||
|
extraTxt = tempMessg;
|
||||||
|
}
|
||||||
|
pos += rx.matchedLength() + 15;
|
||||||
|
count ++;
|
||||||
|
}
|
||||||
|
|
||||||
QHashIterator<QString, QString> i(smileys);
|
QHashIterator<QString, QString> i(smileys);
|
||||||
while(i.hasNext())
|
while(i.hasNext())
|
||||||
{
|
{
|
||||||
@ -1522,7 +1536,7 @@ void PeersDialog::addAttachment(std::string filePath) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PeersDialog::fileHashingFinished(AttachFileItem* file) {
|
void PeersDialog::fileHashingFinished(AttachFileItem* file) {
|
||||||
std::cerr << "PopupChatDialog::fileHashingFinished() started.";
|
std::cerr << "PeersDialog::fileHashingFinished() started.";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
//check that the file is ok tos end
|
//check that the file is ok tos end
|
||||||
@ -1553,8 +1567,8 @@ void PeersDialog::fileHashingFinished(AttachFileItem* file) {
|
|||||||
|
|
||||||
std::string mesgString = "<a href='retroshare://file|" + (file->FileName()) + "|" + fileSize + "|" + (file->FileHash()) + "'>"
|
std::string mesgString = "<a href='retroshare://file|" + (file->FileName()) + "|" + fileSize + "|" + (file->FileHash()) + "'>"
|
||||||
+ "retroshare://file|" + (file->FileName()) + "|" + fileSize + "|" + (file->FileHash()) + "</a>";
|
+ "retroshare://file|" + (file->FileName()) + "|" + fileSize + "|" + (file->FileHash()) + "</a>";
|
||||||
#ifdef CHAT_DEBUG
|
#ifdef PEERS_DEBUG
|
||||||
std::cerr << "CreateForumMsg::anchorClicked mesgString : " << mesgString << std::endl;
|
std::cerr << "PeersDialog::fileHashingFinished mesgString : " << mesgString << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char * messageString = mesgString.c_str ();
|
const char * messageString = mesgString.c_str ();
|
||||||
@ -1581,8 +1595,8 @@ void PeersDialog::fileHashingFinished(AttachFileItem* file) {
|
|||||||
|
|
||||||
void PeersDialog::anchorClicked (const QUrl& link )
|
void PeersDialog::anchorClicked (const QUrl& link )
|
||||||
{
|
{
|
||||||
#ifdef FORUM_DEBUG
|
#ifdef PEERS_DEBUG
|
||||||
std::cerr << "ForumsDialog::anchorClicked link.scheme() : " << link.scheme().toStdString() << std::endl;
|
std::cerr << "PeersDialog::anchorClicked link.scheme() : " << link.scheme().toStdString() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (link.scheme() == "retroshare")
|
if (link.scheme() == "retroshare")
|
||||||
@ -1593,7 +1607,7 @@ void PeersDialog::anchorClicked (const QUrl& link )
|
|||||||
uint64_t fileSize = L.at(2).toULongLong();
|
uint64_t fileSize = L.at(2).toULongLong();
|
||||||
std::string fileHash = L.at(3).toStdString() ;
|
std::string fileHash = L.at(3).toStdString() ;
|
||||||
|
|
||||||
#ifdef FORUM_DEBUG
|
#ifdef PEERS_DEBUG
|
||||||
std::cerr << "PeersDialog::anchorClicked FileRequest : fileName : " << fileName << ". fileHash : " << fileHash << ". fileSize : " << fileSize << std::endl;
|
std::cerr << "PeersDialog::anchorClicked FileRequest : fileName : " << fileName << ". fileHash : " << fileHash << ". fileSize : " << fileSize << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -861,6 +861,12 @@ 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>false</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
@ -99,8 +99,8 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
|
|||||||
// Create the status bar
|
// Create the status bar
|
||||||
resetStatusBar() ;
|
resetStatusBar() ;
|
||||||
|
|
||||||
ui.textBrowser->setOpenExternalLinks ( false );
|
//ui.textBrowser->setOpenExternalLinks ( false );
|
||||||
ui.textBrowser->setOpenLinks ( false );
|
//ui.textBrowser->setOpenLinks ( false );
|
||||||
|
|
||||||
QString title = QString::fromStdString(name) + " :" + tr(" RetroShare - Encrypted Chat") ;
|
QString title = QString::fromStdString(name) + " :" + tr(" RetroShare - Encrypted Chat") ;
|
||||||
setWindowTitle(title);
|
setWindowTitle(title);
|
||||||
@ -252,29 +252,21 @@ void PopupChatDialog::addChatMsg(ChatInfo *ci)
|
|||||||
//replace http://, https:// and www. with <a href> links
|
//replace http://, https:// and www. with <a href> links
|
||||||
QRegExp rx("(https?://[^ <>]*)|(www\\.[^ <>]*)");
|
QRegExp rx("(https?://[^ <>]*)|(www\\.[^ <>]*)");
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int pos = 100; //ignor the first 100 charater because of the standard DTD ref
|
int pos = 100; //ignore the first 100 char because of the standard DTD ref
|
||||||
while ( (pos = rx.indexIn(message, pos)) != -1 ) {
|
while ( (pos = rx.indexIn(message, pos)) != -1 ) {
|
||||||
count ++;
|
|
||||||
//we need to look ahead to see if it's already a well formed link
|
//we need to look ahead to see if it's already a well formed link
|
||||||
if (message.mid(pos - 6, 6) != "href=\"" && message.mid(pos - 6, 6) != "href='" && message.mid(pos - 6, 6) != "ttp://" ) {
|
if (message.mid(pos - 6, 6) != "href=\"" && message.mid(pos - 6, 6) != "href='" && message.mid(pos - 6, 6) != "ttp://" ) {
|
||||||
QString tempMessg = message.left(pos) + "<a href=\"" + rx.cap(count) + "\">" + rx.cap(count) + "</a>" + message.mid(pos + rx.matchedLength(), -1);
|
QString tempMessg = message.left(pos) + "<a href=\"" + rx.cap(count) + "\">" + rx.cap(count) + "</a>" + message.mid(pos + rx.matchedLength(), -1);
|
||||||
message = tempMessg;
|
message = tempMessg;
|
||||||
}
|
}
|
||||||
pos += rx.matchedLength() + 15;
|
pos += rx.matchedLength() + 15;
|
||||||
|
count ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CHAT_DEBUG
|
#ifdef CHAT_DEBUG
|
||||||
std::cout << "PopupChatDialog:addChatMsg message : " << message.toStdString() << std::endl;
|
std::cout << "PopupChatDialog:addChatMsg message : " << message.toStdString() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*QHashIterator<QString, QString> i(smileys);
|
|
||||||
while(i.hasNext())
|
|
||||||
{
|
|
||||||
i.next();
|
|
||||||
message.replace(i.key(), "<img src=\"" + i.value() + "\">");
|
|
||||||
}*/
|
|
||||||
|
|
||||||
QHashIterator<QString, QString> i(smileys);
|
QHashIterator<QString, QString> i(smileys);
|
||||||
while(i.hasNext())
|
while(i.hasNext())
|
||||||
{
|
{
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>PopupChatDialog</class>
|
<class>PopupChatDialog</class>
|
||||||
<widget class="QMainWindow" name="PopupChatDialog">
|
<widget class="QMainWindow" name="PopupChatDialog">
|
||||||
@ -20,16 +21,13 @@
|
|||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="horizontalSpacing" >
|
<property name="spacing">
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="verticalSpacing" >
|
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QTextBrowser" name="textBrowser">
|
<widget class="QTextBrowser" name="textBrowser">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy vsizetype="MinimumExpanding" hsizetype="Expanding" >
|
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
@ -46,9 +44,15 @@
|
|||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="openExternalLinks">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="openLinks">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item rowspan="4" row="0" column="1" >
|
<item row="0" column="1" rowspan="4">
|
||||||
<widget class="QFrame" name="avatarframe">
|
<widget class="QFrame" name="avatarframe">
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::StyledPanel</enum>
|
<enum>QFrame::StyledPanel</enum>
|
||||||
@ -102,7 +106,7 @@ border-image: url(:/images/mystatus_bg.png);
|
|||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" >
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>61</width>
|
<width>61</width>
|
||||||
<height>141</height>
|
<height>141</height>
|
||||||
@ -146,7 +150,7 @@ border-image: url(:/images/mystatus_bg.png);
|
|||||||
<property name="sizeType">
|
<property name="sizeType">
|
||||||
<enum>QSizePolicy::Fixed</enum>
|
<enum>QSizePolicy::Fixed</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" >
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>61</width>
|
<width>61</width>
|
||||||
<height>30</height>
|
<height>30</height>
|
||||||
@ -157,7 +161,7 @@ border-image: url(:/images/mystatus_bg.png);
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item rowspan="4" row="0" column="2" >
|
<item row="0" column="2" rowspan="4">
|
||||||
<layout class="QGridLayout">
|
<layout class="QGridLayout">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QPushButton" name="avatarFrameButton">
|
<widget class="QPushButton" name="avatarFrameButton">
|
||||||
@ -192,7 +196,7 @@ border-image: url(:/images/mystatus_bg.png);
|
|||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" >
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>14</width>
|
<width>14</width>
|
||||||
<height>321</height>
|
<height>321</height>
|
||||||
@ -228,7 +232,7 @@ border-image: url(:/images/mystatus_bg.png);
|
|||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" >
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>190</width>
|
<width>190</width>
|
||||||
<height>25</height>
|
<height>25</height>
|
||||||
@ -239,7 +243,7 @@ border-image: url(:/images/mystatus_bg.png);
|
|||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QPushButton" name="emoteiconButton">
|
<widget class="QPushButton" name="emoteiconButton">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
@ -282,10 +286,10 @@ border-image: url(:/images/mystatus_bg.png);
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string><html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
<string><html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||||
p, li { white-space: pre-wrap; }
|
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;">
|
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Set Chat Window Style</p></body></html></string>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Set Chat Window Style</p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
@ -319,7 +323,8 @@ p, li { white-space: pre-wrap; }
|
|||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset>C:/Dokumente und Einstellungen/Linux/.designer/backup</iconset>
|
<iconset>
|
||||||
|
<normaloff>C:/Dokumente und Einstellungen/Linux/.designer/backup</normaloff>C:/Dokumente und Einstellungen/Linux/.designer/backup</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="checkable">
|
<property name="checkable">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
@ -347,7 +352,8 @@ p, li { white-space: pre-wrap; }
|
|||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset>C:/Dokumente und Einstellungen/Linux/.designer/backup</iconset>
|
<iconset>
|
||||||
|
<normaloff>C:/Dokumente und Einstellungen/Linux/.designer/backup</normaloff>C:/Dokumente und Einstellungen/Linux/.designer/backup</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="checkable">
|
<property name="checkable">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
@ -375,7 +381,8 @@ p, li { white-space: pre-wrap; }
|
|||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset>C:/Dokumente und Einstellungen/Linux/.designer/backup</iconset>
|
<iconset>
|
||||||
|
<normaloff>C:/Dokumente und Einstellungen/Linux/.designer/backup</normaloff>C:/Dokumente und Einstellungen/Linux/.designer/backup</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="checkable">
|
<property name="checkable">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
@ -403,7 +410,8 @@ p, li { white-space: pre-wrap; }
|
|||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset>C:/Dokumente und Einstellungen/Linux/.designer/backup</iconset>
|
<iconset>
|
||||||
|
<normaloff>C:/Dokumente und Einstellungen/Linux/.designer/backup</normaloff>C:/Dokumente und Einstellungen/Linux/.designer/backup</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="checkable">
|
<property name="checkable">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
@ -438,7 +446,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QTextEdit" name="chattextEdit">
|
<widget class="QTextEdit" name="chattextEdit">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy vsizetype="Maximum" hsizetype="Expanding" >
|
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
@ -465,7 +473,8 @@ p, li { white-space: pre-wrap; }
|
|||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../images.qrc" >:/images/add-share24.png</iconset>
|
<iconset resource="../images.qrc">
|
||||||
|
<normaloff>:/images/add-share24.png</normaloff>:/images/add-share24.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="iconSize">
|
<property name="iconSize">
|
||||||
<size>
|
<size>
|
||||||
@ -480,7 +489,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" >
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>331</width>
|
<width>331</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
@ -543,7 +552,8 @@ p, li { white-space: pre-wrap; }
|
|||||||
</action>
|
</action>
|
||||||
<action name="actionAvatar">
|
<action name="actionAvatar">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../images.qrc" >:/images/add_image24.png</iconset>
|
<iconset resource="../images.qrc">
|
||||||
|
<normaloff>:/images/add_image24.png</normaloff>:/images/add_image24.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Avatar</string>
|
<string>Avatar</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user