mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 08:29:26 -05:00
Add Double Click on Name for Chat to add their name in text writer.
This commit is contained in:
parent
4d7bd833a9
commit
4fbcc1e85f
@ -48,6 +48,7 @@
|
|||||||
#include "gui/common/FilesDefs.h"
|
#include "gui/common/FilesDefs.h"
|
||||||
#include "gui/common/Emoticons.h"
|
#include "gui/common/Emoticons.h"
|
||||||
#include "gui/chat/ChatLobbyDialog.h"
|
#include "gui/chat/ChatLobbyDialog.h"
|
||||||
|
#include "gui/gxs/GxsIdDetails.h"
|
||||||
#include "util/misc.h"
|
#include "util/misc.h"
|
||||||
#include "util/HandleRichText.h"
|
#include "util/HandleRichText.h"
|
||||||
#include "gui/chat/ChatUserNotify.h"//For BradCast
|
#include "gui/chat/ChatUserNotify.h"//For BradCast
|
||||||
@ -65,6 +66,8 @@
|
|||||||
|
|
||||||
#define FMM 2.5//fontMetricsMultiplicator
|
#define FMM 2.5//fontMetricsMultiplicator
|
||||||
|
|
||||||
|
#define PERSONID "PersonId:"
|
||||||
|
|
||||||
/*****
|
/*****
|
||||||
* #define CHAT_DEBUG 1
|
* #define CHAT_DEBUG 1
|
||||||
*****/
|
*****/
|
||||||
@ -587,6 +590,9 @@ bool ChatWidget::eventFilter(QObject *obj, QEvent *event)
|
|||||||
if (ui->textBrowser->checkImage(helpEvent->pos(), imageStr)) {
|
if (ui->textBrowser->checkImage(helpEvent->pos(), imageStr)) {
|
||||||
toolTipText = 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()){
|
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<QMouseEvent*>(event);
|
||||||
|
QTextCursor cursor = ui->textBrowser->cursorForPosition(mouseEvent->pos());
|
||||||
|
cursor.select(QTextCursor::WordUnderCursor);
|
||||||
|
if (!cursor.selectedText().isEmpty()){
|
||||||
|
QRegExp rx("<a name=\"(.*)\"",Qt::CaseSensitive, QRegExp::RegExp2);
|
||||||
|
rx.setMinimal(true);
|
||||||
|
QString sel=cursor.selection().toHtml();
|
||||||
|
QStringList anchors;
|
||||||
|
int pos=0;
|
||||||
|
while ((pos = rx.indexIn(sel,pos)) != -1) {
|
||||||
|
anchors << rx.cap(1);
|
||||||
|
pos += rx.matchedLength();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!anchors.isEmpty()){
|
||||||
|
if (anchors.at(0).startsWith(PERSONID)){
|
||||||
|
RsGxsId mId = RsGxsId(QString(anchors.at(0)).replace(PERSONID,"").toStdString());
|
||||||
|
if(!mId.isNull()) {
|
||||||
|
RsIdentityDetails details;
|
||||||
|
if (rsIdentity->getIdDetails(mId, details)){
|
||||||
|
QString text = QString("@").append(GxsIdDetails::getName(details)).append(" ");
|
||||||
|
ui->chatTextEdit->textCursor().insertText(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (event->type() == QEvent::WindowActivate) {
|
if (event->type() == QEvent::WindowActivate) {
|
||||||
if (isVisible() && (window() == NULL || window()->isActiveWindow())) {
|
if (isVisible() && (window() == NULL || window()->isActiveWindow())) {
|
||||||
@ -963,9 +1002,13 @@ void ChatWidget::addChatMsg(bool incoming, const QString &name, const RsGxsId gx
|
|||||||
formatMsg.replace(QString("<a name=\"time\">"),QString("<a name=\"%1\">").arg(timeStamp));
|
formatMsg.replace(QString("<a name=\"time\">"),QString("<a name=\"%1\">").arg(timeStamp));
|
||||||
//replace Name anchors with GXS Id
|
//replace Name anchors with GXS Id
|
||||||
QString strGxsId = "";
|
QString strGxsId = "";
|
||||||
if (!gxsId.isNull())
|
if (!gxsId.isNull()) {
|
||||||
strGxsId = QString::fromStdString(gxsId.toStdString());
|
strGxsId = QString::fromStdString(gxsId.toStdString());
|
||||||
formatMsg.replace(QString("<a name=\"name\">"),QString("<a name=\"Person Id: %1\">").arg(strGxsId));
|
formatMsg.replace(QString("<a name=\"name\">")
|
||||||
|
,QString("<a name=\"").append(PERSONID).append("%1\">").arg(strGxsId) );
|
||||||
|
} else {
|
||||||
|
formatMsg.replace(QString("<a name=\"name\">"),"");
|
||||||
|
}
|
||||||
|
|
||||||
QTextCursor textCursor = QTextCursor(ui->textBrowser->textCursor());
|
QTextCursor textCursor = QTextCursor(ui->textBrowser->textCursor());
|
||||||
textCursor.movePosition(QTextCursor::End);
|
textCursor.movePosition(QTextCursor::End);
|
||||||
|
Loading…
Reference in New Issue
Block a user