Show custom emoji in private chat reactions.

This commit is contained in:
John Preston 2022-08-16 20:57:40 +03:00
parent 09124f6424
commit 1e2e007d38
15 changed files with 54 additions and 14 deletions

View File

@ -488,6 +488,8 @@ PRIVATE
data/data_media_types.h
# data/data_messages.cpp
# data/data_messages.h
data/data_message_reaction_id.cpp
data/data_message_reaction_id.h
data/data_message_reactions.cpp
data/data_message_reactions.h
data/data_msg_id.h
@ -697,6 +699,8 @@ PRIVATE
history/view/history_view_react_animation.h
history/view/history_view_react_button.cpp
history/view/history_view_react_button.h
history/view/history_view_react_selector.cpp
history/view/history_view_react_selector.h
history/view/history_view_reactions.cpp
history/view/history_view_reactions.h
history/view/history_view_replies_section.cpp

View File

@ -17,7 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_changes.h"
#include "data/data_session.h"
#include "data/data_media_types.h"
#include "data/data_message_reactions.h"
#include "data/data_message_reaction_id.h"
#include "main/main_app_config.h"
#include "main/main_session.h"
#include "main/main_account.h"

View File

@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_changes.h"
#include "data/data_document.h"
#include "data/data_document_media.h"
#include "data/stickers/data_custom_emoji.h"
#include "lottie/lottie_icon.h"
#include "storage/localimageloader.h"
#include "ui/image/image_location_factory.h"
@ -203,6 +204,16 @@ QImage Reactions::resolveImageFor(
Unexpected("ImageSize in Reactions::resolveImageFor.");
}
std::unique_ptr<Ui::Text::CustomEmoji> Reactions::resolveCustomFor(
const ReactionId &emoji,
ImageSize size) {
const auto custom = std::get_if<DocumentId>(&emoji.data);
if (!custom) {
return nullptr;
}
return _owner->customEmojiManager().create(*custom, [] {});
}
void Reactions::resolveImages() {
for (auto &[id, set] : _images) {
if (!set.bottomInfo.isNull() || set.icon || set.media) {

View File

@ -10,6 +10,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/timer.h"
#include "data/data_message_reaction_id.h"
namespace Ui::Text {
class CustomEmoji;
} // namespace Ui::Text
namespace Lottie {
class Icon;
} // namespace Lottie
@ -62,6 +66,9 @@ public:
[[nodiscard]] QImage resolveImageFor(
const ReactionId &emoji,
ImageSize size);
[[nodiscard]] std::unique_ptr<Ui::Text::CustomEmoji> resolveCustomFor(
const ReactionId &emoji,
ImageSize size);
void send(not_null<HistoryItem*> item, const ReactionId &chosen);
[[nodiscard]] bool sending(not_null<HistoryItem*> item) const;

View File

@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/chat/chat_style.h"
#include "ui/text/text_options.h"
#include "ui/text/text_utilities.h"
#include "ui/text/text_block.h"
#include "lang/lang_keys.h"
#include "history/history_item_components.h"
#include "history/history_message.h"
@ -355,7 +356,12 @@ void BottomInfo::paintReactions(
y += st::msgDateFont->height;
widthLeft = availableWidth;
}
if (reaction.image.isNull()) {
if (!reaction.custom && reaction.image.isNull()) {
reaction.custom = _reactionsOwner->resolveCustomFor(
reaction.id,
::Data::Reactions::ImageSize::BottomInfo);
}
if (!reaction.custom && reaction.image.isNull()) {
reaction.image = _reactionsOwner->resolveImageFor(
reaction.id,
::Data::Reactions::ImageSize::BottomInfo);
@ -369,6 +375,9 @@ void BottomInfo::paintReactions(
&& (reaction.count < 2 || !reaction.animation->flying());
if (!reaction.image.isNull() && !skipImage) {
p.drawImage(image.topLeft(), reaction.image);
} else if (reaction.custom && !skipImage) {
const auto size = Ui::Text::AdjustCustomEmojiSize(st::emojiSize);
reaction.custom->paint(p, x + (st::reactionInfoSize - size) / 2, y + (st::msgDateFont->height - size) / 2, crl::now(), Qt::white, false);
}
if (animating) {
animations.push_back({

View File

@ -8,7 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#pragma once
#include "history/view/history_view_object.h"
#include "data/data_message_reactions.h"
#include "data/data_message_reaction_id.h"
#include "ui/text/text.h"
#include "base/flags.h"
@ -16,6 +16,18 @@ namespace Ui {
struct ChatPaintContext;
} // namespace Ui
namespace Ui::Text {
class CustomEmoji;
} // namespace Ui::Text
namespace Data {
class Reactions;
} // namespace Data
namespace Lottie {
class Icon;
} // namespace Lottie
namespace HistoryView {
namespace Reactions {
class Animation;
@ -93,6 +105,7 @@ private:
struct Reaction {
mutable std::unique_ptr<Reactions::Animation> animation;
mutable QImage image;
mutable std::unique_ptr<Ui::Text::CustomEmoji> custom;
ReactionId id;
QString countText;
int count = 0;

View File

@ -34,10 +34,6 @@ struct ChatPaintContext;
class ChatStyle;
} // namespace Ui
namespace Lottie {
class Icon;
} // namespace Lottie
namespace HistoryView {
enum class PointState : char;

View File

@ -556,7 +556,6 @@ void Manager::updateButton(ButtonParameters parameters) {
if (_button) {
_button->applyState(ButtonState::Hidden);
_buttonHiding.push_back(std::move(_button));
_expandSelectorRequests.fire({ .expanded = false });
}
_buttonShowTimer.cancel();
_scheduledParameters = std::nullopt;

View File

@ -9,7 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/effects/animations.h"
#include "ui/widgets/scroll_area.h"
#include "data/data_message_reactions.h"
#include "data/data_message_reaction_id.h"
#include "ui/chat/chat_style.h"
namespace Ui {

View File

@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/view/history_view_react_animation.h"
#include "history/view/history_view_group_call_bar.h"
#include "core/click_handler_types.h"
#include "data/data_message_reactions.h"
#include "data/data_peer.h"
#include "lang/lang_tag.h"
#include "ui/chat/chat_style.h"

View File

@ -8,10 +8,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#pragma once
#include "history/view/history_view_object.h"
#include "data/data_message_reactions.h"
#include "data/data_message_reaction_id.h"
namespace Data {
class CloudImageView;
class Reactions;
} // namespace Data
namespace Ui {

View File

@ -15,7 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history.h"
#include "api/api_who_reacted.h"
#include "ui/controls/who_reacted_context_action.h"
#include "data/data_message_reactions.h"
#include "data/data_message_reaction_id.h"
#include "main/main_session.h"
#include "data/data_session.h"
#include "data/data_peer.h"

View File

@ -10,7 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/rp_widget.h"
#include "ui/abstract_button.h"
#include "ui/controls/who_reacted_context_action.h"
#include "data/data_message_reactions.h"
#include "data/data_message_reaction_id.h"
#include "styles/style_widgets.h"
#include "styles/style_chat.h"

View File

@ -17,7 +17,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h"
#include "data/notify/data_notify_settings.h"
#include "data/stickers/data_custom_emoji.h"
#include "data/data_message_reactions.h"
#include "data/data_document_media.h"
#include "data/data_session.h"
#include "data/data_channel.h"

View File

@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "data/data_message_reactions.h"
#include "data/data_message_reaction_id.h"
#include "base/observer.h"
#include "base/timer.h"