2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-03 16:15:13 +00:00

Instant in-field emoji and text replaces.

Fixes #4410. Fixes #522.
This commit is contained in:
John Preston
2018-05-13 18:14:02 +03:00
parent 8764da787b
commit 4b763a76df
8 changed files with 302 additions and 116 deletions

View File

@@ -11,6 +11,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/qthelp_regex.h"
#include "styles/style_history.h"
#include "window/window_controller.h"
#include "emoji_suggestions_data.h"
#include "chat_helpers/emoji_suggestions_helper.h"
#include "mainwindow.h"
#include "auth_session.h"
@@ -115,6 +117,22 @@ MessageField::MessageField(QWidget *parent, not_null<Window::Controller*> contro
setMaxHeight(st::historyComposeFieldMaxHeight);
setTagMimeProcessor(std::make_unique<FieldTagMimeProcessor>());
addInstantReplace("--", QString(1, QChar(8212)));
addInstantReplace("<<", QString(1, QChar(171)));
addInstantReplace(">>", QString(1, QChar(187)));
const auto &replacements = Ui::Emoji::internal::GetAllReplacements();
for (const auto &one : replacements) {
const auto with = Ui::Emoji::QStringFromUTF16(one.emoji);
const auto what = Ui::Emoji::QStringFromUTF16(one.replacement);
addInstantReplace(what, with);
}
const auto &pairs = Ui::Emoji::internal::GetReplacementPairs();
for (const auto &[what, index] : pairs) {
const auto emoji = Ui::Emoji::internal::ByIndex(index);
Assert(emoji != nullptr);
addInstantReplace(what, emoji->text());
}
}
bool MessageField::hasSendText() const {