diff --git a/retroshare-gui/src/gui/chat/ChatStyle.cpp b/retroshare-gui/src/gui/chat/ChatStyle.cpp index 3cb74a4cf..8d7b7ce60 100644 --- a/retroshare-gui/src/gui/chat/ChatStyle.cpp +++ b/retroshare-gui/src/gui/chat/ChatStyle.cpp @@ -272,6 +272,7 @@ QString ChatStyle::formatMessage(enumFormatMessage type, const QString &name, co QString styleOptimized ; QString errorMsg ; int errorLine ; int errorColumn ; QString messageBody = message ; + me = me || message.trimmed().startsWith("/me "); if (doc.setContent(messageBody, &errorMsg, &errorLine, &errorColumn)) { QDomElement body = doc.documentElement(); if (!body.isNull()){ @@ -362,9 +363,12 @@ QString ChatStyle::formatMessage(enumFormatMessage type, const QString &name, co QString strDate = DateTime::formatDate(timestamp.date()).prepend(QString("")).append(QString("")); QString strTime = DateTime::formatTime(timestamp.time()).prepend(QString("")).append(QString("")); + int bi = name.lastIndexOf(QRegExp(" \\(.*\\)")); //trim location from the end + QString strShortName = RsHtml::plainText(name.left(bi)).prepend(QString("")).append(QString("")); + //handle /me if(me){ - messageBody = messageBody.replace(messageBody.indexOf("/me "), 3, strName); //replace only the first /me + messageBody = messageBody.replace(messageBody.indexOf("/me "), 3, strShortName); //replace only the first /me strName = "*"; } diff --git a/retroshare-gui/src/gui/settings/ChatPage.cpp b/retroshare-gui/src/gui/settings/ChatPage.cpp index bee6f0248..6f87dfba0 100644 --- a/retroshare-gui/src/gui/settings/ChatPage.cpp +++ b/retroshare-gui/src/gui/settings/ChatPage.cpp @@ -338,6 +338,7 @@ void ChatPage::setPreviewMessages(QString &stylePath, QString styleVariant, QTex textBrowser->append(style.formatMessage(ChatStyle::FORMATMSG_OUTGOING, nameOutgoing, timestmp, tr("Outgoing message"))); textBrowser->append(style.formatMessage(ChatStyle::FORMATMSG_OOUTGOING, nameOutgoing, timestmp, tr("Outgoing offline message"))); textBrowser->append(style.formatMessage(ChatStyle::FORMATMSG_SYSTEM, tr("System"), timestmp, tr("System message"))); + textBrowser->append(style.formatMessage(ChatStyle::FORMATMSG_OUTGOING, tr("UserName"), timestmp, tr("/me is sending a message with /me"))); } void ChatPage::fillPreview(QListWidget *listWidget, QComboBox *comboBox, QTextBrowser *textBrowser)