Fix spaces between emoticons in message composer and forum

This commit is contained in:
hunbernd 2017-01-21 22:53:56 +01:00
parent d0ab10cc38
commit d1328f4467
2 changed files with 14 additions and 2 deletions

View file

@ -400,7 +400,13 @@ void CreateGxsForumMsg::smileyWidgetForums()
void CreateGxsForumMsg::addSmileys() void CreateGxsForumMsg::addSmileys()
{ {
ui.forumMessage->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.forumMessage->textCursor().atStart() && ui.forumMessage->toPlainText()[ui.forumMessage->textCursor().position() - 1] != QChar(' '))
smiley = QString(" ") + smiley;
ui.forumMessage->textCursor().insertText(smiley);
} }
void CreateGxsForumMsg::addFile() void CreateGxsForumMsg::addFile()

View file

@ -2200,7 +2200,13 @@ void MessageComposer::smileyWidget()
void MessageComposer::addSmileys() void MessageComposer::addSmileys()
{ {
ui.msgText->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.msgText->textCursor().atStart() && ui.msgText->toPlainText()[ui.msgText->textCursor().position() - 1] != QChar(' '))
smiley = QString(" ") + smiley;
ui.msgText->textCursor().insertText(smiley);
} }
void MessageComposer::currentCharFormatChanged(const QTextCharFormat &format) void MessageComposer::currentCharFormatChanged(const QTextCharFormat &format)