From 16afb72166f32077e314e0fd0675f86088b922c9 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 3 Nov 2015 12:15:49 -0500 Subject: [PATCH] fixed emoji replaces in the beginning of the input fields --- Telegram/SourceFiles/gui/flatinput.cpp | 20 ++++++++++---------- Telegram/SourceFiles/gui/flattextarea.cpp | 10 +++++----- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Telegram/SourceFiles/gui/flatinput.cpp b/Telegram/SourceFiles/gui/flatinput.cpp index 887ea25994..8d5e5731c4 100644 --- a/Telegram/SourceFiles/gui/flatinput.cpp +++ b/Telegram/SourceFiles/gui/flatinput.cpp @@ -917,7 +917,7 @@ QVariant InputArea::InputAreaInner::loadResource(int type, const QUrl &name) { } void InputArea::processDocumentContentsChange(int position, int charsAdded) { - int32 emojiPosition = 0, emojiLen = 0; + int32 emojiPosition = -1, emojiLen = 0; const EmojiData *emoji = 0; static QString regular = qsl("Open Sans"), semibold = qsl("Open Sans Semibold"); @@ -982,11 +982,11 @@ void InputArea::processDocumentContentsChange(int position, int charsAdded) { ++fp; } } - if (emojiPosition) break; + if (emojiPosition >= 0) break; } - if (emojiPosition) break; + if (emojiPosition >= 0) break; } - if (emojiPosition) { + if (emojiPosition >= 0) { if (emoji) { if (!_inner.document()->pageSize().isNull()) { _inner.document()->setPageSize(QSizeF(0, 0)); @@ -999,7 +999,7 @@ void InputArea::processDocumentContentsChange(int position, int charsAdded) { position = emojiPosition + 1; emoji = 0; - emojiPosition = 0; + emojiPosition = -1; } else { break; } @@ -1611,7 +1611,7 @@ QVariant InputField::InputFieldInner::loadResource(int type, const QUrl &name) { } void InputField::processDocumentContentsChange(int position, int charsAdded) { - int32 emojiPosition = 0, emojiLen = 0; + int32 emojiPosition = -1, emojiLen = 0; const EmojiData *emoji = 0; static QString regular = qsl("Open Sans"), semibold = qsl("Open Sans Semibold"), space(' '); @@ -1689,9 +1689,9 @@ void InputField::processDocumentContentsChange(int position, int charsAdded) { ++fp; } } - if (emojiPosition) break; + if (emojiPosition >= 0) break; } - if (emojiPosition) break; + if (emojiPosition >= 0) break; if (b.next() != doc->end()) { emojiPosition = b.next().position() - 1; @@ -1702,7 +1702,7 @@ void InputField::processDocumentContentsChange(int position, int charsAdded) { break; } } - if (emojiPosition) { + if (emojiPosition >= 0) { if (emoji) { if (!_inner.document()->pageSize().isNull()) { _inner.document()->setPageSize(QSizeF(0, 0)); @@ -1715,7 +1715,7 @@ void InputField::processDocumentContentsChange(int position, int charsAdded) { position = emojiPosition + 1; emoji = 0; - emojiPosition = 0; + emojiPosition = -1; } else { break; } diff --git a/Telegram/SourceFiles/gui/flattextarea.cpp b/Telegram/SourceFiles/gui/flattextarea.cpp index d49a219481..8cb8103b6d 100644 --- a/Telegram/SourceFiles/gui/flattextarea.cpp +++ b/Telegram/SourceFiles/gui/flattextarea.cpp @@ -619,7 +619,7 @@ void FlatTextarea::checkContentHeight() { } void FlatTextarea::processDocumentContentsChange(int position, int charsAdded) { - int32 emojiPosition = 0, emojiLen = 0; + int32 emojiPosition = -1, emojiLen = 0; const EmojiData *emoji = 0; static QString regular = qsl("Open Sans"), semibold = qsl("Open Sans Semibold"); @@ -681,11 +681,11 @@ void FlatTextarea::processDocumentContentsChange(int position, int charsAdded) { ++fp; } } - if (emojiPosition) break; + if (emojiPosition >= 0) break; } - if (emojiPosition) break; + if (emojiPosition >= 0) break; } - if (emojiPosition) { + if (emojiPosition >= 0) { if (emoji) { if (!document()->pageSize().isNull()) { document()->setPageSize(QSizeF(0, 0)); @@ -698,7 +698,7 @@ void FlatTextarea::processDocumentContentsChange(int position, int charsAdded) { position = emojiPosition + 1; emoji = 0; - emojiPosition = 0; + emojiPosition = -1; } else { break; }