diff --git a/src/chatlog/chatlog.cpp b/src/chatlog/chatlog.cpp index 5c41d51f6..ef877ea0a 100644 --- a/src/chatlog/chatlog.cpp +++ b/src/chatlog/chatlog.cpp @@ -25,7 +25,6 @@ #include "content/spinner.h" #include "../misc/style.h" -#include "../misc/smileypack.h" #include "../misc/settings.h" #include @@ -86,7 +85,7 @@ ChatLog::~ChatLog() ChatMessage* ChatLog::addChatMessage(const QString& sender, const QString &msg, bool self, bool alert) { - QString txt = SmileyPack::getInstance().smileyfied(msg); + QString txt = msg; if(alert) txt = "
" + txt + "
"; @@ -119,7 +118,7 @@ ChatMessage *ChatLog::addChatAction(const QString &sender, const QString &msg) { ChatMessage* line = new ChatMessage(scene, msg); line->addColumn(new Text(""), ColumnFormat(NAME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right)); - line->addColumn(new Text("
*" + sender + " " + SmileyPack::getInstance().smileyfied(msg) + "
", Style::getFont(Style::Big)), ColumnFormat(1.0, ColumnFormat::VariableSize)); + line->addColumn(new Text("
*" + sender + " " + msg + "
", Style::getFont(Style::Big)), ColumnFormat(1.0, ColumnFormat::VariableSize)); line->addColumn(new Spinner(QSizeF(16, 16)), ColumnFormat(TIME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right)); line->setAsAction(); diff --git a/src/chatlog/content/text.cpp b/src/chatlog/content/text.cpp index b8783066b..c07a453cf 100644 --- a/src/chatlog/content/text.cpp +++ b/src/chatlog/content/text.cpp @@ -17,6 +17,7 @@ #include "text.h" #include "../customtextdocument.h" +#include "src/misc/smileypack.h" #include #include @@ -50,11 +51,10 @@ Text::~Text() void Text::setText(const QString& txt) { - text = txt; + text = SmileyPack::getInstance().smileyfied(toHtmlChars(txt)); detectAnchors(); - - text.replace("\n", "
"); + detectQuotes(); ensureIntegrity(); freeResources(); @@ -287,6 +287,25 @@ void Text::detectAnchors() } } +void Text::detectQuotes() +{ + // detect text quotes + QStringList messageLines = text.split("\n"); + QString quotedText; + for (int i=0;i"; + else + quotedText += messageLines[i]; + + if (i < messageLines.size() - 1) + quotedText += "
"; + } + + text = quotedText; +} + QString Text::toHtmlChars(const QString &str) { static QList> replaceList = {{"&","&"}, {">",">"}, {"<","<"}}; diff --git a/src/chatlog/content/text.h b/src/chatlog/content/text.h index 8ef17499b..ef1deee67 100644 --- a/src/chatlog/content/text.h +++ b/src/chatlog/content/text.h @@ -62,6 +62,7 @@ protected: int cursorFromPos(QPointF scenePos) const; void detectAnchors(); + void detectQuotes(); QString toHtmlChars(const QString& str); private: