diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp index ccb4bd1dd..8a8ea4d15 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp @@ -370,7 +370,7 @@ void ChatLobbyDialog::addChatMsg(const ChatMessage& msg) else name = QString::fromUtf8(msg.peer_alternate_nickname.c_str()) + " (" + QString::fromStdString(gxs_id.toStdString()) + ")" ; - ui.chatWidget->addChatMsg(msg.incoming, name, sendTime, recvTime, message, ChatWidget::MSGTYPE_NORMAL); + ui.chatWidget->addChatMsg(msg.incoming, name, gxs_id, sendTime, recvTime, message, ChatWidget::MSGTYPE_NORMAL); emit messageReceived(msg.incoming, id(), sendTime, name, message) ; // This is a trick to translate HTML into text. diff --git a/retroshare-gui/src/gui/chat/ChatStyle.cpp b/retroshare-gui/src/gui/chat/ChatStyle.cpp index 7bc382dbd..b6a27b90c 100644 --- a/retroshare-gui/src/gui/chat/ChatStyle.cpp +++ b/retroshare-gui/src/gui/chat/ChatStyle.cpp @@ -351,11 +351,14 @@ QString ChatStyle::formatMessage(enumFormatMessage type, const QString &name, co Q_UNUSED(flag); #endif - QString formatMsg = style.replace("%name%", RsHtml::plainText(name)) - .replace("%date%", DateTime::formatDate(timestamp.date())) - .replace("%time%", DateTime::formatTime(timestamp.time())) + QString strName = RsHtml::plainText(name).prepend(QString("")).append(QString("")); + QString strDate = DateTime::formatDate(timestamp.date()).prepend(QString("")).append(QString("")); + QString strTime = DateTime::formatTime(timestamp.time()).prepend(QString("")).append(QString("")); + QString formatMsg = style.replace("%name%", strName) + .replace("%date%", strDate) + .replace("%time%", strTime) #ifdef COLORED_NICKNAMES - .replace("%color%", color.name()) + .replace("%color%", color.name()) #endif .replace("%message%", messageBody ) ; if ( !styleOptimized.isEmpty() ) { diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index 825ddfb31..564c0860c 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -845,6 +845,13 @@ void ChatWidget::setWelcomeMessage(QString &text) } void ChatWidget::addChatMsg(bool incoming, const QString &name, const QDateTime &sendTime, const QDateTime &recvTime, const QString &message, MsgType chatType) +{ + addChatMsg(incoming, name, RsGxsId(), sendTime, recvTime, message, chatType); +} + +void ChatWidget::addChatMsg(bool incoming, const QString &name, const RsGxsId gxsId + , const QDateTime &sendTime, const QDateTime &recvTime + , const QString &message, MsgType chatType) { #ifdef CHAT_DEBUG std::cout << "ChatWidget::addChatMsg message : " << message.toStdString() << std::endl; @@ -905,8 +912,15 @@ void ChatWidget::addChatMsg(bool incoming, const QString &name, const QDateTime QString formatMsg = chatStyle.formatMessage(type, name, dtTimestamp, formattedMessage, formatFlag); QString timeStamp = dtTimestamp.toString(Qt::ISODate); - formatMsg.prepend(QString("").arg(timeStamp)); - //To call this anchor do: ui->textBrowser->scrollToAnchor(QString("%1_%2").arg(timeStamp).arg(name)); + //replace Date and Time anchors + formatMsg.replace(QString(""),QString("").arg(timeStamp)); + formatMsg.replace(QString(""),QString("").arg(timeStamp)); + //replace Name anchors with GXS Id + QString strGxsId = ""; + if (!gxsId.isNull()) + strGxsId = QString::fromStdString(gxsId.toStdString()); + formatMsg.replace(QString(""),QString("").arg(strGxsId)); + QTextCursor textCursor = QTextCursor(ui->textBrowser->textCursor()); textCursor.movePosition(QTextCursor::End); textCursor.setBlockFormat(QTextBlockFormat ()); diff --git a/retroshare-gui/src/gui/chat/ChatWidget.h b/retroshare-gui/src/gui/chat/ChatWidget.h index 6d041e493..d93df9496 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.h +++ b/retroshare-gui/src/gui/chat/ChatWidget.h @@ -94,6 +94,7 @@ public: void setWelcomeMessage(QString &text); void addChatMsg(bool incoming, const QString &name, const QDateTime &sendTime, const QDateTime &recvTime, const QString &message, MsgType chatType); + void addChatMsg(bool incoming, const QString &name, const RsGxsId gxsId, const QDateTime &sendTime, const QDateTime &recvTime, const QString &message, MsgType chatType); void updateStatusString(const QString &statusMask, const QString &statusString, bool permanent = false); void addToolsAction(QAction *action);