diff --git a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp index f73aeef91..23a0bca04 100644 --- a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp +++ b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp @@ -400,7 +400,13 @@ void CreateGxsForumMsg::smileyWidgetForums() void CreateGxsForumMsg::addSmileys() { - ui.forumMessage->textCursor().insertText(qobject_cast(sender())->toolTip().split("|").first()); + QString smiley = qobject_cast(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() diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index ecd4327e6..a0b2c2e86 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -2200,7 +2200,13 @@ void MessageComposer::smileyWidget() void MessageComposer::addSmileys() { - ui.msgText->textCursor().insertText(qobject_cast(sender())->toolTip().split("|").first()); + QString smiley = qobject_cast(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)