mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 08:29:26 -05:00
/me
TODO: allow customizing the style
This commit is contained in:
parent
1da28aff90
commit
cdda411c79
@ -267,6 +267,7 @@ static QString getStyle(const QDir &styleDir, const QString &styleVariant, enumG
|
||||
|
||||
QString ChatStyle::formatMessage(enumFormatMessage type, const QString &name, const QDateTime ×tamp, const QString &message, unsigned int flag)
|
||||
{
|
||||
bool me = false;
|
||||
QDomDocument doc ;
|
||||
QString styleOptimized ;
|
||||
QString errorMsg ; int errorLine ; int errorColumn ;
|
||||
@ -279,6 +280,12 @@ QString ChatStyle::formatMessage(enumFormatMessage type, const QString &name, co
|
||||
for (int curs = 0; curs < count; ++curs){
|
||||
QDomNode it = body.childNodes().item(curs);
|
||||
if (it.nodeName().toLower() != "style") {
|
||||
//find out if the message starts with /me
|
||||
if(it.isText()){
|
||||
me = me || it.toText().data().trimmed().startsWith("/me ");
|
||||
}else if(it.isElement()){
|
||||
me = me || it.toElement().text().trimmed().startsWith("/me ");
|
||||
}
|
||||
QString str;
|
||||
QTextStream stream(&str);
|
||||
it.toElement().save(stream, -1);
|
||||
@ -354,6 +361,13 @@ QString ChatStyle::formatMessage(enumFormatMessage type, const QString &name, co
|
||||
QString strName = RsHtml::plainText(name).prepend(QString("<a name=\"name\">")).append(QString("</a>"));
|
||||
QString strDate = DateTime::formatDate(timestamp.date()).prepend(QString("<a name=\"date\">")).append(QString("</a>"));
|
||||
QString strTime = DateTime::formatTime(timestamp.time()).prepend(QString("<a name=\"time\">")).append(QString("</a>"));
|
||||
|
||||
//handle /me
|
||||
if(me){
|
||||
messageBody = messageBody.replace(messageBody.indexOf("/me "), 3, strName); //replace only the first /me
|
||||
strName = "*";
|
||||
}
|
||||
|
||||
QString formatMsg = style.replace("%name%", strName)
|
||||
.replace("%date%", strDate)
|
||||
.replace("%time%", strTime)
|
||||
|
Loading…
Reference in New Issue
Block a user