diff --git a/Telegram/SourceFiles/boxes/add_contact_box.cpp b/Telegram/SourceFiles/boxes/add_contact_box.cpp index 1c529b4ed..0d67fc308 100644 --- a/Telegram/SourceFiles/boxes/add_contact_box.cpp +++ b/Telegram/SourceFiles/boxes/add_contact_box.cpp @@ -438,7 +438,7 @@ void GroupInfoBox::prepare() { _initialTitle); _title->setMaxLength(kMaxGroupChannelTitle); _title->setInstantReplaces(Ui::InstantReplaces::Default()); - _title ->setInstantReplacesEnabled(Global::ReplaceEmojiValue()); + _title->setInstantReplacesEnabled(Global::ReplaceEmojiValue()); Ui::Emoji::SuggestionsController::Init( getDelegate()->outerContainer(), _title); diff --git a/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp index 7cca5cba8..65bb708f9 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp @@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/text/text_utilities.h" #include "ui/text_options.h" #include "ui/special_buttons.h" +#include "chat_helpers/emoji_suggestions_widget.h" #include "info/profile/info_profile_button.h" #include "settings/settings_privacy_security.h" #include "boxes/calendar_box.h" @@ -412,6 +413,11 @@ not_null EditAdminBox::addRankInput() { _oldRank), st::rightsAboutMargin); result->setMaxLength(kAdminRoleLimit); + result->setInstantReplaces(Ui::InstantReplaces::Default()); + result->setInstantReplacesEnabled(Global::ReplaceEmojiValue()); + Ui::Emoji::SuggestionsController::Init( + getDelegate()->outerContainer(), + result); addControl( object_ptr( diff --git a/Telegram/SourceFiles/history/history_message.cpp b/Telegram/SourceFiles/history/history_message.cpp index a7ddd7639..b6b8d80a4 100644 --- a/Telegram/SourceFiles/history/history_message.cpp +++ b/Telegram/SourceFiles/history/history_message.cpp @@ -421,6 +421,8 @@ HistoryMessage::HistoryMessage( setGroupId( MessageGroupId::FromRaw(history->peer->id, groupedId->v)); } + + refreshMessageBadge(); } HistoryMessage::HistoryMessage( @@ -636,8 +638,11 @@ bool HistoryMessage::updateDependencyItem() { return true; } -void HistoryMessage::updateAdminBadgeState() { - _adminBadge = [&] { +void HistoryMessage::refreshMessageBadge() { + const auto text = [&] { + if (isDiscussionPost()) { + return tr::lng_channel_badge(tr::now); + } const auto channel = history()->peer->asMegagroup(); const auto user = author()->asUser(); if (!channel || !user) { @@ -655,11 +660,19 @@ void HistoryMessage::updateAdminBadgeState() { ? tr::lng_admin_badge(tr::now) : i->second; }(); + if (text.isEmpty()) { + _messageBadge.clear(); + } else { + _messageBadge.setText( + st::defaultTextStyle, + TextUtilities::SingleLine(text)); + } } void HistoryMessage::applyGroupAdminChanges( const base::flat_set &changes) { if (!out() && changes.contains(peerToUser(author()->id))) { + refreshMessageBadge(); history()->owner().requestItemResize(this); } } @@ -671,10 +684,6 @@ bool HistoryMessage::allowsForward() const { return !_media || _media->allowsForward(); } -bool HistoryMessage::hasMessageBadge() const { - return hasAdminBadge() || isDiscussionPost(); -} - bool HistoryMessage::isTooOldForEdit(TimeId now) const { const auto peer = _history->peer; if (peer->isSelf()) { diff --git a/Telegram/SourceFiles/history/history_message.h b/Telegram/SourceFiles/history/history_message.h index 8cfd5df2d..9f4f732f5 100644 --- a/Telegram/SourceFiles/history/history_message.h +++ b/Telegram/SourceFiles/history/history_message.h @@ -104,13 +104,12 @@ public: [[nodiscard]] bool allowsEdit(TimeId now) const override; [[nodiscard]] bool uploading() const; - [[nodiscard]] QString adminBadge() const { - return _adminBadge; + [[nodiscard]] const Ui::Text::String &messageBadge() const { + return _messageBadge; } - [[nodiscard]] bool hasAdminBadge() const { - return !_adminBadge.isEmpty(); + [[nodiscard]] bool hasMessageBadge() const { + return !_messageBadge.isEmpty(); } - [[nodiscard]] bool hasMessageBadge() const; void applyGroupAdminChanges( const base::flat_set &changes) override; @@ -180,9 +179,10 @@ private: CreateConfig &config, const MTPDmessageFwdHeader &data); - void updateAdminBadgeState(); + void refreshMessageBadge(); + + Ui::Text::String _messageBadge; - QString _adminBadge; QString _timeText; int _timeWidth = 0; diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index 721fe86f4..82c83ed7a 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -123,11 +123,6 @@ int KeyboardStyle::minButtonWidth( return result; } -QString MessageBadgeText(not_null message) { - const auto result = message->adminBadge(); - return result.isEmpty() ? tr::lng_channel_badge(tr::now) : result; -} - QString FastReplyText() { return tr::lng_fast_reply(tr::now); } @@ -238,9 +233,6 @@ QSize Message::performCountOptimalSize() { if (reply) { reply->updateName(); } - if (displayFromName()) { - item->updateAdminBadgeState(); - } auto mediaDisplayed = false; if (media) { @@ -306,8 +298,7 @@ QSize Message::performCountOptimalSize() { ? st::msgFont->width(FastReplyText()) : 0; if (item->hasMessageBadge()) { - const auto badgeWidth = st::msgFont->width( - MessageBadgeText(item)); + const auto badgeWidth = item->messageBadge().maxWidth(); namew += st::msgPadding.right() + std::max(badgeWidth, replyWidth); } else if (replyWidth) { @@ -525,7 +516,7 @@ void Message::paintFromName( if (displayFromName()) { const auto badgeWidth = [&] { if (item->hasMessageBadge()) { - return st::msgFont->width(MessageBadgeText(item)); + return item->messageBadge().maxWidth(); } return 0; }(); @@ -577,10 +568,18 @@ void Message::paintFromName( p.setFont(ClickHandler::showAsActive(_fastReplyLink) ? st::msgFont->underline() : st::msgFont); - p.drawText( - trect.left() + trect.width() - rightWidth, - trect.top() + st::msgFont->ascent, - replyWidth ? FastReplyText() : MessageBadgeText(item)); + if (replyWidth) { + p.drawText( + trect.left() + trect.width() - rightWidth, + trect.top() + st::msgFont->ascent, + FastReplyText()); + } else { + item->messageBadge().draw( + p, + trect.left() + trect.width() - rightWidth, + trect.top(), + rightWidth); + } } trect.setY(trect.y() + st::msgNameFont->height); } @@ -1551,7 +1550,7 @@ void Message::fromNameUpdated(int width) const { ? st::msgFont->width(FastReplyText()) : 0; if (item->hasMessageBadge()) { - const auto badgeWidth = st::msgFont->width(MessageBadgeText(item)); + const auto badgeWidth = item->messageBadge().maxWidth(); width -= st::msgPadding.right() + std::max(badgeWidth, replyWidth); } else if (replyWidth) { width -= st::msgPadding.right() + replyWidth;