mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04: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)
|
QString ChatStyle::formatMessage(enumFormatMessage type, const QString &name, const QDateTime ×tamp, const QString &message, unsigned int flag)
|
||||||
{
|
{
|
||||||
|
bool me = false;
|
||||||
QDomDocument doc ;
|
QDomDocument doc ;
|
||||||
QString styleOptimized ;
|
QString styleOptimized ;
|
||||||
QString errorMsg ; int errorLine ; int errorColumn ;
|
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){
|
for (int curs = 0; curs < count; ++curs){
|
||||||
QDomNode it = body.childNodes().item(curs);
|
QDomNode it = body.childNodes().item(curs);
|
||||||
if (it.nodeName().toLower() != "style") {
|
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;
|
QString str;
|
||||||
QTextStream stream(&str);
|
QTextStream stream(&str);
|
||||||
it.toElement().save(stream, -1);
|
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 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 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>"));
|
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)
|
QString formatMsg = style.replace("%name%", strName)
|
||||||
.replace("%date%", strDate)
|
.replace("%date%", strDate)
|
||||||
.replace("%time%", strTime)
|
.replace("%time%", strTime)
|
||||||
|
Loading…
Reference in New Issue
Block a user