diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index 37e2b589e..ead335091 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -48,6 +48,7 @@ #include "gui/common/FilesDefs.h" #include "gui/common/Emoticons.h" #include "gui/chat/ChatLobbyDialog.h" +#include "gui/gxs/GxsIdDetails.h" #include "util/misc.h" #include "util/HandleRichText.h" #include "gui/chat/ChatUserNotify.h"//For BradCast @@ -65,6 +66,8 @@ #define FMM 2.5//fontMetricsMultiplicator +#define PERSONID "PersonId:" + /***** * #define CHAT_DEBUG 1 *****/ @@ -587,6 +590,9 @@ bool ChatWidget::eventFilter(QObject *obj, QEvent *event) if (ui->textBrowser->checkImage(helpEvent->pos(), imageStr)) { toolTipText = imageStr; } + } else if (toolTipText.startsWith(PERSONID)){ + toolTipText = toolTipText.replace(PERSONID, tr("Person id: ") ); + toolTipText = toolTipText.append(tr("\nDouble click on it to add his name on text writer.") ); } } if (!toolTipText.isEmpty()){ @@ -664,6 +670,39 @@ bool ChatWidget::eventFilter(QObject *obj, QEvent *event) } } } + } else if (obj == ui->textBrowser->viewport()) { + if (event->type() == QEvent::MouseButtonDblClick) { + + QMouseEvent* mouseEvent = static_cast(event); + QTextCursor cursor = ui->textBrowser->cursorForPosition(mouseEvent->pos()); + cursor.select(QTextCursor::WordUnderCursor); + if (!cursor.selectedText().isEmpty()){ + QRegExp rx("getIdDetails(mId, details)){ + QString text = QString("@").append(GxsIdDetails::getName(details)).append(" "); + ui->chatTextEdit->textCursor().insertText(text); + } + } + } + } + + } + + } } else { if (event->type() == QEvent::WindowActivate) { if (isVisible() && (window() == NULL || window()->isActiveWindow())) { @@ -963,9 +1002,13 @@ void ChatWidget::addChatMsg(bool incoming, const QString &name, const RsGxsId gx formatMsg.replace(QString(""),QString("").arg(timeStamp)); //replace Name anchors with GXS Id QString strGxsId = ""; - if (!gxsId.isNull()) + if (!gxsId.isNull()) { strGxsId = QString::fromStdString(gxsId.toStdString()); - formatMsg.replace(QString(""),QString("").arg(strGxsId)); + formatMsg.replace(QString("") + ,QString("").arg(strGxsId) ); + } else { + formatMsg.replace(QString(""),""); + } QTextCursor textCursor = QTextCursor(ui->textBrowser->textCursor()); textCursor.movePosition(QTextCursor::End);