mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 14:45:14 +00:00
Implement emoji search / categories.
This commit is contained in:
@@ -213,49 +213,13 @@ auto SuggestionsWidget::getRowsByQuery(const QString &text) const
|
||||
return ranges::none_of(text, [](QChar ch) { return ch.isLower(); });
|
||||
}();
|
||||
const auto exact = !middle || simple;
|
||||
const auto list = Core::App().emojiKeywords().query(real, exact);
|
||||
if (list.empty()) {
|
||||
return {};
|
||||
}
|
||||
const auto list = Core::App().emojiKeywords().queryMine(real, exact);
|
||||
using Entry = ChatHelpers::EmojiKeywords::Result;
|
||||
auto result = ranges::views::all(
|
||||
return ranges::views::all(
|
||||
list
|
||||
) | ranges::views::transform([](const Entry &result) {
|
||||
return Row(result.emoji, result.replacement);
|
||||
}) | ranges::to_vector;
|
||||
|
||||
auto lastRecent = begin(result);
|
||||
const auto &recent = Core::App().settings().recentEmoji();
|
||||
for (const auto &item : recent) {
|
||||
const auto emoji = std::get_if<EmojiPtr>(&item.id.data);
|
||||
if (!emoji) {
|
||||
continue;
|
||||
}
|
||||
const auto original = (*emoji)->original()
|
||||
? (*emoji)->original()
|
||||
: (*emoji);
|
||||
const auto it = ranges::find(result, original, [](const Row &row) {
|
||||
return row.emoji.get();
|
||||
});
|
||||
if (it > lastRecent && it != end(result)) {
|
||||
std::rotate(lastRecent, it, it + 1);
|
||||
++lastRecent;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &item : result) {
|
||||
item.emoji = [&] {
|
||||
const auto result = item.emoji;
|
||||
const auto &variants = Core::App().settings().emojiVariants();
|
||||
const auto i = result->hasVariants()
|
||||
? variants.find(result->nonColoredId())
|
||||
: end(variants);
|
||||
return (i != end(variants))
|
||||
? result->variant(i->second)
|
||||
: result.get();
|
||||
}();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void SuggestionsWidget::resizeToRows() {
|
||||
|
Reference in New Issue
Block a user