From d1328f4467bc2fa236196b6ed4d9a8785f188b5b Mon Sep 17 00:00:00 2001 From: hunbernd Date: Sat, 21 Jan 2017 22:53:56 +0100 Subject: [PATCH] Fix spaces between emoticons in message composer and forum --- retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp | 8 +++++++- retroshare-gui/src/gui/msgs/MessageComposer.cpp | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) 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)