mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Sync custom emoji from strip to recent in the panel.
This commit is contained in:
parent
7c3814cdcd
commit
d5008fe7ac
4 changed files with 34 additions and 17 deletions
|
@ -751,7 +751,7 @@ void EmojiListWidget::fillRecent() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
_recent.push_back({
|
_recent.push_back({
|
||||||
.custom = resolveCustomEmoji(one.id),
|
.custom = resolveCustomRecent(one.id),
|
||||||
.id = one.id,
|
.id = one.id,
|
||||||
});
|
});
|
||||||
if (document) {
|
if (document) {
|
||||||
|
@ -771,7 +771,7 @@ void EmojiListWidget::fillRecentFrom(const std::vector<DocumentId> &list) {
|
||||||
_recent.reserve(list.size());
|
_recent.reserve(list.size());
|
||||||
for (const auto &id : list) {
|
for (const auto &id : list) {
|
||||||
_recent.push_back({
|
_recent.push_back({
|
||||||
.custom = resolveCustomEmoji(id),
|
.custom = resolveCustomRecent(id),
|
||||||
.id = { RecentEmojiDocument{.id = id, .test = test } },
|
.id = { RecentEmojiDocument{.id = id, .test = test } },
|
||||||
});
|
});
|
||||||
_recentCustomIds.emplace(id);
|
_recentCustomIds.emplace(id);
|
||||||
|
@ -1587,30 +1587,38 @@ not_null<Ui::Text::CustomEmoji*> EmojiListWidget::resolveCustomEmoji(
|
||||||
).first->second.emoji.get();
|
).first->second.emoji.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ui::Text::CustomEmoji *EmojiListWidget::resolveCustomEmoji(
|
Ui::Text::CustomEmoji *EmojiListWidget::resolveCustomRecent(
|
||||||
RecentEmojiId customId) {
|
RecentEmojiId customId) {
|
||||||
const auto &data = customId.data;
|
const auto &data = customId.data;
|
||||||
if (const auto document = std::get_if<RecentEmojiDocument>(&data)) {
|
if (const auto document = std::get_if<RecentEmojiDocument>(&data)) {
|
||||||
return resolveCustomEmoji(document->id);
|
return resolveCustomRecent(document->id);
|
||||||
} else if (const auto emoji = std::get_if<EmojiPtr>(&data)) {
|
} else if (const auto emoji = std::get_if<EmojiPtr>(&data)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
Unexpected("Custom recent emoji id.");
|
Unexpected("Custom recent emoji id.");
|
||||||
}
|
}
|
||||||
|
|
||||||
not_null<Ui::Text::CustomEmoji*> EmojiListWidget::resolveCustomEmoji(
|
not_null<Ui::Text::CustomEmoji*> EmojiListWidget::resolveCustomRecent(
|
||||||
DocumentId documentId) {
|
DocumentId documentId) {
|
||||||
const auto i = _customEmoji.find(documentId);
|
const auto i = _customRecent.find(documentId);
|
||||||
if (i != end(_customEmoji)) {
|
if (i != end(_customRecent)) {
|
||||||
return i->second.emoji.get();
|
return i->second.get();
|
||||||
|
}
|
||||||
|
const auto j = _customEmoji.find(documentId);
|
||||||
|
if (j != end(_customEmoji)) {
|
||||||
|
return j->second.emoji.get();
|
||||||
}
|
}
|
||||||
auto repaint = repaintCallback(documentId, RecentEmojiSectionSetId());
|
auto repaint = repaintCallback(documentId, RecentEmojiSectionSetId());
|
||||||
auto custom = _customRecentFactory
|
if (_customRecentFactory) {
|
||||||
? _customRecentFactory(documentId, std::move(repaint))
|
return _customRecent.emplace(
|
||||||
: session().data().customEmojiManager().create(
|
|
||||||
documentId,
|
documentId,
|
||||||
std::move(repaint),
|
_customRecentFactory(documentId, std::move(repaint))
|
||||||
Data::CustomEmojiManager::SizeTag::Large);
|
).first->second.get();
|
||||||
|
}
|
||||||
|
auto custom = session().data().customEmojiManager().create(
|
||||||
|
documentId,
|
||||||
|
std::move(repaint),
|
||||||
|
Data::CustomEmojiManager::SizeTag::Large);
|
||||||
return _customEmoji.emplace(
|
return _customEmoji.emplace(
|
||||||
documentId,
|
documentId,
|
||||||
CustomEmojiInstance{ .emoji = std::move(custom), .recentOnly = true }
|
CustomEmojiInstance{ .emoji = std::move(custom), .recentOnly = true }
|
||||||
|
|
|
@ -304,9 +304,9 @@ private:
|
||||||
[[nodiscard]] not_null<Ui::Text::CustomEmoji*> resolveCustomEmoji(
|
[[nodiscard]] not_null<Ui::Text::CustomEmoji*> resolveCustomEmoji(
|
||||||
not_null<DocumentData*> document,
|
not_null<DocumentData*> document,
|
||||||
uint64 setId);
|
uint64 setId);
|
||||||
[[nodiscard]] Ui::Text::CustomEmoji *resolveCustomEmoji(
|
[[nodiscard]] Ui::Text::CustomEmoji *resolveCustomRecent(
|
||||||
Core::RecentEmojiId customId);
|
Core::RecentEmojiId customId);
|
||||||
[[nodiscard]] not_null<Ui::Text::CustomEmoji*> resolveCustomEmoji(
|
[[nodiscard]] not_null<Ui::Text::CustomEmoji*> resolveCustomRecent(
|
||||||
DocumentId documentId);
|
DocumentId documentId);
|
||||||
[[nodiscard]] Fn<void()> repaintCallback(
|
[[nodiscard]] Fn<void()> repaintCallback(
|
||||||
DocumentId documentId,
|
DocumentId documentId,
|
||||||
|
@ -330,6 +330,9 @@ private:
|
||||||
QVector<EmojiPtr> _emoji[kEmojiSectionCount];
|
QVector<EmojiPtr> _emoji[kEmojiSectionCount];
|
||||||
std::vector<CustomSet> _custom;
|
std::vector<CustomSet> _custom;
|
||||||
base::flat_map<DocumentId, CustomEmojiInstance> _customEmoji;
|
base::flat_map<DocumentId, CustomEmojiInstance> _customEmoji;
|
||||||
|
base::flat_map<
|
||||||
|
DocumentId,
|
||||||
|
std::unique_ptr<Ui::Text::CustomEmoji>> _customRecent;
|
||||||
int _customSingleSize = 0;
|
int _customSingleSize = 0;
|
||||||
bool _allowWithoutPremium = false;
|
bool _allowWithoutPremium = false;
|
||||||
Ui::RoundRect _overBg;
|
Ui::RoundRect _overBg;
|
||||||
|
|
|
@ -46,6 +46,7 @@ public:
|
||||||
void paint(QPainter &p, const Context &context) override;
|
void paint(QPainter &p, const Context &context) override;
|
||||||
void unload() override;
|
void unload() override;
|
||||||
bool ready() override;
|
bool ready() override;
|
||||||
|
bool readyInDefaultState() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::unique_ptr<Ui::Text::CustomEmoji> _wrapped;
|
const std::unique_ptr<Ui::Text::CustomEmoji> _wrapped;
|
||||||
|
@ -74,7 +75,8 @@ QString StripEmoji::entityData() {
|
||||||
void StripEmoji::paint(QPainter &p, const Context &context) {
|
void StripEmoji::paint(QPainter &p, const Context &context) {
|
||||||
if (_switched) {
|
if (_switched) {
|
||||||
_wrapped->paint(p, context);
|
_wrapped->paint(p, context);
|
||||||
} else if (_wrapped->ready() && _strip->inDefaultState(_index)) {
|
} else if (_wrapped->readyInDefaultState()
|
||||||
|
&& _strip->inDefaultState(_index)) {
|
||||||
_switched = true;
|
_switched = true;
|
||||||
_wrapped->paint(p, context);
|
_wrapped->paint(p, context);
|
||||||
} else {
|
} else {
|
||||||
|
@ -91,6 +93,10 @@ bool StripEmoji::ready() {
|
||||||
return _wrapped->ready();
|
return _wrapped->ready();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool StripEmoji::readyInDefaultState() {
|
||||||
|
return _wrapped->readyInDefaultState();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
Selector::Selector(
|
Selector::Selector(
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 3287bf45c607e980268090ae27dfe4fb69d037e4
|
Subproject commit 6dc6309269beb64a69e3184b671e030a2969f00e
|
Loading…
Add table
Reference in a new issue