2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-05 09:05:14 +00:00

Allow disabling first-word emoji suggestions.

This commit is contained in:
John Preston
2019-05-27 12:16:14 +02:00
parent a49a96ba33
commit 0eb975e679
3 changed files with 22 additions and 8 deletions

View File

@@ -503,9 +503,11 @@ void SuggestionsWidget::leaveEventHook(QEvent *e) {
SuggestionsController::SuggestionsController(
not_null<QWidget*> outer,
not_null<QTextEdit*> field)
not_null<QTextEdit*> field,
const Options &options)
: _field(field)
, _showExactTimer([=] { showWithQuery(getEmojiQuery()); }) {
, _showExactTimer([=] { showWithQuery(getEmojiQuery()); })
, _options(options) {
_container = base::make_unique_q<InnerDropdown>(
outer,
st::emojiSuggestionsDropdown);
@@ -555,11 +557,13 @@ SuggestionsController::SuggestionsController(
SuggestionsController *SuggestionsController::Init(
not_null<QWidget*> outer,
not_null<Ui::InputField*> field) {
not_null<Ui::InputField*> field,
const Options &options) {
const auto result = Ui::CreateChild<SuggestionsController>(
field.get(),
outer,
field->rawTextEdit());
field->rawTextEdit(),
options);
result->setReplaceCallback([=](
int from,
int till,
@@ -679,7 +683,8 @@ QString SuggestionsController::getEmojiQuery() {
const auto is = [&](QLatin1String string) {
return (text.compare(string, Qt::CaseInsensitive) == 0);
};
if (!length
if (!_options.suggestExactFirstWord
|| !length
|| text[0].isSpace()
|| (length > modernLimit)
|| (_queryStartPosition != 0)