Add whitespaces around smileys.

Only replace smileys with an image when they are surrounded by whitespaces.
This fixes smileys in links and other text that happen to include the sequence for a smiley.
This commit is contained in:
sehraf 2016-01-05 14:58:41 +01:00
parent f1f111f096
commit 54f9912c32
2 changed files with 49 additions and 3 deletions

View file

@ -1391,7 +1391,13 @@ void ChatWidget::smileyWidget()
void ChatWidget::addSmiley()
{
ui->chatTextEdit->textCursor().insertText(qobject_cast<QPushButton*>(sender())->toolTip().split("|").first());
QString smiley = qobject_cast<QPushButton*>(sender())->toolTip().split("|").first();
// add trailing space
smiley += QString(" ");
// add preceding space when needed (not at start of text or preceding space already exists)
if(!ui->chatTextEdit->textCursor().atStart() && ui->chatTextEdit->toPlainText()[ui->chatTextEdit->textCursor().position() - 1] != QChar(' '))
smiley = QString(" ") + smiley;
ui->chatTextEdit->textCursor().insertText(smiley);
}
void ChatWidget::clearChatHistory()